Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

How oaktree-sapling is tested

Most of what oak does is calls to GitHub, Zenodo and Cloudflare: it opens pull requests, deposits versions and deploys previews. Making those calls in a test is slow, needs tokens, and leaves repositories, deposits and deployments to clean up. So oak is tested in two layers. The fake layer is npm test, which runs on every pull request: it runs oak against fakes of the three services, offline. The fakes are written with an LLM’s help[1]. The real layer is a conformance run, started by gh workflow run conformance.yml -f tag=<release> and after each release from main: it runs oak upgrade in a test paper repository to move it onto a release, then runs that paper’s CI on GitHub, which deploys to Cloudflare and deposits to the Zenodo sandbox. RELEASING.md has the steps for making a dev release and starting a conformance run, and the secrets a run reads.

The fake layer: npm test

oak makes its calls through interfaces, and a test passes in a fake for each one. A fake records every call it answers, so a test can check what oak sent. For example, ConformanceGh is the GitHub that oak conformance calls, and the deposit tests answer Zenodo’s API with a fake transport.

A paper’s workflows run the bundled CLI, dist/cli.cjs, from the release they pin, so a test of src/ alone would pass with a broken bundle. Some suites run dist/cli.cjs, and they fail when it is older than src/. The PDF tests in npm test skip themselves unless the bundle, typst and oak’s typst template are all present. npm run build:fixture builds the test paper in test/fixture-paper to a PDF with the bundle and the typst template, and the release script runs it with the typst version oak pins.

The workflow files’ run: scripts guard what a paper’s CI does with its tokens, and a test that only reads the YAML would pass with every guard deleted. So the tests take each script out of its workflow file and run it in bash, as How the launchers are tested describes.

The real layer: conformance

Some behaviour exists only on a GitHub runner: a composite action’s if: and hashFiles conditions, secrets passed through a step’s env:, and previews on pull requests from forks. oak conformance run (reference) tests a release there, the way a journal uses it. It moves the test paper repository onto the release with oak upgrade, opens pull requests and pushes a tag there, and waits for the paper’s CI. Each phase checks what that CI produced, such as a page that serves, a comment or a file on the release, because a workflow can pass without producing it.

A run needs a release to move the paper onto. To test a change before a stable release, make a dev release, a pre-release named vX.Y.Z-dev.N. A version with a - becomes a GitHub pre-release, which releases/latest skips, so oak upgrade with no version never picks it.

What a run uses

The run itself has GitHub tokens only, one for the test repository and one for the fork, in an environment that admits only main and staging. RELEASING.md names the variables and secrets, and how to test a change to conformance from staging.

Each run works on its own branches, pull requests and tag, and oak conformance reset removes them before and after the run, so a run that crashed does not affect the next.

What a run checks

PhasePasses when
push-mainThe upgrade pull request passes its Journal checks and merges. On main, the paper pins the release, Build paper passes, GitHub Pages serves the site, and post-checks posts the Journal checks result.
preview-same-repoA pull request from a branch gets a preview comment, and its Cloudflare URL serves the page.
depositA v* tag runs deposit-version.yml. Its GitHub release has the deposit files, and oak release deposit comments the Zenodo draft’s link on the tagged commit.
failing-checksA pull request with an invalid project.id and an edition the journal lacks fails its Journal checks. The checks comment reports id-shape, and the summary reports the compose failure.
preview-forkA pull request from the fork gets a preview that serves, and post-checks posts its Journal checks result and comment.

Wherever post-checks posts the Journal checks result, the run waits for both the Check Run and the commit status (why both). check-paper composes the paper only when it has both the journal and oak’s checkout, so the compose failure also shows that it had them. The run has no Zenodo token, so it checks the deposit files by name. GitHub waits for approval before it runs the workflows on a first-time contributor’s pull request, so on the fork’s pull request the run approves them.

When it runs

A run starts after each successful cut-engine-release run from main, and by hand from Actions with a tag.

A conformance run goes through several real CI runs on the test paper repository, so it tests releases rather than pull requests and is not a required check. It uses a personal access token because GITHUB_TOKEN does not reach another repository, and events caused with GITHUB_TOKEN start no workflows. A run where a third party timed out exits 3 and stays green, so a red run points at oak rather than at GitHub, Cloudflare or Zenodo being slow. A run on a release the test repository already pins has no upgrade to test: it exits 4, stays green and uploads nothing, so the release keeps the conformance.json that npm-publish checks before publishing a stable tag.

Footnotes
  1. Each fake is modeled on the real service’s API, but the service can change and the model can be wrong, so a fake can drift from what the service does. The fakes are used only for fast tests of oak’s own logic, and a conformance run shows whether oak works with the real services.