-
Notifications
You must be signed in to change notification settings - Fork 7
134 lines (112 loc) · 4.23 KB
/
Copy pathci.yaml
File metadata and controls
134 lines (112 loc) · 4.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
name: CI
on:
push:
paths:
- '.github/workflows/*.yaml'
- '**.go'
- '**.proto'
- '**/go.mod'
pull_request:
paths:
- '.github/workflows/*.yaml'
- '**.go'
- '**.proto'
- '**/go.mod'
permissions:
contents: read
pull-requests: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
jobs:
unit-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: 'go.mod'
- name: Setup buf dependencies
run: |
go install github.com/bufbuild/buf/cmd/buf@v1.65.0
go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2@v2.28.0
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc
go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway@v2.28.0
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.36.11
- name: Cache go modules
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-
- name: Make buf
run: |
make buf
- name: Check if Go code has changed
run: |
if git diff --exit-code -- '*.go' '*.proto' '*.yaml' '*.json' ':!*.sum'; then
echo "Generated Go code has not changed."
else
echo "Generated Go code has changed. Please make sure to commit the changes."
exit 1
fi
- name: Run go tests
run: |
go test ./... -run=^Test_U_ -coverprofile=root.cov
go test ./deploy/... -run=^Test_U_ -coverprofile=deploy.cov
go test ./sdk/... -run=^Test_U_ -coverprofile=sdk.cov
go install go.shabbyrobe.org/gocovmerge/cmd/gocovmerge@fa4f82cfbf4d57c646c1ed0f35002bf1b89fbf7a
gocovmerge root.cov deploy.cov sdk.cov > unit.cov
- name: Upload unit tests coverage
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: unit.cov
path: unit.cov
e2e-tests:
uses: ./.github/workflows/e2e.yaml
coverages:
name: Merge Coverage and Upload to Coveralls
runs-on: ubuntu-latest
needs: [unit-tests, e2e-tests]
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: "go.work"
- name: Download unit coverage
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v4.3.2
with:
name: unit.cov
- name: Download e2e coverage
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v4.3.2
with:
name: e2e.cov
- name: Merge coverage files
run: |
go install go.shabbyrobe.org/gocovmerge/cmd/gocovmerge@fa4f82cfbf4d57c646c1ed0f35002bf1b89fbf7a
gocovmerge unit.cov e2e.cov > overall.cov
- name: Upload coverage to Coveralls
uses: shogo82148/actions-goveralls@9606dbc5ac5cf888a0e9ef901515c3cd516a2790 # v1.11.0
with:
path-to-profile: overall.cov
ignore: api/v1/*/*.pb.go,api/v1/*/*.pb.gw.go
go-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: 'go.mod'
- name: go-lint
uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0
buf-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: bufbuild/buf-action@8c6a16e16f12ba20b6470afa9c2ba9b5ba8c97c3 # v1.5.0
with:
push: false
lint: true