← Validation Lab Bench 1 · Temperature monitor I2CUARTPython simulator
Clean run STR-TMP-002: ready

Stage 07 · CI/CD

Every change tested by one command. Nothing broken reaches the site.

One entry point, nox -s ci, runs the same locally and in CI. GitHub Actions tests and decides; Cloudflare Pages only hosts what passed. A fast suite keeps the whole pipeline to one short job.

nox -s ci to the report
40.4 s
Bench 1, all runs
11.4 s
Lab machines
0

Every pull request marked ready and every push to main that changes code · one job

  1. Static checksruff · mypy · import-linter
  2. Spec lintYAML · matrix · STD ↔ code
  3. Framework testsunit · contract
  4. Bench suiteall levels · virtual clock
  5. Report and siteSTR · RTM · history · pages
  6. Security checksheaders · links · gitleaks
  7. Deploymain only · Cloudflare Pages

Static checks

fails the run

What runs

Lint, strict typing, and the layer contract: a layer imports only the layers below it. The long-dash check runs here too.

Where

step 1 of nox -s ci

Why it exists

A broken layer boundary spreads quietly. It is cheapest to stop it before any test runs.

Spec lint

fails the run

What runs

Schema check of the requirements, questions, matrix, STD and STP files. Matrix rules. Every STD case has a test, every test has a known ID.

Where

step 2

Why it exists

In validation the documents are deliverables. If they disagree with the code, the report is wrong.

Framework tests

fails the run

What runs

Unit tests of the factory, registry, plugin and tools. Contract tests run on every HAL implementation.

Where

step 3

Why it exists

If the framework lies, every bench result lies with it.

Bench suite

fails the run

What runs

Every case of bench 1 on the simulator, the soak level included: 12 h of device time on the virtual clock. Then one more run per seeded bug, and the break-it gate.

Where

step 4 · pytest -n auto

Why it exists

With a virtual clock the full suite costs seconds, so there is no reason to split smoke and nightly. Every change gets the whole picture.

Report and site

fails the run on bad data

What runs

results.json becomes the STR, the RTM, the defect drafts and these pages. history.json is downloaded from the live site, this run is appended, and it is published again.

Where

step 5

Why it exists

Trends without a database: the published site carries its own history.

Security checks

fails the run

What runs

The response headers match docs/security.md, no inline script or style, no banned DOM calls in the scripts, every internal link resolves, and a secret scan of the commits and the built site.

Where

step 6

Why it exists

The site is static, so the attack surface is small. It is checked anyway, on every run.

Deploy

only after green

What runs

wrangler pages deploy uploads the site built in step 5. Switched off until the Pages project and its token exist.

Where

after nox, main only

Why it exists

CI decides, CD only delivers. A red run never replaces the live site.

One entry point

The pipeline lives in noxfile.py, not in YAML. The same command runs on a laptop, in GitHub Actions and in any other CI.

One job, not six

GitHub rounds every job up to a whole minute, so all steps share one job. Six small jobs would cost at least six minutes for the same work.

Fast by design

A virtual clock runs 12 hours of device time in seconds.

CI and CD separated

CI produces results.json and the site. CD uploads it to Cloudflare Pages. A red run never deploys, so the live site always shows a green, known build.

Build history

from history.json: 2 builds, the last 100 are kept
Build 1: 40.2 sBuild 2: 40.4 s
BuildDateCommitnox to reportBench 1Clean runCases passedBugs caught
#22026-11-25T20:40:43Z93ea83d 40.4 s 11.4 s STR-TMP-002 ready 30 / 30 5 / 5
#12026-11-25T20:37:46Z93ea83d 40.2 s 11.3 s STR-TMP-001 ready 30 / 30 5 / 5

Until the first deploy every build starts a new history, so the table holds one build. Each published build adds a row.

Gate policy

what fails the run, and why
CheckEffectReason
ruff, mypy --strict, import-linterfails the runbroken boundaries spread quietly
YAML schema, matrix rules, STD ↔ codefails the rundocuments and code must agree
Framework unit and contract testsfails the runevery result depends on them
Any record of the clean run not passedfails the runthe clean firmware is the reference
A seeded bug that no case catchesfails the runa suite that misses a known bug is broken
A soak-only bug caught below the soak levelfails the runthe levels must mean what they say
Long dash, banned HTML or JS, dead link, leaked secretfails the runwriting and security rules
Exit criteria of a bug run not metreportedexpected: that run shows what a red STR looks like

The pipeline · one command

