Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

requirements.integration.ci

Requirements index · View definition

evidence Valid

Requirement

A GitHub Actions CI workflow MUST run, for pull requests and pushes to main, these checks: cargo habeas coverage -- --locked --workspace under cite requirements.test-coverage.run, cargo test --locked --doc --workspace, mdbook test, the autofix controller tests with node --test .github/scripts/autofix.test.mjs, and, in a separate job, the Symposium session-start hook smoke test tests/symposium_hook_smoke.py. It MUST also build the book with the combined coverage reports of cite requirements.test-coverage.index.summary, including the coverage collected by these checks, and on a push to main, only after every check job passes, it MUST deploy the generated book/ directory to GitHub Pages. The book MUST set output.html.site-url to /habeas-codicem/ for project-site hosting.

Rationale

The single marked test, tests/repository.rs#fn[ci_tests_pull_requests_and_main_then_deploys_the_book_from_main], checks every obligation in requirements.integration.ci. I compared it with .github/workflows/ci.yml, which holds the {impl} markers for the requirement.

  • Triggers: the test asserts the exact on: block, which has push with branches: [main] plus pull_request. This covers “for pull requests and pushes to main”.
  • Required checks in test-and-build: the test finds each of these commands in the job text:
    • node --test .github/scripts/autofix.test.mjs
    • cargo habeas coverage -- --locked --workspace
    • cargo test --locked --doc --workspace
    • mdbook test
  • Coverage gate: cargo habeas coverage-check isn’t in the requirement text. The test still asserts that this step has no if and no continue-on-error, so a coverage failure fails the job. The requirements.test-coverage.run text is cited here only as context.
  • Symposium smoke test in a separate job: the test reads the symposium-hook job and asserts it runs python3 tests/symposium_hook_smoke.py. Separation holds because the step sits in its own job.
  • Book built with combined coverage, including coverage from these checks: the test asserts the order of the steps. The node tests, release build, coverage run, coverage check, doc tests, mdbook test and mdbook build must appear in that order, and the Pages artifact upload comes after them. It also asserts the upload path: book. So the book is built after the coverage run and the other checks, and book/ is what gets uploaded.
  • Deploy only after every check job passes, and only on a push to main: the test reads the deploy job and asserts the if: github.event_name == 'push' && github.ref == 'refs/heads/main' condition. It also asserts needs: [test-and-build, symposium-hook], which covers both check jobs, and actions/deploy-pages@v4.
  • Site URL: the test parses book.toml and asserts that output.html.site-url equals /habeas-codicem/.

The test is string- and ordering-based, so it would accept continue-on-error or if added to a check step other than the coverage gate. The requirement doesn’t name that failure mode. The coverage-collection wording is also loose, since the doctest and mdbook test steps don’t visibly collect coverage. The test does pin the ordering and the mdbook build step that consumes the coverage, which is the testable part. I found no unacknowledged gap.

Inputs

Implementation

Input 6: outline .github/workflows/ci.yml pair[on]
# {impl}`requirements.integration.ci`
on:
  push:
    branches: [main]
  pull_request:
Input 7: outline .github/workflows/ci.yml pair[jobs]
jobs:
  # {impl}`requirements.integration.ci`
  test-and-build:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      pages: read
    steps:
      - uses: actions/checkout@v6
      - uses: actions/setup-node@v6
        with:
          node-version: '24'
      - name: JavaScript tests
        run: node --test .github/scripts/autofix.test.mjs
      - name: Install mdBook
        run: cargo install mdbook --locked --version 0.5.4 --no-default-features --features search
      - name: Install nextest and LLVM tools
        run: |
          cargo install cargo-nextest --locked
          rustup component add llvm-tools-preview
      - name: Cargo tests with per-process coverage
        run: |
          cargo build --release --locked -p habeas
          cargo habeas coverage -- --locked --workspace
      - name: Enforce execution coverage
        run: cargo habeas coverage-check
      - name: Cargo doctests
        run: cargo test --locked --doc --workspace
      - name: mdBook tests
        run: mdbook test
      - name: Build mdBook
        run: mdbook build
      - name: Configure Pages
        if: github.event_name == 'push'
        uses: actions/configure-pages@v5
      - name: Upload Pages artifact
        if: github.event_name == 'push'
        uses: actions/upload-pages-artifact@v4
        with:
          path: book

  # {impl}`requirements.integration.ci`
  symposium-hook:
    runs-on: ubuntu-latest
    permissions:
      contents: read
    steps:
      - uses: actions/checkout@v6
      - name: Install Symposium
        run: cargo install symposium --locked --version 0.5.1
      - name: Test Habeas session-start hook
        run: python3 tests/symposium_hook_smoke.py

  # {impl}`requirements.integration.ci`
  deploy:
    if: github.event_name == 'push' && github.ref == 'refs/heads/main'
    needs: [test-and-build, symposium-hook]
    runs-on: ubuntu-latest
    permissions:
      contents: read
      pages: write
      id-token: write
    concurrency:
      group: pages
      cancel-in-progress: false
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    steps:
      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v4

