-
Notifications
You must be signed in to change notification settings - Fork 47
299 lines (274 loc) · 9.96 KB
/
static.yml
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
name: static checks
on:
workflow_dispatch:
push:
branches:
- "main"
pull_request:
branches:
- "*"
jobs:
gofmt:
name: "Ensure that code is gofmt-ed"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Setup Golang
uses: actions/setup-go@v5.1.0
with:
go-version-file: './backend/go.mod'
- name: "Run make fmt and then 'git diff' to see if anything changed: to fix this check, run make fmt and then commit the changes."
run: |
make fmt
git diff --exit-code -- .
duplimport:
name: Ensure there are no duplicate package imports
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Setup Golang
uses: actions/setup-go@v5.1.0
with:
go-version-file: './backend/go.mod'
- name: "Install dupimport"
run: |
go install github.com/gostaticanalysis/dupimport/cmd/dupimport@37d4ab484168ec60101dcc9bf644b54f910c2a25
- name: "Ensure 'backend' has no duplicate imports"
run: |
cd $GITHUB_WORKSPACE/backend
go vet -vettool=`which dupimport` ./...
- name: "Ensure 'cluster-agent' has no duplicate imports"
run: |
cd $GITHUB_WORKSPACE/cluster-agent
go vet -vettool=`which dupimport` ./...
- name: "Ensure 'backend-shared' has no duplicate imports"
run: |
cd $GITHUB_WORKSPACE/backend-shared
go vet -vettool=`which dupimport` ./...
- name: "Ensure 'appstudio-controller' has no duplicate imports"
run: |
cd $GITHUB_WORKSPACE/appstudio-controller
go vet -vettool=`which dupimport` ./...
gosec:
name: Ensure that code passes gosec and golint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Setup Golang
uses: actions/setup-go@v5.1.0
with:
go-version-file: './backend/go.mod'
- name: "Install gosec"
run: |
go install github.com/securego/gosec/v2/cmd/gosec@latest
- name: "Ensure 'backend' passes 'go-sec' - run 'make gosec' to identify issues"
run: |
cd $GITHUB_WORKSPACE/backend
make gosec
- name: "Ensure 'cluster-agent' passes 'go-sec' - run 'make gosec' to identify issues"
run: |
cd $GITHUB_WORKSPACE/cluster-agent
make gosec
- name: "Ensure 'backend-shared' passes 'go-sec' - run 'make gosec' to identify issues"
run: |
cd $GITHUB_WORKSPACE/backend-shared
make gosec
- name: "Ensure 'appstudio-controller' passes 'go-sec' - run 'make gosec' to identify issues"
run: |
cd $GITHUB_WORKSPACE/appstudio-controller
make gosec
- name: "Ensure 'backend' passes 'go-lint' - run 'make lint' to identify issues"
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.60.3
cd $GITHUB_WORKSPACE/backend
make lint
- name: "Ensure 'cluster-agent' passes 'go-lint' - run 'make lint' to identify issues"
run: |
cd $GITHUB_WORKSPACE/cluster-agent
make lint
- name: "Ensure 'backend-shared' passes 'go-lint' - run 'make lint' to identify issues"
run: |
cd $GITHUB_WORKSPACE/backend-shared
make lint
- name: "Ensure 'tests-e2e' passes 'go-lint' - run 'make lint' to identify issues"
run: |
cd $GITHUB_WORKSPACE/tests-e2e
make lint
- name: "Ensure 'appstudio-controller' passes 'go-lint' - run 'make lint' to identify issues"
run: |
cd $GITHUB_WORKSPACE/appstudio-controller
make lint
- name: "Ensure 'db-migration' passes 'go-lint' - run 'make lint' to identify issues"
run: |
cd $GITHUB_WORKSPACE/utilities/db-migration
make lint
check-go:
name: Ensure Go modules synchronicity
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Golang
uses: actions/setup-go@v5.1.0
with:
go-version-file: './backend/go.mod'
- name: "Backend: Download all Go modules"
run: |
cd $GITHUB_WORKSPACE/backend
go mod download
- name: "Backend: Check for tidyness of go.mod and go.sum: run `go mod tidy` to fix"
run: |
cd $GITHUB_WORKSPACE/backend
go mod tidy
git diff --exit-code -- .
- name: "Backend-shared: Download all Go modules"
run: |
cd $GITHUB_WORKSPACE/backend-shared
go mod download
- name: "Backend-shared: Check for tidyness of go.mod and go.sum: run `go mod tidy` to fix"
run: |
cd $GITHUB_WORKSPACE/backend-shared
go mod tidy
git diff --exit-code -- .
- name: "Cluster-agent: Download all Go modules"
run: |
cd $GITHUB_WORKSPACE/cluster-agent
go mod download
- name: "Cluster-agent: Check for tidyness of go.mod and go.sum: run `go mod tidy` to fix"
run: |
cd $GITHUB_WORKSPACE/cluster-agent
go mod tidy
git diff --exit-code -- .
- name: "Appstudio-controller: Download all Go modules"
run: |
cd $GITHUB_WORKSPACE/appstudio-controller
go mod download
- name: "Appstudio-controller: Check for tidyness of go.mod and go.sum: run `go mod tidy` to fix"
run: |
cd $GITHUB_WORKSPACE/appstudio-controller
go mod tidy
git diff --exit-code -- .
db-migration-tests:
name: Run db-migration tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Golang
uses: actions/setup-go@v5.1.0
with:
go-version-file: './backend/go.mod'
- name: "Start PostgreSQL"
run: |
cd $GITHUB_WORKSPACE
./create-dev-env.sh
- name: "Migrate database to version x"
run: |
cd $GITHUB_WORKSPACE/utilities/db-migration
go run main.go migrate_to 20
- name: "Run migration tests to add data in database"
run: |
cd $GITHUB_WORKSPACE/utilities/db-migration/migration_test/add_test_values
DEV_ONLY_ALLOW_NON_TLS_CONNECTION_TO_POSTGRESQL=true go test $GITHUB_WORKSPACE/utilities/db-migration/migration_test/add_test_values -run "TestInitializeValues"
- name: "Migrate to latest version of database"
run: |
cd $GITHUB_WORKSPACE
make db-migrate
- name: "Run migration tests to verify that data added is still present/valid in database"
run: |
cd $GITHUB_WORKSPACE/utilities/db-migration/migration_test/verify_test_values
DEV_ONLY_ALLOW_NON_TLS_CONNECTION_TO_POSTGRESQL=true go test $GITHUB_WORKSPACE/utilities/db-migration/migration_test/verify_test_values -run "TestVerifyDBValues"
validate-db-migration:
name: Check if migration schema matches with super schema.
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Golang
uses: actions/setup-go@v5.1.0
with:
go-version-file: './backend/go.mod'
- name: "Install go modules for migration"
run: |
cd $GITHUB_WORKSPACE/utilities
./check-db-schema.sh
verify-db-migration:
name: Check if migrations work as expected when applied to most recent two migrations.
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Golang
uses: actions/setup-go@v5.1.0
with:
go-version-file: './backend/go.mod'
- name: "Install go modules for migration"
run: |
cd $GITHUB_WORKSPACE/utilities
./verify-db-migration.sh
test-go:
name: Run unit tests for Go packages
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Golang
uses: actions/setup-go@v5.1.0
with:
go-version-file: './backend/go.mod'
- name: "Start PostgreSQL"
run: |
cd $GITHUB_WORKSPACE
./create-dev-env.sh
- name: "Run backend tests"
run: |
cd $GITHUB_WORKSPACE/backend
make test
- name: "Run backend-shared tests"
run: |
cd $GITHUB_WORKSPACE/backend-shared
make test
- name: "Run cluster-agent tests"
run: |
cd $GITHUB_WORKSPACE/cluster-agent
make test
- name: "Run appstudio-controller tests"
run: |
cd $GITHUB_WORKSPACE/appstudio-controller
make test
- name: "Send coverage results to codecov.io"
uses: codecov/codecov-action@v4.6.0
manifests:
name: "Ensure that manifests are up-to-date"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Setup Golang
uses: actions/setup-go@v5.1.0
with:
go-version-file: './backend/go.mod'
- name: "Run 'make generate-manifests' and report any diff (to fix this if failing: run 'make clean' then 'make generate-manifests' at root, and check in changes)"
run: |
cd $GITHUB_WORKSPACE
make generate-manifests
git diff --exit-code -- .
mocks:
name: Check mocks generated are up-to-date.
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Golang
uses: actions/setup-go@v5.1.0
with:
go-version-file: './backend/go.mod'
- name: "Install mockgen and mockery for generating mocks"
run: |
cd $GITHUB_WORKSPACE
go install github.com/golang/mock/mockgen@latest
go install github.com/vektra/mockery/v2@v2.45.0
- name: "Generate mocks"
run: |
cd $GITHUB_WORKSPACE
make mocks
git diff --exit-code -- .