-
Notifications
You must be signed in to change notification settings - Fork 113
312 lines (262 loc) · 9.75 KB
/
ci.yml
File metadata and controls
312 lines (262 loc) · 9.75 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
name: CI
on:
pull_request:
branches: ["**"]
merge_group:
workflow_dispatch:
inputs:
test_filter:
description: 'Optional test filter (e.g., "workspace", "tests/file.test.ts", or "-t pattern")'
required: false
type: string
# This filter is passed to unit tests, integration tests, e2e tests, and storybook tests
# to enable faster iteration when debugging specific test failures in CI
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
static-check:
name: Static Checks (lint + typecheck + fmt)
runs-on: ${{ github.repository_owner == 'coder' && 'depot-ubuntu-22.04-16' || 'ubuntu-latest' }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Required for git describe to find tags
- uses: ./.github/actions/setup-mux
- name: Generate version file
run: ./scripts/generate-version.sh
- name: Cache shfmt
id: cache-shfmt
uses: actions/cache@v4
with:
path: ~/.local/bin/shfmt
# We install latest via webinstall; reflect that in the cache key to avoid pinning mismatches
key: ${{ runner.os }}-shfmt-latest
restore-keys: |
${{ runner.os }}-shfmt-
- name: Install and setup shfmt
run: |
# Install shfmt if not cached or if cached binary is broken
if [[ ! -f "$HOME/.local/bin/shfmt" ]] || ! "$HOME/.local/bin/shfmt" --version >/dev/null 2>&1; then
curl -sS https://webinstall.dev/shfmt | bash
fi
echo "$HOME/.local/bin" >> $GITHUB_PATH
# Verify shfmt is available
"$HOME/.local/bin/shfmt" --version
- name: Install Nix
uses: cachix/install-nix-action@v27
with:
extra_nix_config: |
experimental-features = nix-command flakes
- name: Install uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Add uv to PATH
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Run static checks
run: make -j3 static-check
test:
name: Unit Tests
runs-on: ${{ github.repository_owner == 'coder' && 'depot-ubuntu-22.04-16' || 'ubuntu-latest' }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Required for git describe to find tags
- uses: ./.github/actions/setup-mux
- name: Build worker files
run: make build-main
- name: Run tests with coverage
run: bun test --coverage --coverage-reporter=lcov ${{ github.event.inputs.test_filter || 'src' }}
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage/lcov.info
flags: unit-tests
fail_ci_if_error: false
integration-test:
name: Integration Tests
timeout-minutes: 10
runs-on: ${{ github.repository_owner == 'coder' && 'depot-ubuntu-22.04-16' || 'ubuntu-latest' }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Required for git describe to find tags
- uses: ./.github/actions/setup-mux
- name: Build worker files
run: make build-main
- name: Run all integration tests with coverage
# --silent suppresses per-test output (17+ test files × workers = overwhelming logs)
run: TEST_INTEGRATION=1 bun x jest --coverage --maxWorkers=100% --silent ${{ github.event.inputs.test_filter || 'tests' }}
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage/lcov.info
flags: integration-tests
fail_ci_if_error: false
storybook-test:
name: Storybook Interaction Tests
runs-on: ${{ github.repository_owner == 'coder' && 'depot-ubuntu-22.04-16' || 'ubuntu-latest' }}
if: github.event.inputs.test_filter == ''
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Required for git describe to find tags
- uses: ./.github/actions/setup-mux
- uses: ./.github/actions/setup-playwright
- name: Build Storybook
run: make storybook-build
- name: Serve Storybook
run: |
bun x http-server storybook-static -p 6006 &
sleep 5
- name: Run Storybook tests
run: make test-storybook
e2e-test:
name: E2E Tests (${{ matrix.os }})
if: github.event.inputs.test_filter == ''
strategy:
fail-fast: false
matrix:
include:
# Linux: comprehensive E2E tests
- os: linux
runner: ${{ github.repository_owner == 'coder' && 'depot-ubuntu-22.04-16' || 'ubuntu-latest' }}
test_scope: "all"
# macOS: window lifecycle and platform-dependent tests only
- os: macos
runner: ${{ github.repository_owner == 'coder' && 'depot-macos-latest' || 'macos-latest' }}
test_scope: "window-lifecycle"
runs-on: ${{ matrix.runner }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Required for git describe to find tags
- uses: ./.github/actions/setup-mux
- name: Install xvfb (Linux)
if: matrix.os == 'linux'
run: |
sudo apt-get update
sudo apt-get install -y xvfb
- uses: ./.github/actions/setup-playwright
- name: Run comprehensive e2e tests (Linux)
if: matrix.os == 'linux'
run: xvfb-run -a make test-e2e
env:
ELECTRON_DISABLE_SANDBOX: 1
- name: Run window lifecycle e2e tests (macOS)
if: matrix.os == 'macos'
run: make test-e2e PLAYWRIGHT_ARGS="tests/e2e/scenarios/windowLifecycle.spec.ts"
docker-smoke-test:
name: Docker Smoke Test
runs-on: ${{ github.repository_owner == 'coder' && 'depot-ubuntu-22.04-16' || 'ubuntu-latest' }}
# Only run in merge queue (Docker builds are slow)
if: github.event_name == 'merge_group'
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Required for git describe to find tags
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker image
uses: docker/build-push-action@v6
with:
context: .
load: true
tags: mux-server:test
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Start container
run: |
docker run -d --name mux-test -p 3000:3000 mux-server:test
# Wait for server to be ready
for i in {1..30}; do
if curl -sf http://localhost:3000/health; then
echo "Server is ready"
break
fi
echo "Waiting for server... ($i/30)"
sleep 1
done
- name: Health check
run: |
response=$(curl -sf http://localhost:3000/health)
echo "Health response: $response"
if ! echo "$response" | grep -q '"status":"ok"'; then
echo "Health check failed"
exit 1
fi
- name: Version check
run: |
response=$(curl -sf http://localhost:3000/version)
echo "Version response: $response"
# Verify response contains expected fields
if ! echo "$response" | grep -q '"mode":"server"'; then
echo "Version check failed: missing mode=server"
exit 1
fi
if ! echo "$response" | grep -q '"git_describe"'; then
echo "Version check failed: missing git_describe field"
exit 1
fi
- name: Show container logs on failure
if: failure()
run: docker logs mux-test
- name: Cleanup
if: always()
run: docker rm -f mux-test || true
mux-server-smoke-test:
name: Mux Server Smoke Test
runs-on: ${{ github.repository_owner == 'coder' && 'depot-ubuntu-22.04-16' || 'ubuntu-latest' }}
# Tests oRPC/WebSocket flows that catch MockBrowserWindow bugs
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Required for git describe to find tags
- uses: ./.github/actions/setup-mux
- name: Build application
run: make build
- name: Pack npm package
run: npm pack
- name: Run smoke test
env:
SERVER_PORT: 3001
SERVER_HOST: localhost
STARTUP_TIMEOUT: 30
run: |
# Find the actual tarball name (version may vary)
TARBALL=$(ls mux-*.tgz | head -1)
PACKAGE_TARBALL="$TARBALL" ./scripts/smoke-test.sh
- name: Upload server logs on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: mux-server-smoke-test-logs
path: /tmp/tmp.*/server.log
if-no-files-found: warn
retention-days: 7
check-codex-comments:
name: Check Codex Comments
runs-on: ${{ github.repository_owner == 'coder' && 'depot-ubuntu-22.04-16' || 'ubuntu-latest' }}
if: github.event_name == 'pull_request'
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Required for git describe to find tags
- name: Check for unresolved Codex comments
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
./scripts/check_codex_comments.sh ${{ github.event.pull_request.number }}
# Trigger CI run