-
Notifications
You must be signed in to change notification settings - Fork 5
254 lines (207 loc) · 8.41 KB
/
Copy pathtest.yml
File metadata and controls
254 lines (207 loc) · 8.41 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
name: CI
on:
push:
branches: [main]
pull_request:
permissions:
contents: read
jobs:
lint-typecheck:
name: Lint & Typecheck
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- uses: jdx/mise-action@dba19683ed58901619b14f395a24841710cb4925 # v4.1.0
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Install web dependencies
# web/ is a separate Bun project with its own lockfile. `tsc -b` follows
# the project reference into web/tsconfig.json, so its node_modules
# (e.g. @testing-library/dom) must be present for the typecheck to resolve.
run: cd web && bun install --frozen-lockfile
- name: Lint (oxlint)
run: oxlint .
- name: Typecheck
run: tsc -b
test-unit:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- uses: jdx/mise-action@dba19683ed58901619b14f395a24841710cb4925 # v4.1.0
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Run backend unit tests
run: just test-backend
- name: Run web unit tests
run: just test-web
- name: Run TLS integration tests (Node runner)
run: just test-integration
test-build:
name: Build Verification
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- uses: jdx/mise-action@dba19683ed58901619b14f395a24841710cb4925 # v4.1.0
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Build Electron app
run: just build
test-e2e:
name: E2E Tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- uses: jdx/mise-action@dba19683ed58901619b14f395a24841710cb4925 # v4.1.0
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Ensure Electron binary is installed
run: |
# electron's install.js downloads the platform zip into @electron/get's
# cache reliably, but in CI its async extraction doesn't finish before the
# process exits, leaving node_modules/electron/dist half-written (no electron
# binary or chrome-sandbox). Run install.js to populate the download cache,
# then extract the cached zip ourselves with unzip (synchronous, complete).
rm -rf node_modules/electron/dist node_modules/electron/path.txt
node node_modules/electron/install.js || true
zip="$(ls -1 "$HOME"/.cache/electron/*/electron-*-linux-x64.zip | head -n1)"
rm -rf node_modules/electron/dist
mkdir -p node_modules/electron/dist
unzip -q "$zip" -d node_modules/electron/dist
printf 'electron' > node_modules/electron/path.txt
# Guard: fail here (not in the chown step) if extraction ever regresses.
test -f node_modules/electron/dist/chrome-sandbox
- name: Fix Electron chrome-sandbox permissions
run: |
sudo chown root:root node_modules/electron/dist/chrome-sandbox
sudo chmod 4755 node_modules/electron/dist/chrome-sandbox
- name: Get Playwright version
id: pw-version
run: echo "version=$(bunx playwright --version | awk '{print $2}')" >> "$GITHUB_OUTPUT"
- name: Cache Playwright browsers
id: pw-cache
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ steps.pw-version.outputs.version }}
- name: Install Playwright browsers
if: steps.pw-cache.outputs.cache-hit != 'true'
run: bunx playwright install --with-deps chromium
- name: Install Playwright system deps
if: steps.pw-cache.outputs.cache-hit == 'true'
run: bunx playwright install-deps chromium
- name: Build Electron app
run: just build
- name: Install Xvfb
run: sudo apt-get install -y xvfb
- name: Run E2E tests
run: xvfb-run --auto-servernum just test-e2e-run
- name: Upload Playwright report
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: ${{ !cancelled() }}
with:
name: playwright-results
path: |
web/test-results/
electron/e2e/test-results/
retention-days: 30
if-no-files-found: ignore
test-runbooks:
name: Runbook Tests
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- uses: jdx/mise-action@dba19683ed58901619b14f395a24841710cb4925 # v4.1.0
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Compile test CLI
run: just compile-test-cli
- name: Configure AWS credentials via OIDC
uses: aws-actions/configure-aws-credentials@e7f100cf4c008499ea8adda475de1042d6975c7b # v6.2.0
with:
role-to-assume: ${{ secrets.RUNBOOKS_TEST_AWS_ROLE_ARN }}
aws-region: us-west-2
- name: Export test credentials
env:
ORIG_KEY_ID: ${{ env.AWS_ACCESS_KEY_ID }}
ORIG_SECRET: ${{ env.AWS_SECRET_ACCESS_KEY }}
ORIG_TOKEN: ${{ env.AWS_SESSION_TOKEN }}
ORIG_REGION: ${{ env.AWS_REGION }}
run: |
echo "RUNBOOKS_TEST_AWS_ACCESS_KEY_ID=${ORIG_KEY_ID}" >> "$GITHUB_ENV"
echo "RUNBOOKS_TEST_AWS_SECRET_ACCESS_KEY=${ORIG_SECRET}" >> "$GITHUB_ENV"
echo "RUNBOOKS_TEST_AWS_SESSION_TOKEN=${ORIG_TOKEN}" >> "$GITHUB_ENV"
echo "RUNBOOKS_TEST_AWS_REGION=${ORIG_REGION}" >> "$GITHUB_ENV"
- name: Run runbook tests
env:
RUNBOOKS_GITHUB_TOKEN: ${{ secrets.RUNBOOKS_GITHUB_TOKEN }}
run: resources/bin/runbooks-test test testdata/...
test-runbooks-app-token:
name: Runbook Tests (GitHub App Token)
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- uses: jdx/mise-action@dba19683ed58901619b14f395a24841710cb4925 # v4.1.0
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Compile test CLI
run: just compile-test-cli
- name: Run GitHub auth flows with installation token
env:
# No RUNBOOKS_GITHUB_TOKEN: force the executor's fallback chain
# (RUNBOOKS_GITHUB_TOKEN -> GITHUB_TOKEN -> GH_TOKEN) to land on the
# ghs_ installation token, exercising validateInstallationToken.
GITHUB_TOKEN: ${{ github.token }}
run: resources/bin/runbooks-test test testdata/feature-demos/github-auth/...
test-docs:
name: Documentation Tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- uses: jdx/mise-action@dba19683ed58901619b14f395a24841710cb4925 # v4.1.0
- name: Run docs tests
run: just test-docs
ci-summary:
name: CI Summary
needs:
[
lint-typecheck,
test-unit,
test-build,
test-e2e,
test-runbooks,
test-runbooks-app-token,
test-docs,
]
runs-on: ubuntu-latest
if: always()
steps:
- name: Check results
env:
LINT_RESULT: ${{ needs.lint-typecheck.result }}
UNIT_RESULT: ${{ needs.test-unit.result }}
BUILD_RESULT: ${{ needs.test-build.result }}
E2E_RESULT: ${{ needs.test-e2e.result }}
RUNBOOKS_RESULT: ${{ needs.test-runbooks.result }}
RUNBOOKS_APP_RESULT: ${{ needs.test-runbooks-app-token.result }}
DOCS_RESULT: ${{ needs.test-docs.result }}
run: |
for result in "$LINT_RESULT" "$UNIT_RESULT" "$BUILD_RESULT" "$E2E_RESULT" "$RUNBOOKS_RESULT" "$RUNBOOKS_APP_RESULT" "$DOCS_RESULT"; do
if [ "$result" != "success" ] && [ "$result" != "skipped" ]; then
echo "CI failed!"
exit 1
fi
done
echo "All checks passed!"