Repository navigation
389 lines (346 loc) · 16.5 KB
/
Copy pathci.yml
File metadata and controls
389 lines (346 loc) · 16.5 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
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
name: CI
# Four kinds of checks, on Linux. "Fast checks" is the fast part of CONTRIBUTING.md#checks: lint,
# format, types, layer contracts, the tests not marked slow, and the static content checks against a
# workspace made by the job. "JVM tests" runs the tests marked jvm (the slow tests that drive Gradle,
# javac, kotlinc or a JVM runner) and the Java and Kotlin conformance suites on the two ends of the
# supported JDK range, 21 and 26 (ADR 0016). "Browser tests" runs the Playwright tests of the web UI
# on Chromium, and only for a push or pull request that touches the page, its tests or this
# workflow: the small "Changes" job decides, and no other job waits for it. "Sandbox tests" runs the
# tests marked docker on a real engine, the same way: only for a change that can affect the sandbox,
# as the same job decides. The other slow tests (Node, Go, Cargo, the debuggers; Firefox and WebKit
# in the browser tests) stay a local gate.
# The fast tests need no toolchain but uv and Python 3.13, which uv installs from .python-version:
# each toolchain is replaced by a fake, and the few tests that call `gofmt`, `rustfmt` or `git`
# skip without one. Pyright runs on Node, the major version the TypeScript runner needs; without
# a Node on PATH, pyright's own download of one fails. The JVM job needs that Node, and pnpm, too:
# the slow tests set up a workspace the way `cstudy doctor --fix` does, TypeScript project included.
# The browser job sets up the same workspace, so it has the same Node, pnpm and a JDK (21, the
# bottom of the range); it has no Go or Rust, which no browser test runs.
#
# CI publishes nothing: it can only read the repository and holds no secret. Versioning and
# publishing belong to version.yml, which runs when a run of this workflow for a push to main
# completes and releases only when that run succeeded, so every job here gates a release. A job
# that "Changes" skips does not fail the run. The release commit says [skip ci], and the commit and
# the tag are pushed with GITHUB_TOKEN, which starts no run.
on:
push:
branches: ["**"]
pull_request:
permissions:
contents: read
# A newer push to the same branch or pull request cancels the run in progress.
concurrency:
group: ci-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
checks:
name: Fast checks (Linux)
runs-on: ubuntu-latest
timeout-minutes: 20
defaults:
run:
working-directory: cli
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
with:
enable-cache: true
cache-dependency-glob: uv.lock
cache-python: true
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: "24"
package-manager-cache: false
- name: Install the development environment
run: uv sync --locked
- name: Lint
run: uv run ruff check .
- name: Format
run: uv run ruff format --check .
- name: Types
run: uv run pyright
- name: Layer contracts
run: uv run lint-imports
- name: Fast tests
run: uv run pytest -q -m "not slow"
- name: Static content checks
env:
CSTUDY_WORKSPACE: ${{ runner.temp }}/workspace
run: |
uv run cstudy init "$CSTUDY_WORKSPACE" --no-ide
uv run cstudy verify --static
jvm:
name: JVM tests (JDK ${{ matrix.jdk }}, Linux)
runs-on: ubuntu-latest
timeout-minutes: 45
strategy:
# A failure on one end of the range says nothing about the other: let both finish.
fail-fast: false
matrix:
jdk: ["21", "26"]
defaults:
run:
working-directory: cli
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
with:
enable-cache: true
cache-dependency-glob: uv.lock
cache-python: true
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: "24"
package-manager-cache: false
# JAVA_HOME and PATH name this JDK, which is the one cstudy selects. The cache holds Gradle's
# downloads, keyed on the files that decide them: the runners' version catalog and builds.
- uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0
with:
distribution: temurin
java-version: ${{ matrix.jdk }}
cache: gradle
cache-dependency-path: |
runners/jvm/gradle/libs.versions.toml
runners/jvm/**/*.gradle.kts
cli/src/coding_study/adapters/workspace_template/jvm/gradle/wrapper/gradle-wrapper.properties
- name: Enable pnpm
run: corepack enable pnpm
- name: Install the development environment
run: uv sync --locked
- name: Selected JDK
run: java -version
- name: JVM tests
run: uv run pytest -q -rs -m jvm
- name: Conformance
env:
CSTUDY_WORKSPACE: ${{ runner.temp }}/workspace
run: |
uv run cstudy init "$CSTUDY_WORKSPACE" --no-ide
uv run cstudy doctor --fix
uv run cstudy verify --conformance --lang java
uv run cstudy verify --conformance --lang kotlin
# Whether a change can affect the web UI's page, for the browser job, or the sandbox of a service
# project, for the sandbox job: the run is of a push or a pull request, and a push or pull request
# of problems or docs alone leaves both as they were. The web paths are the page itself, the
# browser tests and the modules they use (a test guards this list against the imports of the
# browser tests), and this workflow; the sandbox paths are the code a stack runs on, its fixtures,
# its tests and this workflow. The diff is of what the run brings: a pull request's merge commit
# against its first parent, a push against the commit the branch had before, or against the default
# branch for a new branch or a commit that is gone (a force push). When no diff can be made both
# jobs run.
changes:
name: Changes
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
web: ${{ steps.diff.outputs.web }}
sandbox: ${{ steps.diff.outputs.sandbox }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 2
persist-credentials: false
- name: Diff against what the run builds on
id: diff
env:
EVENT: ${{ github.event_name }}
BEFORE: ${{ github.event.before }}
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
WEB_PATHS: |
tools/web-ui
cli/src/coding_study/entrypoints/web
cli/tests/entrypoints/web/test_browser_*.py
cli/tests/entrypoints/web/conftest.py
cli/tests/entrypoints/web/hide_paths_probe.cjs
cli/tests/conftest.py
cli/tests/browsers.py
cli/tests/fake_language_server.py
cli/tests/fake_sandbox_site
cli/tests/helpers.py
cli/tests/intelligence_lab.py
cli/tests/language_server_scripts.py
cli/tests/profile_workspace.py
cli/tests/ai_fixtures.py
cli/tests/ai_review_workspace.py
cli/tests/ai_workspace.py
cli/tests/fake_ai_provider.py
cli/tests/sandbox_fakes.py
cli/tests/scripted_child.py
cli/tests/scripted_runs.py
cli/tests/scripted_sandbox.py
cli/tests/serve_page.py
cli/tests/serve_process.py
cli/tests/waits.py
cli/tests/workspaces.py
.github/workflows/ci.yml
SANDBOX_PATHS: |
cli/src/coding_study/adapters/docker_sandbox.py
cli/src/coding_study/adapters/sandbox_forward.py
cli/src/coding_study/adapters/stack_guard.py
cli/src/coding_study/adapters/service_files.py
cli/src/coding_study/adapters/mock_server
cli/src/coding_study/adapters/http_grader
cli/src/coding_study/adapters/process_environment.py
cli/src/coding_study/application/sandbox.py
cli/src/coding_study/application/graded_stack.py
cli/src/coding_study/application/http_grading.py
cli/src/coding_study/application/http_grading_ports.py
cli/src/coding_study/application/http_grading_steps.py
cli/src/coding_study/application/service_*.py
cli/src/coding_study/application/verify_service.py
cli/src/coding_study/application/code_intelligence.py
cli/src/coding_study/domain/sandbox.py
cli/src/coding_study/domain/devcontainer.py
cli/src/coding_study/domain/docker_engine.py
cli/src/coding_study/domain/mock_configs.py
cli/src/coding_study/domain/service_*.py
cli/src/coding_study/domain/http_*.py
cli/src/coding_study/domain/stack_progress.py
cli/src/coding_study/domain/code_intelligence.py
cli/src/coding_study/entrypoints/commands/dev.py
cli/src/coding_study/entrypoints/commands/dev_events.py
cli/src/coding_study/entrypoints/commands/service_test.py
cli/src/coding_study/entrypoints/web/code_intelligence.py
cli/tests/adapters/test_docker_sandbox_real.py
cli/tests/adapters/test_backing_services_real.py
cli/tests/adapters/test_service_steps_real.py
cli/tests/real_service_projects.py
cli/tests/test_service_projects_real.py
cli/tests/fixtures/service_projects
schemas/mock.schema.json
.github/workflows/ci.yml
run: |
set -euo pipefail
base=""
if [ "$EVENT" = pull_request ]; then
base=HEAD^1
elif [ "$BEFORE" != "0000000000000000000000000000000000000000" ] \
&& git fetch --quiet --no-tags --depth=1 origin "$BEFORE"; then
base=FETCH_HEAD
elif git fetch --quiet --no-tags --depth=1 origin "$DEFAULT_BRANCH"; then
base=FETCH_HEAD
fi
decide() {
local output=$1 paths=()
while read -r path; do
if [ -n "$path" ]; then paths+=("$path"); fi
done <<< "$2"
local changed=true
if [ -z "$base" ]; then
echo "No base to compare with: the $output job runs."
elif [ -n "$(git diff --name-only "$base" HEAD -- "${paths[@]}")" ]; then
git diff --name-only "$base" HEAD -- "${paths[@]}"
else
echo "Nothing the $output job depends on changed: it is skipped."
changed=false
fi
echo "$output=$changed" >> "$GITHUB_OUTPUT"
}
decide web "$WEB_PATHS"
decide sandbox "$SANDBOX_PATHS"
# Chromium only, one job, no matrix and no schedule: the web UI supports three engines
# (docs/specs/web-ui.md#browser-support) and the tests run on each of them locally, but a failure
# on one of the other two says little the run on Chromium does not, and Firefox and WebKit
# double the download and the time. `-k chromium` selects the tests whose parameters name it (the
# `engine` fixture, and the axe checks' views), a third of the collected tests. The browsers are
# cached by the version of Playwright that decides their revision, and the pnpm store by the
# lock files of the packages the workspace and the language servers install; the system
# libraries the browsers link are installed every run. Two workers, one test file each, as in the
# local gate's browser lane.
browser:
name: Browser tests (Chromium, Linux)
needs: changes
if: needs.changes.outputs.web == 'true'
runs-on: ubuntu-latest
timeout-minutes: 15
defaults:
run:
working-directory: cli
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
with:
enable-cache: true
cache-dependency-glob: uv.lock
cache-python: true
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: "24"
package-manager-cache: false
# The workspace the tests share is set up with `cstudy doctor --fix`'s steps, the JVM ones
# included, so the runner has a JDK of the supported range and Gradle's downloads cached.
- uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0
with:
distribution: temurin
java-version: "21"
cache: gradle
cache-dependency-path: |
runners/jvm/gradle/libs.versions.toml
runners/jvm/**/*.gradle.kts
cli/src/coding_study/adapters/workspace_template/jvm/gradle/wrapper/gradle-wrapper.properties
- name: Enable pnpm
run: corepack enable pnpm
- name: Cache the pnpm store
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.local/share/pnpm/store
key: pnpm-store-${{ runner.os }}-${{ hashFiles('cli/src/coding_study/adapters/workspace_template/typescript/pnpm-lock.yaml', 'cli/src/coding_study/adapters/language_servers/pnpm-lock.yaml') }}
- name: Install the development environment
run: uv sync --locked --group browser
- name: Playwright version
id: playwright
run: echo "version=$(uv run --group browser playwright --version | cut -d' ' -f2)" >> "$GITHUB_OUTPUT"
- name: Cache the Playwright browsers
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.cache/ms-playwright
key: playwright-chromium-${{ runner.os }}-${{ steps.playwright.outputs.version }}
- name: Install Chromium
run: uv run --group browser playwright install --with-deps chromium
- name: Browser tests
run: uv run --group browser pytest -q -rs -n 2 --dist loadfile -k chromium tests/entrypoints/web/test_browser_*.py
# A real engine, for what no fake can show: compose's behavior, the network that has no way out and
# the leftovers a killed owner leaves. One job, no matrix and no schedule, on a free account's
# minutes: it takes a few minutes and runs only when the sandbox can have changed. The real-engine
# JVM tests (marked docker_jvm, about ten minutes under load) and Go tests (marked docker_go, whose
# first build of each fresh install cache compiles Go's standard library: 15 minutes under a heavy
# load) stay a local gate to keep it under 15 minutes. It is also the only Linux evidence: file ownership, the firewall and the bridge address differ from Docker
# Desktop's. Images come from the registry here: the mock server's and the fixture's Redis before
# the tests that pull nothing, and the others through `cstudy start`. Installs are small and go through a volume on
# the engine, so nothing is worth caching. Nothing waits for this job.
sandbox:
name: Sandbox tests (real Docker, Linux)
needs: changes
if: needs.changes.outputs.sandbox == 'true'
runs-on: ubuntu-latest
timeout-minutes: 15
defaults:
run:
working-directory: cli
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
with:
enable-cache: true
cache-dependency-glob: uv.lock
cache-python: true
- name: Install the development environment
run: uv sync --locked
- name: Docker
run: |
docker info --format '{{.ServerVersion}}'
docker compose version
- name: Pull the mock server's image
run: docker pull "$(uv run python -c 'from coding_study.domain.sandbox import PYTHON_IMAGE; print(PYTHON_IMAGE)')"
- name: Pull the Redis that the service-step tests pause and stop
run: docker pull "$(uv run python -c 'from tests.adapters.test_service_steps_real import REDIS; print(REDIS["image"])')"
- name: Sandbox tests
run: uv run pytest -q -rs -m "docker and not docker_jvm and not docker_go"