Repository navigation
ci: run the backend tests in parallel, start every CI job at once - #328
Merged
Merged
Conversation
The backend's tests ran in one job each for the embedded and the server database (8 and 6.5 minutes on GitHub's runners), behind an Affected projects job that every other job waited for, so each of them queued for a free runner twice. - tests/conftest.py: one OpenMP thread per tesseract. Each xdist worker runs its own, and their threads fighting over the cores made the video and OCR tests take minutes (539 s against 23 s for them on 4 cores; the whole suite 320 s against 171 s). - Both backend jobs are split across two runners by recorded durations (pytest-split, fastapi_backend/tests/durations.json; nx run backend:test-durations records them again). Coverage uses Python's sys.monitoring (COVERAGE_CORE=sysmon), a third faster. - Every CI job starts at once and asks Nx itself whether its project is affected (.github/actions/affected); one that isn't stops there and passes. - On main, Backend coverage adds up the shards' coverage. - Merging or closing a pull request cancels its CI, pre-commit and Install runs that are still waiting or going; PR title cancels its older checks. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AZk9aGmS4XYCbX5FtubfuF
…n4jv # Conflicts: # docs/contributing.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Adeel · project thread
Description
Before: a backend PR's CI took about 9 minutes of running after two waits for a free runner. The embedded-database tests ran in one job (8 min of tests) and the server-database tests in another (6.5 min), and since #303 every job also waited for an Affected projects job first, so it queued for a runner a second time. Runs of merged or closed PRs kept going.
After: every CI job starts at once. The backend's tests are split across two runners per database and are much faster on their own. Merging or closing a PR cancels its leftover runs.
FastAPI (embedded SurrealDB) 1/2, 2/2andFastAPI (SurrealDB server) 1/2, 2/2, split by recorded durations with pytest-split (MIT, pinned withuv run --with, so the lockfile is untouched). The durations are infastapi_backend/tests/durations.json, andnx run backend:test-durationsrecords them again. Locally the halves are 437 and 433 tests, disjoint and covering all 870. The first embedded shard also runs lint, mypy and the OpenAPI check.sys.monitoring(COVERAGE_CORE=sysmon): a shard took 117 s instead of 162 s locally. Each shard keeps its coverage data with the run. Onmain, Backend coverage combines them into thebackend-coverageartifact and the summary; on PRs that job would hold the checks waiting for another runner, so it doesn't run there..github/actions/affected, the same nx-set-shas base as before). An unaffected job stops after that and passes. If Nx can't answer, the job runs. Other projects writes the affected list to the summary..github/actions/**joinssharedGlobalsinnx.json.closed, with every job skipped. The per-PR concurrency group then cancels the PR's queued or running runs. PR title gets a concurrency group too.Every check that ran before still runs. No test is skipped or disabled.
Motivation and Context
About 40 runs were queued, and jobs waited 4 to 23 minutes for a runner, longer than they ran (e.g. main's run at 20:53: Next.js started after 13 min, embedded tests after 23 min). Shorter jobs, no second queue and no leftover runs free runners for the open PRs.
Types of changes
Checklist:
docs/accordingly (docs/contributing.md, Monorepo and CI).Done questions (AGENTS.md)
uv run --with.contents: readandactions: read.--store-durations), docs updated.durations.jsonnow and then. Maybe drop the duplicated ruff/ESLint/tsc in pre-commit, since CI runs them too. Backend coverage's combine runs for the first time on main.🤖 Generated with Claude Code
https://claude.ai/code/session_01AZk9aGmS4XYCbX5FtubfuF
Generated by Claude Code