-
Notifications
You must be signed in to change notification settings - Fork 0
313 lines (274 loc) · 9.29 KB
/
test.yml
File metadata and controls
313 lines (274 loc) · 9.29 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
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
300
301
302
303
304
305
306
307
308
309
310
311
312
313
name: Run Tests
on:
pull_request:
branches:
- "**"
paths-ignore:
- "**.md"
- "docs/**"
- "webflow-designer-extension/**"
- "webflow-designer-extension-cli/**"
- "LICENSE"
- ".gitignore"
- "CHANGELOG.md"
- "SECURITY.md"
- "Roadmap.md"
- "QandA.md"
push:
branches:
- main
paths-ignore:
- "**.md"
- "docs/**"
- "webflow-designer-extension/**"
- "webflow-designer-extension-cli/**"
- "LICENSE"
- ".gitignore"
- "CHANGELOG.md"
- "SECURITY.md"
- "Roadmap.md"
- "QandA.md"
jobs:
lint:
name: Lint
runs-on: blacksmith-4vcpu-ubuntu-2404
env:
GOFLAGS: "-mod=mod"
GOPROXY: "https://proxy.golang.org,direct"
steps:
- uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: "1.26.3"
cache: true
- name: Determine Go cache paths
id: go-env
run: |
echo "gomodcache=$(go env GOMODCACHE)" >> $GITHUB_OUTPUT
echo "gocache=$(go env GOCACHE)" >> $GITHUB_OUTPUT
- name: Cache Go modules
uses: actions/cache@v5
with:
path: |
${{ steps.go-env.outputs.gomodcache }}
${{ steps.go-env.outputs.gocache }}
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Download dependencies
run: go mod download
- name: Prime module graph (test + prod)
run: go list -deps -test ./...
- name: golangci-lint
uses: golangci/golangci-lint-action@v8
with:
version: v2.9.0
args: --config .golangci.yml --modules-download-mode=mod
format:
name: Format Check
runs-on: blacksmith-4vcpu-ubuntu-2404
steps:
- uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: "1.26.3"
cache: true
- name: Check Go formatting
run: |
echo "=== Checking Go formatting ==="
UNFORMATTED=$(gofmt -l .)
if [ -n "$UNFORMATTED" ]; then
echo "❌ The following files are not formatted with gofmt:"
echo "$UNFORMATTED"
echo ""
echo "Run 'gofmt -w .' to fix formatting"
exit 1
fi
echo "✅ All Go files are properly formatted"
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: "20"
- name: Install Node dependencies
run: npm ci --ignore-scripts
- name: Check Prettier formatting
run: |
echo "=== Checking Prettier formatting ==="
npm run format:check || {
echo ""
echo "❌ Some files are not formatted with Prettier"
echo "Run 'npm run format:write' to fix formatting"
exit 1
}
echo "✅ All files are properly formatted with Prettier"
unit-tests:
name: Unit Tests
runs-on: blacksmith-4vcpu-ubuntu-2404
needs: [lint, format]
steps:
- uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: "1.26.3"
cache: true
- name: Run unit tests
run: |
echo "=== Running Unit Tests ==="
go test -race -short -shuffle=on -covermode=atomic -coverprofile=coverage-unit.out -coverpkg=./... ./... || \
go test -v -race -short -shuffle=on -covermode=atomic -coverprofile=coverage-unit.out -coverpkg=./... ./...
- name: Upload unit test coverage
uses: actions/upload-artifact@v6
with:
name: coverage-unit
path: coverage-unit.out
- name: Load secrets from 1Password
uses: 1password/load-secrets-action@v2
with:
export-env: true
env:
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
CODECOV_TOKEN: op://Good Native/hover-codecov/CODECOV_TOKEN
- name: Upload unit test coverage to Codecov
if: env.CODECOV_TOKEN != ''
uses: codecov/codecov-action@v5
with:
token: ${{ env.CODECOV_TOKEN }}
files: ./coverage-unit.out
flags: unit
name: unit-tests
fail_ci_if_error: false
integration-tests:
name: Integration Tests
runs-on: blacksmith-4vcpu-ubuntu-2404
needs: [lint, format]
steps:
- uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: "1.26.3"
cache: true
- name: Skip database setup for dynamic preview branches
run: |
echo "Skipping database setup - using Supabase preview branches per PR"
echo "Integration tests will run on deployed review apps with their own database"
- name: Run integration tests
run: |
echo "=== Running Integration Tests ==="
go test -race -covermode=atomic -coverprofile=coverage-integration.out -coverpkg=./... -tags=integration ./... -json > test-output.json || \
go test -v -race -covermode=atomic -coverprofile=coverage-integration.out -coverpkg=./... -tags=integration ./... -json > test-output.json
# Show test results summary
echo "=== Test Results ==="
if grep -q '"Action":"fail"' test-output.json; then
echo "❌ Found test failures:"
grep -E '"Action":"fail"' test-output.json | head -10 || true
else
echo "✅ All integration tests passed!"
fi
- name: Generate JUnit report
if: always()
run: |
go install github.com/jstemmer/go-junit-report/v2@latest
$(go env GOPATH)/bin/go-junit-report -parser gojson < test-output.json > junit.xml
- name: Upload integration test coverage
if: always()
uses: actions/upload-artifact@v6
with:
name: coverage-integration
path: coverage-integration.out
- name: Upload test results
if: always()
uses: actions/upload-artifact@v6
with:
name: test-results
path: junit.xml
- name: Load secrets from 1Password
if: always()
uses: 1password/load-secrets-action@v2
with:
export-env: true
env:
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
CODECOV_TOKEN: op://Good Native/hover-codecov/CODECOV_TOKEN
- name: Upload integration test coverage to Codecov
if: always() && env.CODECOV_TOKEN != ''
uses: codecov/codecov-action@v5
with:
token: ${{ env.CODECOV_TOKEN }}
files: ./coverage-integration.out
flags: integration
name: integration-tests
fail_ci_if_error: false
- name: Upload test results to Codecov
if: always() && env.CODECOV_TOKEN != ''
uses: codecov/test-results-action@v1
with:
token: ${{ env.CODECOV_TOKEN }}
files: ./junit.xml
coverage-report:
name: Coverage Report (Informational Only)
runs-on: blacksmith-4vcpu-ubuntu-2404
needs: [unit-tests, integration-tests]
if:
always() && (needs.unit-tests.result == 'success' ||
needs.integration-tests.result == 'success')
steps:
- uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: "1.26.3"
cache: true
- name: Download coverage files
uses: actions/download-artifact@v5
with:
pattern: coverage-*
merge-multiple: true
- name: Merge coverage reports
run: |
echo "=== Merging Coverage Reports ==="
# Simple approach - use unit tests coverage primarily
if [ -f coverage-unit.out ]; then
echo "Using unit coverage as primary"
cp coverage-unit.out coverage.out
elif [ -f coverage-integration.out ]; then
echo "Using integration coverage as fallback"
cp coverage-integration.out coverage.out
else
echo "No coverage files found"
exit 1
fi
# Show total coverage
if [ -f coverage.out ]; then
echo "=== Total Coverage ==="
go tool cover -func=coverage.out | tail -1
fi
- name: Load secrets from 1Password
uses: 1password/load-secrets-action@v2
with:
export-env: true
env:
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
CODECOV_TOKEN: op://Good Native/hover-codecov/CODECOV_TOKEN
CODECOV_STATIC_TOKEN:
op://Good Native/hover-codecov/CODECOV_STATIC_TOKEN
- name: Upload combined coverage to Codecov
if: env.CODECOV_TOKEN != ''
uses: codecov/codecov-action@v5
with:
token: ${{ env.CODECOV_TOKEN }}
files: ./coverage.out
flags: all
name: all-tests
fail_ci_if_error: false
- name: Upload static analysis to Codecov
if: env.CODECOV_STATIC_TOKEN != ''
uses: codecov/codecov-action@v5
with:
token: ${{ env.CODECOV_STATIC_TOKEN }}
flags: static-analysis
name: static-analysis
fail_ci_if_error: false