Skip to content

Commit abcc9dc

Browse files
authored
Merge ba48bd7 into 0d804bb
2 parents 0d804bb + ba48bd7 commit abcc9dc

File tree

4 files changed

+98
-59
lines changed

4 files changed

+98
-59
lines changed

.github/workflows/go.yml

Lines changed: 68 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -2,78 +2,89 @@ name: CI
22

33
on:
44
push:
5-
branches: master
5+
branches: [ "main", "master" ]
66
pull_request:
7-
branches: "*"
7+
branches: [ "*" ]
88

99
jobs:
1010

11+
lint:
12+
name: Lint check
13+
runs-on: ubuntu-latest
14+
steps:
15+
16+
- name: Set up Go
17+
uses: actions/setup-go@v3
18+
with:
19+
go-version: 1.18
20+
21+
- name: Check out code into the Go module directory
22+
uses: actions/checkout@v3
23+
24+
- name: Golangci Lint
25+
# https://golangci-lint.run/
26+
uses: golangci/golangci-lint-action@v3
27+
with:
28+
version: latest
29+
args: "--out-${NO_FUTURE}format colored-line-number"
30+
1131
build:
12-
name: ${{ matrix.os }} - Go ${{ matrix.go_version }}
32+
name: Build and test - Go ${{ matrix.go_version }}
1333
runs-on: ubuntu-latest
1434
strategy:
15-
# If you want to matrix build , you can append the following list.
35+
# If you want to matrix build , you can append the following list.
1636
matrix:
1737
go_version:
18-
- 1.13
19-
- 1.14
38+
- 1.16
39+
- 1.18
40+
- 1.19
2041
os:
2142
- ubuntu-latest
2243

2344
steps:
2445

25-
- name: Set up Go ${{ matrix.go_version }}
26-
uses: actions/setup-go@v2
27-
with:
28-
go-version: ${{ matrix.go_version }}
29-
id: go
30-
31-
- name: Check out code into the Go module directory
32-
uses: actions/checkout@v2
33-
34-
- name: Cache build dependence
35-
uses: actions/cache@v2
36-
with:
37-
# Cache
38-
path: ~/go/pkg/mod
39-
# Cache key
40-
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
41-
# An ordered list of keys to use for restoring the cache if no cache hit occurred for key
42-
restore-keys: ${{ runner.os }}-go-
46+
- name: Set up Go ${{ matrix.go_version }}
47+
uses: actions/setup-go@v3
48+
with:
49+
go-version: ${{ matrix.go_version }}
50+
id: go
4351

44-
- name: Install goimports
45-
run: go get golang.org/x/tools/cmd/goimports
52+
- name: Check out code into the Go module directory
53+
uses: actions/checkout@v3
4654

47-
- name: Install go ci lint
48-
run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.27.0
55+
- name: Cache build dependence
56+
uses: actions/cache@v3
57+
with:
58+
# Cache
59+
path: ~/go/pkg/mod
60+
# Cache key
61+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
62+
# An ordered list of keys to use for restoring the cache if no cache hit occurred for key
63+
restore-keys: ${{ runner.os }}-go-
4964

50-
- name: Run Linter
51-
run: golangci-lint run --timeout=10m -v --disable-all --enable=govet --enable=staticcheck --enable=ineffassign --enable=misspell
65+
- name: Test
66+
run: |
67+
go test -v -race ./... -coverprofile=coverage.txt -covermode=atomic
68+
cd ./pkg/datasource/consul
69+
go test -race -count=1 ./... -coverprofile=coverage.txt -covermode=atomic
70+
cd ../etcdv3
71+
go test -race -count=1 ./... -coverprofile=coverage.txt -covermode=atomic
72+
cd ../k8s
73+
go test -race -count=1 ./... -coverprofile=coverage.txt -covermode=atomic
74+
cd ../nacos
75+
go test -race -count=1 ./... -coverprofile=coverage.txt -covermode=atomic
76+
cd ../apollo
77+
go test -race -count=1 ./... -coverprofile=coverage.txt -covermode=atomic
78+
cd ../../adapters/echo
79+
go test -race -count=1 ./... -coverprofile=coverage.txt -covermode=atomic
80+
cd ../gear
81+
go test -race -count=1 ./... -coverprofile=coverage.txt -covermode=atomic
82+
cd ../gin
83+
go test -race -count=1 ./... -coverprofile=coverage.txt -covermode=atomic
84+
cd ../grpc
85+
go test -race -count=1 ./... -coverprofile=coverage.txt -covermode=atomic
86+
cd ../micro
87+
go test -race -count=1 ./... -coverprofile=coverage.txt -covermode=atomic
5288
53-
- name: Test
54-
run: |
55-
diff -u <(echo -n) <(gofmt -d -s .)
56-
diff -u <(echo -n) <(goimports -d .)
57-
go test -v -race ./... -coverprofile=coverage.txt -covermode=atomic
58-
cd ./pkg/datasource/consul
59-
go test -race -count=1 ./... -coverprofile=coverage.txt -covermode=atomic
60-
cd ../etcdv3
61-
go test -race -count=1 ./... -coverprofile=coverage.txt -covermode=atomic
62-
cd ../k8s
63-
go test -race -count=1 ./... -coverprofile=coverage.txt -covermode=atomic
64-
cd ../nacos
65-
go test -race -count=1 ./... -coverprofile=coverage.txt -covermode=atomic
66-
cd ../apollo
67-
go test -race -count=1 ./... -coverprofile=coverage.txt -covermode=atomic
68-
cd ../../adapters/echo
69-
go test -race -count=1 ./... -coverprofile=coverage.txt -covermode=atomic
70-
cd ../gear
71-
go test -race -count=1 ./... -coverprofile=coverage.txt -covermode=atomic
72-
cd ../gin
73-
go test -race -count=1 ./... -coverprofile=coverage.txt -covermode=atomic
74-
cd ../grpc
75-
go test -race -count=1 ./... -coverprofile=coverage.txt -covermode=atomic
76-
cd ../micro
77-
go test -race -count=1 ./... -coverprofile=coverage.txt -covermode=atomic
78-
- name: Coverage
79-
run: bash <(curl -s https://codecov.io/bash)
89+
- name: Coverage
90+
run: bash <(curl -s https://codecov.io/bash)

.golangci.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Options for analysis running.
2+
run:
3+
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
4+
skip-dirs-use-default: true
5+
skip-dirs:
6+
- example
7+
skip-files:
8+
- ".*\\.pb\\.go$"
9+
# output configuration options
10+
output:
11+
format: colored-line-number
12+
# Refer to https://golangci-lint.run/usage/linters
13+
linters-settings:
14+
govet:
15+
# Disable analyzers by name.
16+
# Run `go tool vet help` to see all analyzers.
17+
disable:
18+
- stdmethods
19+
linters:
20+
disable-all: true
21+
enable:
22+
- goimports
23+
- gofmt
24+
- misspell
25+
- govet
26+
- ineffassign
27+
- staticcheck
28+
issues:
29+
exclude-use-default: true

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/alibaba/sentinel-golang
22

3-
go 1.13
3+
go 1.16
44

55
require (
66
github.com/fsnotify/fsnotify v1.4.7

go.sum

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,6 @@ go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
282282
go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg=
283283
go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
284284
go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
285-
go.opencensus.io v0.22.2 h1:75k/FF0Q2YM8QYo07VPddOLBslDt1MZOdEslOHvmzAs=
286285
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
287286
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
288287
go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=

0 commit comments

Comments
 (0)