Repository navigation
237 lines (223 loc) · 8.28 KB
/
Copy pathci.yml
File metadata and controls
237 lines (223 loc) · 8.28 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
# Continuous integration: the console (lint, test, production build),
# build (the console embedded, and the noconsole stub), test, the
# network-namespace enforcement and collection suites, lint, known
# vulnerabilities reachable from the shipped code, the operator surface
# contract (spec lint), proto (lint, build, breaking-change gate),
# generated-code drift, applied migrations unchanged, and DCO sign-off.
# Tool versions here are mirrored in scripts/install-tools.sh so local
# regeneration matches CI.
# Every Go job installs exactly the toolchain go.mod's go directive names,
# a patched release; the Dockerfile's build stage pins the same one.
# release.yml calls this workflow on a v* tag as the gate before anything is
# published; there the checks that compare a change against its base (the
# proto breaking-change gate, applied migrations, DCO) have no base and are
# skipped.
name: ci
on:
push:
branches: [main]
pull_request:
workflow_call:
permissions:
contents: read
env:
NODE_VERSION: "22"
BUF_VERSION: "1.72.0"
SQLC_VERSION: "1.31.1"
GOLANGCI_LINT_VERSION: "v2.9.0"
jobs:
console:
runs-on: ubuntu-latest
# The console is built on a pinned Node ahead of the Go build, which
# embeds its output; the build artifact is handed over rather than
# rebuilt so the binary CI proves is the one the console job checked.
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
cache-dependency-path: ui/package-lock.json
- run: npm --prefix ui ci --no-audit --no-fund
- run: npm --prefix ui run lint
- run: npm --prefix ui run test
- run: npm --prefix ui run build
# The built console carries its third-party licenses: the notices
# file at its root and each font family's license beside the fonts.
- run: test -s ui/dist/THIRD-PARTY-NOTICES.txt && ls ui/dist/assets/*-LICENSE.txt
- uses: actions/upload-artifact@v4
with:
name: console-dist
path: ui/dist
if-no-files-found: error
retention-days: 1
build:
needs: console
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: console-dist
path: ui/dist
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- run: make build
# The stub build never needs Node; proving it compiles keeps Go-only
# iteration honest.
- run: make build-noconsole
- run: go build -tags dev ./cmd/innerwall
test:
runs-on: ubuntu-latest
# Integration tests (enrollment end to end, the store) run against a
# disposable Postgres and skip when INNERWALL_TEST_DATABASE_URL is unset.
services:
postgres:
image: postgres:17-alpine
env:
POSTGRES_DB: innerwall_test
POSTGRES_USER: innerwall
POSTGRES_PASSWORD: innerwall
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U innerwall -d innerwall_test"
--health-interval 5s
--health-timeout 3s
--health-retries 10
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- run: make test
env:
INNERWALL_TEST_DATABASE_URL: postgres://innerwall:innerwall@127.0.0.1:5432/innerwall_test?sslmode=disable
enforcement:
name: enforcement (network namespace)
runs-on: ubuntu-latest
# The enforcement suite programs real nftables inside a fresh network
# namespace and sends real traffic into it, and the collection suite
# drives the conntrack source against real connection tracking in
# namespaces of its own, so both run as root with the nftables
# userspace installed. Build-tagged so the ordinary test job never
# needs privileges.
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- run: sudo apt-get update -q && sudo apt-get install -y -q nftables
- run: make test-netns
lint:
runs-on: ubuntu-latest
# The analysis cache is keyed on the Go toolchain and the linter, so a
# toolchain change never reuses verdicts computed under the previous
# one. The action's own cache cannot be keyed that way: it restores
# from a key prefix holding only the OS and the week, so it served
# verdicts from before the move to Go 1.26.10. It is off.
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
id: go
with:
go-version-file: go.mod
- uses: actions/cache@v4
with:
path: ~/.cache/golangci-lint
key: golangci-lint-${{ runner.os }}-go${{ steps.go.outputs.go-version }}-${{ env.GOLANGCI_LINT_VERSION }}-${{ hashFiles('go.mod', 'go.sum') }}
restore-keys: golangci-lint-${{ runner.os }}-go${{ steps.go.outputs.go-version }}-${{ env.GOLANGCI_LINT_VERSION }}-
- uses: golangci/golangci-lint-action@v8
with:
version: ${{ env.GOLANGCI_LINT_VERSION }}
skip-cache: true
vulncheck:
name: known vulnerabilities
runs-on: ubuntu-latest
# Fails on a known vulnerability the shipped code can reach, in the
# standard library or a dependency, built as released: without the dev
# build tag. A finding in a module the code requires but never calls
# is reported and does not fail the job.
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- run: make vulncheck
openapi:
name: operator surface contract
runs-on: ubuntu-latest
# Spec lint only: the document parses as OpenAPI 3.1 and passes the
# linter's rules. A Go test in internal/api checks it against the
# mounted routes; nothing conforms responses to it at runtime.
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- run: make openapi
drift:
name: generated-code drift
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- uses: bufbuild/buf-action@v1
with:
version: ${{ env.BUF_VERSION }}
setup_only: true
- uses: sqlc-dev/setup-sqlc@v4
with:
sqlc-version: ${{ env.SQLC_VERSION }}
# The console's types are generated from api/openapi.yaml by the
# generator pinned in ui/package-lock.json.
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
cache-dependency-path: ui/package-lock.json
- run: npm --prefix ui ci --no-audit --no-fund
- run: scripts/check-drift.sh
proto:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: bufbuild/buf-action@v1
with:
version: ${{ env.BUF_VERSION }}
setup_only: true
- run: buf lint
- run: buf build
# Breaking changes are compared against main. A breaking change passes
# only when the PR title or body references an ADR (ADR-0007).
- if: ${{ !startsWith(github.ref, 'refs/tags/') }}
run: scripts/check-proto-breaking.sh origin/main
env:
PR_TEXT: |
${{ github.event.pull_request.title }}
${{ github.event.pull_request.body }}
migrations:
name: applied migrations unchanged
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
runs-on: ubuntu-latest
# A migration on main is applied: once there it never changes, and a
# fix is a new migration. A pull request is checked against its base;
# a push to main against the commit it moved main from.
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- run: scripts/check-migrations.sh "${{ github.event_name == 'pull_request' && format('origin/{0}', github.base_ref) || github.event.before }}"
dco:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- run: scripts/check-dco.sh "origin/${{ github.base_ref }}..HEAD"