-
Notifications
You must be signed in to change notification settings - Fork 31
286 lines (244 loc) · 8.87 KB
/
Copy pathci.yml
File metadata and controls
286 lines (244 loc) · 8.87 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
name: CI/CD Pipeline
on:
push:
branches: [ main ]
tags: [ 'v*' ]
paths-ignore:
- '.github/CODEOWNERS'
- '.github/SECURITY.md'
- '.slsa-goreleaser/**'
- '.gitignore'
- 'docs/**'
- '**.md'
pull_request:
branches: [ main ]
paths-ignore:
- '.github/CODEOWNERS'
- '.github/SECURITY.md'
- '.slsa-goreleaser/**'
- '.gitignore'
- 'docs/**'
- '**.md'
# NOTE: If your enterprise restricts GITHUB_TOKEN permissions,
# create a Personal Access Token (PAT) with 'repo' and 'write:packages' scopes
# and add it as a secret named 'GH_PAT'
env:
GO_VERSION: '1.26'
DAGGER_VERSION: '0.18.14'
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
lint:
name: Lint Code
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: ${{ env.GO_VERSION }}
- name: Download dependencies
run: go mod download
- name: Install mockgen
run: go install github.com/golang/mock/mockgen@v1.6.0
- name: Generate mocks
run: go generate ./...
- uses: dagger/dagger-for-github@8.0.0
with:
version: ${{ env.DAGGER_VERSION }}
verb: call
module: ./ci
args: lint --source .
test:
name: Run Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: ${{ env.GO_VERSION }}
- name: Install mockgen
run: go install github.com/golang/mock/mockgen@v1.6.0
- name: Add Go bin to PATH
run: echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Download dependencies
run: go mod download
- uses: dagger/dagger-for-github@8.0.0
with:
version: ${{ env.DAGGER_VERSION }}
verb: call
module: ./ci
args: test --source .
- name: Run JS client tests
run: node web/js/graphql-client-test.js
- name: Run tests with coverage
run: |
go test -race -coverprofile=coverage.txt -covermode=atomic ./...
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.txt
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
web-v2:
# v2 SPA (Vite + React + TypeScript) lives at web-v2/. Its built
# output is embedded into the Go binary via //go:embed all:dist,
# so the Go test/build jobs above don't catch a broken TypeScript
# source — the pre-checked-in dist/ keeps embedding cleanly. This
# job is the source-side safety net: typecheck, lint, unit tests,
# production build, and a schema-drift check between the GraphQL
# SDL the Go backend exposes and the copy web-v2 codegen consumes.
#
# No untrusted user input flows into run: blocks. The only ${{ }}
# expression is github.workspace, which is GitHub-controlled.
name: Web v2 (typecheck · lint · test · build · schema check)
runs-on: ubuntu-latest
timeout-minutes: 15
# Read-only token: this job only checks out and builds. Keeps the
# blast radius minimal if a dependency in the build is compromised.
permissions:
contents: read
steps:
# Actions pinned to full commit SHAs (not moving tags) so an action
# owner cannot silently repoint a tag at malicious code in our runner.
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
with:
persist-credentials: false
- name: GraphQL schema drift check
# Backend SDL is the source of truth; web-v2 keeps a synced
# copy so its codegen produces typed clients. Fail loudly if
# they ever diverge.
run: |
diff -q internal/reporter/graphql/schema.graphql \
web-v2/src/gql/schema.graphql \
|| { echo "::error::GraphQL schema drift between backend and web-v2 copy. Sync the two files."; exit 1; }
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
with:
version: 9
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: '20'
cache: 'pnpm'
cache-dependency-path: web-v2/pnpm-lock.yaml
- name: Install dependencies
working-directory: web-v2
run: pnpm install --frozen-lockfile
- name: Typecheck
working-directory: web-v2
run: pnpm typecheck
- name: Lint
working-directory: web-v2
run: pnpm lint
- name: Unit tests
working-directory: web-v2
run: pnpm test:run
- name: Build production bundle
working-directory: web-v2
run: pnpm build
security-scan:
name: Security Scan (Trivy)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: dagger/dagger-for-github@8.0.0
with:
version: ${{ env.DAGGER_VERSION }}
verb: call
module: ./ci
args: security-scan --source .
vulnerability-check:
name: Go Vulnerability Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: ${{ env.GO_VERSION }}
- name: Install govulncheck
run: go install golang.org/x/vuln/cmd/govulncheck@v1.3.0
- name: Run govulncheck
run: |
# Advisory-only: || true prevents blocking merges on vulnerabilities in indirect
# dependencies that have no available fix. Remove once all transitive CVEs are cleared.
govulncheck ./cmd/... ./internal/... ./pkg/... || true
dependency-review:
name: Dependency Review
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v5
- uses: actions/dependency-review-action@v4.7.1
with:
fail-on-severity: moderate
# Allow-list of advisories confined to the web-v2 dev/build/test
# toolchain (babel, esbuild, vite, ws, lodash, form-data, immutable,
# js-yaml — pulled via graphql-codegen / jsdom / vite). None reach the
# shipped production bundle (verified: no runtime dependency path), and
# several have no in-place patch on the pinned major (e.g. vite's
# server.fs.deny fix lands only in 6.x). fail-on-scopes can't filter
# these because GitHub's dependency graph carries no dev/runtime scope
# for the pnpm lockfile. Runtime deps stay fully enforced at moderate+.
# Revisit when the web-v2 toolchain is upgraded.
allow-ghsas: GHSA-4x5r-pxfx-6jf8,GHSA-67mh-4wv8-2f99,GHSA-hmw2-7cc7-3qxx,GHSA-wf6x-7x77-mvgw,GHSA-h67p-54hq-rp68,GHSA-r5fr-rjxr-66jc,GHSA-f23m-r3pf-42rh,GHSA-4w7w-66w2-5vf9,GHSA-v6wh-96g9-6wx3,GHSA-fx2h-pf6j-xcff,GHSA-96hv-2xvq-fx4p,GHSA-v56q-mh7h-f735,GHSA-xvcm-6775-5m9r
build:
name: Build Images
runs-on: ubuntu-latest
# For PRs, only run a single build test. For main/tags, build all platforms
strategy:
matrix:
platform: ${{ github.event_name == 'pull_request' && fromJson('["linux/amd64"]') || fromJson('["linux/amd64", "linux/arm64"]') }}
steps:
- uses: actions/checkout@v5
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- uses: dagger/dagger-for-github@8.0.0
with:
version: ${{ env.DAGGER_VERSION }}
verb: call
module: ./ci
args: build --source . --platforms ${{ matrix.platform }}
all-checks:
name: All Checks (Main Branch)
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v5
- uses: dagger/dagger-for-github@8.0.0
with:
version: ${{ env.DAGGER_VERSION }}
verb: call
module: ./ci
args: all --source .
upload-main-coverage:
name: Upload Coverage (main)
runs-on: ubuntu-latest
permissions:
contents: read
if: github.event.repository.fork == false && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- run: go test -race -coverprofile=coverage.txt -covermode=atomic ./...
# codecov/codecov-action v5.1.2 (pinned for security)
- uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.txt
flags: unittests
name: main-coverage
fail_ci_if_error: false