-
Notifications
You must be signed in to change notification settings - Fork 113
184 lines (151 loc) · 5.81 KB
/
ci.yml
File metadata and controls
184 lines (151 loc) · 5.81 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
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
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-cmux
- 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-cmux
- 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
runs-on: ${{ github.repository_owner == 'coder' && 'depot-ubuntu-24.04-32' || '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-cmux
- name: Run integration tests with coverage
# --silent suppresses per-test output (17 test files × 32 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-cmux
- name: Install Playwright browsers
run: bun x playwright install --with-deps
- 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: End-to-End 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-cmux
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y xvfb
- name: Install Playwright runtime dependencies
run: bun x playwright install-deps
- name: Install Playwright browsers
run: bun x playwright install --with-deps
- name: Run e2e tests
run: xvfb-run -a make test-e2e
env:
ELECTRON_DISABLE_SANDBOX: 1
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