@@ -2,78 +2,89 @@ name: CI
2
2
3
3
on :
4
4
push :
5
- branches : master
5
+ branches : [ "main", " master" ]
6
6
pull_request :
7
- branches : " *"
7
+ branches : [ "*" ]
8
8
9
9
jobs :
10
10
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
+
11
31
build :
12
- name : ${{ matrix.os }} - Go ${{ matrix.go_version }}
32
+ name : Build and test - Go ${{ matrix.go_version }}
13
33
runs-on : ubuntu-latest
14
34
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.
16
36
matrix :
17
37
go_version :
18
- - 1.13
19
- - 1.14
38
+ - 1.16
39
+ - 1.18
40
+ - 1.19
20
41
os :
21
42
- ubuntu-latest
22
43
23
44
steps :
24
45
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
43
51
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
46
54
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-
49
64
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
52
88
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)
0 commit comments