Tests

Input 4: outline tests/repository.rs fn[ci_tests_pull_requests_and_main_then_deploys_the_book_from_main]
// {test}`requirements.integration.ci`
// {test}`requirements.test-coverage.check.guidance`
#[test]
fn ci_tests_pull_requests_and_main_then_deploys_the_book_from_main() {
    let workflow = repository_file(".github/workflows/ci.yml");
    assert!(
        workflow.contains("\non:\n  push:\n    branches: [main]\n  pull_request:\n\n"),
        "{workflow}"
    );

    let test = workflow_job(&workflow, "test-and-build");
    let steps = [
        "run: node --test .github/scripts/autofix.test.mjs",
        "cargo build --release --locked -p habeas",
        "cargo habeas coverage -- --locked --workspace",
        "run: cargo habeas coverage-check",
        "run: cargo test --locked --doc --workspace",
        "run: mdbook test",
        "run: mdbook build",
        "uses: actions/upload-pages-artifact@v4",
    ];
    let positions: Vec<_> = steps
        .iter()
        .map(|step| test.find(step).unwrap_or_else(|| panic!("{step}:\n{test}")))
        .collect();
    assert!(positions.is_sorted(), "{test}");
    assert!(test.contains("with:\n          path: book\n"), "{test}");
    let workflow_yaml: serde_json::Value = serde_saphyr::from_str(&workflow).unwrap();
    let gate = workflow_yaml["jobs"]["test-and-build"]["steps"]
        .as_array()
        .unwrap()
        .iter()
        .find(|step| step["run"] == "cargo habeas coverage-check")
        .unwrap();
    assert!(
        gate.get("if").is_none(),
        "check only after successful collection"
    );
    assert!(
        gate.get("continue-on-error").is_none(),
        "enforce coverage failures"
    );

    let hook = workflow_job(&workflow, "symposium-hook");
    assert!(
        hook.contains("run: python3 tests/symposium_hook_smoke.py"),
        "{hook}"
    );

    let deploy = workflow_job(&workflow, "deploy");
    assert!(
        deploy.contains("if: github.event_name == 'push' && github.ref == 'refs/heads/main'"),
        "{deploy}"
    );
    assert!(
        deploy.contains("needs: [test-and-build, symposium-hook]"),
        "{deploy}"
    );
    assert!(deploy.contains("uses: actions/deploy-pages@v4"), "{deploy}");

    let book = repository_toml("book.toml");
    assert_eq!(
        book["output"]["html"]["site-url"].as_str(),
        Some("/habeas-codicem/")
    );
}

Referenced definitions

Input 2: requirements selection requirements.test-coverage.run
:::{req} run
`habeas coverage [-- <nextest arguments>]` MUST run LLVM-instrumented Rust tests
through `cargo nextest run`, forwarding the supplied arguments and preserving
nextest's configured test concurrency, filtering, and retries. With no supplied
arguments it MUST select the workspace.
:::
Input 3: requirements selection requirements.test-coverage.index.summary
:::{req} index.summary
The coverage index MUST display the combined view selected under
{cite}`requirements.test-coverage.index.selection` and
{cite}`requirements.test-coverage.index.freshness`. It MUST show the number of
selected test attempts and summarize coverage excluded because it is stale,
unavailable, or from a historical build configuration. Detailed test identities,
run provenance, and per-test execution data MUST remain in the saved coverage
artifacts rather than being included in the generated book.

For first-party Rust files under
{cite}`requirements.references.rust_item_coverage`, the summary MUST compute
line coverage from the union of instrumented file-and-line locations in the
selected fresh records, including their associated child-process records.
Each location MUST count once in the denominator and count as covered when any
selected record has a positive execution count for it. Percentages MUST be
computed from those union counts rather than averaged across process reports.
A view with no instrumented lines MUST show coverage as unavailable. The index
MUST visibly identify incomplete coverage and MUST NOT imply that every current
test has coverage merely because all available records are valid.
:::

Other sources

Input 1: requirements selection requirements.integration.ci
:::{req} ci
A GitHub Actions CI workflow MUST run, for pull requests and pushes to `main`, these checks: `cargo habeas coverage -- --locked --workspace` under {cite}`requirements.test-coverage.run`, `cargo test --locked --doc --workspace`, `mdbook test`, the autofix controller tests with `node --test .github/scripts/autofix.test.mjs`, and, in a separate job, the Symposium session-start hook smoke test `tests/symposium_hook_smoke.py`. It MUST also build the book with the combined coverage reports of {cite}`requirements.test-coverage.index.summary`, including the coverage collected by these checks, and on a push to `main`, only after every check job passes, it MUST deploy the generated `book/` directory to GitHub Pages. The book MUST set `output.html.site-url` to `/habeas-codicem/` for project-site hosting.
:::
Input 5: outline .github/workflows/ci.yml pair[name]
name: CI