Docs / Development / CI
CI
Two workflows run on GitHub. The first runs the tests and the determinism checks on every push and pull request. The second builds and publishes this site.
ci.yml run side by side, and deploy waits for build.ci.yml#
.github/workflows/ci.yml has two jobs that run side by side on ubuntu-latest with Python 3.12. Each starts with actions/checkout@v4 and actions/setup-python@v5. Nothing in them needs Docker, a model, a key or a network, apart from fetching the two actions.
| Job | Step | Runs |
|---|---|---|
tests | Unit tests (every golden case is replayed and compared byte for byte) | python3 -m unittest discover -s tests -v with SWARMLABRE_SKIP_BROWSER=1 |
determinism | Replay every golden case twice under four hash seeds, two time zones and -X dev | The loop described below |
determinism | Re-recording and resealing change nothing (the recorder is deterministic on this runner too) | python3 -X dev -W error tests/goldenrun.py --update-golden |
determinism | The demo bundle replays | python3 -X dev -m swarmlabre replay demo/sfaef16e6 |
The determinism loop#
The loop runs tests/goldenrun.py --check --twice once for each of the hash seeds 0, 1, 4242 and random, under python3 -X dev -W error, and writes the case/file sha256 lines it prints to a file for each seed. Seed 1 runs in the time zone Pacific/Auckland and the others in UTC.
The job fails when a run exits with an error, when any warning is printed, when the table of seed 0 is empty, or when the table of any other seed differs from it. The table has one line for each output file of each case.
pages.yml#
.github/workflows/pages.yml runs on a push to main that changes the code, the UI, the demo, the site or the workflow itself, and by hand (workflow_dispatch). The environment variable DEMO_BUNDLE names the recorded run it builds from.
The build job runs on ubuntu-latest with Python 3.12 and installs nothing. deploy waits for it.
| Job | Step | Runs |
|---|---|---|
build | Replay the recording (fails if it is not byte for byte what was recorded) | python3 -m swarmlabre replay "$DEMO_BUNDLE" |
build | Build the static demo | python3 tools/build-demo.py "$DEMO_BUNDLE" --out site/demo |
build | Check the page holds no address it would fetch | A Python snippet. It removes the embedded recording from site/demo/index.html and fails when any address is left, apart from the SVG namespace. |
build | Copy the files the one-pager links into site/ | Copies the architecture diagram, four screenshots, the sample report and the fonts with their licence. |
build | Check the one-pager and the docs (no fetchable address, every link resolves) | tests/test_site.py and tests/test_docs.py with python3 -m unittest discover -s tests -p FILE -v |
build | actions/upload-pages-artifact@v3 | Uploads site/ as the Pages artifact. |
deploy | actions/deploy-pages@v4 | Publishes the artifact to the github-pages environment. |
Pages is switched on in the repository settings with the source "GitHub Actions". The custom domain is set there as well: a CNAME file is ignored when a workflow publishes. The workflow keeps one run per concurrency group, pages, and cancels one that is still going when a new push arrives.
Run the checks locally#
The steps are ordinary commands, so a contributor can run them as CI does:
$ SWARMLABRE_SKIP_BROWSER=1 python3 -m unittest discover -s tests $ python3 -X dev -W error tests/goldenrun.py --check --twice $ python3 -X dev -W error tests/goldenrun.py --update-golden $ python3 -X dev -m swarmlabre replay demo/sfaef16e6
--update-golden prints "golden: nothing would change" and exits 0 when the recorder and the reseal reproduce every committed file. When they do not, it prints a diff and a review token; Golden cases says what to do with them.
What CI does not run#
- The browser checks.
tests/ui/parity.py,tests/ui/tour.pyandtests/ui/site.pyneed headless Firefox andgeckodriver, and are run by hand. The unit tests skip their browser tests whenSWARMLABRE_SKIP_BROWSERis set, as the CI step does. - Docker. No step builds an image, starts a container or makes a real run, and no step re-records a real pipeline case.
- Other platforms. Every job runs on one Ubuntu image with Python 3.12.