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.ymltestsUnit testsevery test intests/, browserchecks skippedci.ymldeterminismReplay twicefour hashseeds, two timezones, -X devRe-recordand resealchange nothingDemo bundlereplayspages.ymlbuildReplaythe recordingBuildthe static demoCheckno fetchableaddressCopylinked filesinto site/Checkone-pager anddocs testsUploadsite/ as thePages artifactpages.ymldeployDeployto GitHub Pages ci.yml testsUnit testsevery test in tests/, browser checks skippedci.yml determinismReplay twicefour hash seeds, two time zones, -X devRe-recordand reseal change nothingDemo bundlereplayspages.yml buildReplaythe recordingBuildthe static demoCheckno fetchable addressCopylinked files into site/Checkone-pager and docs testsUploadsite/ as the Pages artifactpages.yml deployDeployto GitHub Pages
The steps of both workflows. Each job also runs the checkout and the Python setup first, which the drawing leaves out. The two jobs of 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.

JobStepRuns
testsUnit tests (every golden case is replayed and compared byte for byte)python3 -m unittest discover -s tests -v with SWARMLABRE_SKIP_BROWSER=1
determinismReplay every golden case twice under four hash seeds, two time zones and -X devThe loop described below
determinismRe-recording and resealing change nothing (the recorder is deterministic on this runner too)python3 -X dev -W error tests/goldenrun.py --update-golden
determinismThe demo bundle replayspython3 -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.

JobStepRuns
buildReplay the recording (fails if it is not byte for byte what was recorded)python3 -m swarmlabre replay "$DEMO_BUNDLE"
buildBuild the static demopython3 tools/build-demo.py "$DEMO_BUNDLE" --out site/demo
buildCheck the page holds no address it would fetchA Python snippet. It removes the embedded recording from site/demo/index.html and fails when any address is left, apart from the SVG namespace.
buildCopy the files the one-pager links into site/Copies the architecture diagram, four screenshots, the sample report and the fonts with their licence.
buildCheck 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
buildactions/upload-pages-artifact@v3Uploads site/ as the Pages artifact.
deployactions/deploy-pages@v4Publishes 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.py and tests/ui/site.py need headless Firefox and geckodriver, and are run by hand. The unit tests skip their browser tests when SWARMLABRE_SKIP_BROWSER is 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.
SwarmLabRE alpha 0.1.0Edit this page on GitHub