noxfile.py
@nox.session(python=False)
def ci(session: nox.Session) -> None:
    """Static checks, spec lint, tests, report and security checks."""
    started = time.monotonic()  # history.json keeps the wall time up to the report
    session.run("uv", "sync", "--locked", external=True)

    # 1. Static checks
    uv_run(session, "ruff", "check", ".")
    uv_run(session, "ruff", "format", "--check", ".")
    uv_run(session, "mypy")
    uv_run(session, "lint-imports")
    uv_run(session, "python", "-m", "tools.check_dashes")

    # 2. Spec lint
    uv_run(session, "python", "-m", "tools.check_spec")

    # 3. Framework unit and contract tests
    uv_run(session, "pytest", "framework_tests")

    # 4. Bench suites on the simulator: one clean run, then one run per seeded bug (T12).
    bench_seconds: list[str] = []
    for tests in sorted(Path("benches").glob("*/tests")):
        bench = tests.parent.name
        bench_started = time.monotonic()
        results = RESULTS_DIR / bench
        shutil.rmtree(results, ignore_errors=True)  # no stale results from an earlier run
        shutil.rmtree(ARTIFACTS_DIR / bench, ignore_errors=True)  # nor stale logs
        run = ("pytest", "-n", "auto", str(tests), "--bench", bench, "--target", "sim")
        uv_run(
            session,
            *run,
            "--results",
            str(results / "clean.json"),
            "--artifacts",
            str(ARTIFACTS_DIR / bench / "clean"),
        )
        # Failing tests are expected here, so exit code 1 is fine. Anything
        # above 1 (interrupted, internal error, usage error, no tests) stops nox.
        # tools.break_it reads the results and fails on a bug nobody caught.
        bugs_key, bugs = bench_bugs(session, bench)
        for bug in bugs:
            uv_run(
                session,
                *run,
                "--set",
                f"{bugs_key}=[{bug}]",
                "--results",
                str(results / f"{bug}.json"),
                "--artifacts",
                str(ARTIFACTS_DIR / bench / bug),
                success_codes=[0, 1],
            )
        uv_run(session, "python", "-m", "tools.break_it", "gate", bench, "--results", str(results))
        bench_seconds += ["--bench-seconds", f"{bench}={time.monotonic() - bench_started:.1f}"]

    # 5. Report data (STR, RTM, defect drafts, history.json, T13), then the site (T14).
    # It prints the exit criteria of each clean run and one line per bug run.
    uv_run(
        session,
        *("python", "-m", "tools.build_report"),
        *("--report", str(REPORT_DIR), "--results", str(RESULTS_DIR)),
        *("--nox-seconds", f"{time.monotonic() - started:.1f}", *bench_seconds),
    )
    # The pages, from the spec YAML and the report data (T14, ADR-028).
    uv_run(
        session,
        *("python", "-m", "tools.build_site", "--out", str(BUILD_DIR)),
        *("--report", str(REPORT_DIR), "--results", str(RESULTS_DIR)),
    )
    uv_run(session, "python", "-m", "tools.check_dashes", str(BUILD_DIR), str(REPORT_DIR))

    # 6. Security checks: headers, page and script rules, links, secrets
    uv_run(session, "python", "-m", "tools.check_security", str(BUILD_DIR))
    uv_run(session, "python", "-m", "tools.check_links", str(BUILD_DIR))
    # A placeholder fails a publishing run (VLAB_PUBLISH), other runs list them.
    uv_run(session, "python", "-m", "tools.check_placeholders", str(BUILD_DIR))
    gitleaks = gitleaks_binary()
    flags = ("--redact", "--no-banner", "--exit-code", "1")
    session.run(str(gitleaks), "git", *flags, ".", external=True)
    session.run(str(gitleaks), "dir", *flags, str(BUILD_DIR), external=True)
    session.run(str(gitleaks), "dir", *flags, str(REPORT_DIR), external=True)

The CI file only calls it

.github/workflows/ci.yml
name: ci

on:
  pull_request:
    types: [opened, synchronize, reopened, ready_for_review]
    paths-ignore:
      - "docs/**"
      - "**/*.md"
  push:
    branches: [main]
    paths-ignore:
      - "docs/**"
      - "**/*.md"

permissions:
  contents: read

concurrency:
  group: ci-${{ github.ref }}
  cancel-in-progress: true

jobs:
  ci:
    # Draft PRs start nothing. Marking a PR ready for review starts the run.
    if: github.event_name == 'push' || github.event.pull_request.draft == false
    runs-on: ubuntu-24.04
    timeout-minutes: 6
    steps:
      - name: Check out
        uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false

      - name: Set up uv
        uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
        with:
          version: "0.11.32"
          enable-cache: true
          cache-dependency-glob: uv.lock

      - name: nox -s ci
        run: uv run --locked nox -s ci
        env:
          # "true" only on a run that deploys: a failed history.json download
          # then fails the run instead of publishing a new history (ADR-027).
          # Same condition as the deploy step (switched on in T16).
          VLAB_PUBLISH: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}

      # Deploys only on a push to main after every step above passed (T16).
      - name: Deploy to Cloudflare Pages
        if: github.event_name == 'push' && github.ref == 'refs/heads/main'
        uses: cloudflare/wrangler-action@953926a2e2182532811c01a25e53647d93bf07c0 # v4.1.3
        with:
          wranglerVersion: "4.158.0"
          apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
          accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
          command: pages deploy build/site --project-name=stanislavdmytrenko --branch=main

      # Same guard as the deploy step: checks the live site against site/_headers.
      - name: Check the live site
        if: github.event_name == 'push' && github.ref == 'refs/heads/main'
        timeout-minutes: 2
        run: uv run --locked python -m tools.check_live

Hygiene

  • least-privilege permissions
  • actions pinned by SHA
  • locked dependencies with hashes
  • Cloudflare token in an encrypted secret
  • gitleaks on every run
  • no lab machine, no self-hosted runner
← Run, debug and report Back to the start page →