Skip to content

Latest commit

 

History

History
133 lines (98 loc) · 6.74 KB

verification.md

File metadata and controls

133 lines (98 loc) · 6.74 KB

Verification model

The catalog has one gate, scripts/verify.sh, and two workflows that run it.

scripts/verify.sh

The script runs from the repository root and executes eight stages in order. Any failure stops the run.

1. Structural validation of every composition contract

For each compositions/*/composition.yaml:

  • metadata.name must equal the directory name
  • spec.type must equal the directory name
  • schema.yaml must exist beside it
  • jobs/ must exist beside it

The run also fails if no composition directories are found at all, so an empty or mis-staged tree cannot pass silently.

2. Every template guard reads a namespace the job can see

A job template is rendered with exactly three namespaces: .orun, .parameters and .env. A condition on any other key is always false, so the step takes its else branch for every consumer and nothing fails. Every {{if ...}} and {{with ...}} in compositions/ must therefore read one of those three.

This is the bug that shipped in 0.18.1 through 0.20.0: turbo-package guarded pre-build, build and typecheck on .preBuildCommand, .buildCommand and .typecheckCommand, so pre-build skipped every component's tests and declared build and typecheck commands were ignored. Inside a range or with block . is rebound; bind a variable there so this rule can still read the expression.

3. Publish target resolution

orun publish "ghcr.io/sourceplane/stack-tectonic:${stack_version}" \
  --dry-run --root . --version "${stack_version}"

stack_version is read from metadata.version in stack.yaml. This resolves the manifest and the registry target without uploading anything.

4. Pack the shipped layers

orun pack archives whatever root it is given, but orun publish ships only stack.yaml, compositions/, and examples/. The script stages exactly that subset into a temporary directory and packs it, so the artifact under test is the artifact consumers actually resolve.

5. Resolve the packed artifact back through a consumer intent

The script writes a throwaway intent.yaml pointing at the packed tarball with an archive composition source:

compositions:
  sources:
    - name: stack-tectonic
      kind: archive
      path: <tmp>/stack.tgz

It then runs orun compositions list --intent intent.yaml and asserts that every composition directory in the repo appears in the output.

This last stage is the point of the script. A dry-run publish only proves the manifest and target resolve; it is no evidence the package is loadable. Packing and re-resolving exercises the same code path a consumer repository runs, so a composition Orun cannot load or export fails here instead of in a downstream repo after release.

6. Render turbo-package through the packed artifact

Resolving proves a composition loads, not that it renders what a component declares. The script plans two fixture components through the same packed artifact, one declaring preBuildCommand, buildCommand and typecheckCommand and one declaring none, on the verify profile. It then checks the rendered steps: the first must run its three commands, and the second must skip pre-build and use the default turbo run build and turbo run typecheck. Every structural check passed on the releases that skipped pre-build; this one would have failed them.

7. Render cloudflare-worker-turbo's deploy with and without skipResourceProvisioning

The script plans two fixture workers on the deploy profile, one setting skipResourceProvisioning: true and one leaving it out. The deploy profile binds secrets, so this fixture's intent declares a placeholder workspace and project; nothing is resolved at plan time. The first worker's deploy step must pass --x-provision=false to wrangler deploy, the second's must not, and both must keep the same wrangler deploy --config ... --env ... command. A consumer that has not opted in therefore deploys exactly as before.

8. Render cloudflare-worker-turbo's Cloudflare steps with and without deployTokenEnv

The same two fixture workers: the opted-in one also sets deployTokenEnv: CF_CONTAINERS_TOKEN. Its pre-deploy, migrate, deploy and secrets-live steps must each export CLOUDFLARE_API_TOKEN from that variable (failing loudly when it is empty); none of the default worker's steps may mention a token switch, so a consumer that has not opted in deploys with the profile's token as before.

9. Render db-migrate's build step with and without buildFilter

The script plans two migration components through the packed artifact, on stage and prod: the composition's own smoke fixture, which sets buildFilter: "@example/db", and one that leaves it out. Every build step of the first must render pnpm exec turbo run build --filter=@example/db. Every build step of the second must render pnpm exec turbo run build --filter=@saas/db, the exact 0.21.0 command, so a consumer that does not set the parameter plans as before.

orun does not copy a schema's default into .parameters, so the default comes from the template's else branch. A guard and a value that read different keys still renders a green build of @saas/db, and the mismatch only shows when the apply step fails with MODULE_NOT_FOUND. This stage fails on it instead.

Verify workflow

.github/workflows/verify.yml runs on every pull request and every push to main. It is a single verify-stack job: check out, log in to GHCR, set up Orun via sourceplane/orun-action, and run ./scripts/verify.sh.

Release workflow

.github/workflows/release.yml runs on tag pushes matching v*, and from its Run workflow button (workflow_dispatch):

  1. Derive the version from metadata.version in stack.yaml. On a tag push, assert it equals the tag without its leading v; a mismatched tag fails the release before anything is published. On a dispatched run the tag is v<version>: the run must be on main, and it stops if that tag already points at a different commit, so a version cannot be released twice from two commits.
  2. Run ./scripts/verify.sh — the same gate the pull request ran.
  3. Create the GitHub release with gh release create --generate-notes on the run's commit, skipping if it already exists. On a dispatched run this is also what creates the tag.
  4. Publish the OCI package with an explicit target. The target is passed explicitly because with no ref orun infers ghcr.io/<owner>/<repo>/<package> from the git remote, which is the wrong repository path.
  5. Confirm the package is pullable: orun fetch into a temp directory, assert stack.yaml is present, and report the exported composition count.

The package push deliberately runs after the release is created, so the tag and release notes are the record of record before the immutable artifact exists.