diff --git a/.github/workflows/bootstrap.yml b/.github/workflows/bootstrap.yml index 298eea9..b265222 100644 --- a/.github/workflows/bootstrap.yml +++ b/.github/workflows/bootstrap.yml @@ -4,24 +4,34 @@ name: bootstrap on: push: branches: [main] + tags: ['**'] pull_request: workflow_dispatch: permissions: contents: read +# A newer push to a pull request cancels its older run. Every other run has a +# group of its own, so a main or tag run is never cancelled, and never replaced +# while queued, and every merged or released commit keeps its verdict. +concurrency: + group: ${{ github.event_name == 'pull_request' && format('bootstrap-pr-{0}', github.event.pull_request.number) || format('bootstrap-run-{0}', github.run_id) }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + jobs: template-gate: name: acceptance / ${{ matrix.runner }} strategy: fail-fast: false matrix: - runner: [ubuntu-24.04, ubuntu-24.04-arm] + # A pull request runs the complete gate once, natively on amd64. Main and + # tags run it on both native architectures before anything is published. + runner: ${{ fromJSON(github.event_name == 'pull_request' && '["ubuntu-24.04"]' || '["ubuntu-24.04", "ubuntu-24.04-arm"]') }} runs-on: ${{ matrix.runner }} timeout-minutes: 45 steps: - name: Check out the exact event revision - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 with: fetch-depth: 0 persist-credentials: false diff --git a/.github/workflows/lexlean.yml b/.github/workflows/lexlean.yml index 85aa024..77ed168 100644 --- a/.github/workflows/lexlean.yml +++ b/.github/workflows/lexlean.yml @@ -107,70 +107,6 @@ jobs: . .github/lexlean-ci/lib.sh gate "list the production requests" output_matrix - cargo: - name: cargo / fmt clippy audits deny test - runs-on: ubuntu-24.04 - timeout-minutes: 90 - steps: - - name: Check out the exact event revision - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - fetch-depth: 0 - persist-credentials: false - - name: Install the pinned Rust toolchain - run: | - . .github/lexlean-ci/lib.sh - gate "install Rust" install_rust - - name: Restore the registry - uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 - with: - path: | - ~/.cargo/registry/index - ~/.cargo/registry/cache - ~/.cargo/git/db - key: registry-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} - restore-keys: registry-${{ runner.os }}- - - name: 1a. cargo fmt - run: | - . .github/lexlean-ci/lib.sh - gate "cargo fmt" cargo fmt --all -- --check - - name: 1b. cargo clippy - run: | - . .github/lexlean-ci/lib.sh - gate "cargo clippy" cargo clippy --workspace --all-targets --locked -- -D warnings - - name: 1c. every optional feature compiles - run: | - . .github/lexlean-ci/lib.sh - gate "cargo check --all-features" cargo check --workspace --all-features --all-targets --locked - - name: 2a. check-model (R1) - run: | - . .github/lexlean-ci/lib.sh - gate "xtask check-model" cargo xtask check-model - - name: 2b. audit-limits (R5) - run: | - . .github/lexlean-ci/lib.sh - gate "xtask audit-limits" cargo xtask audit-limits - - name: 2c. audit-deferral (R4) - run: | - . .github/lexlean-ci/lib.sh - gate "xtask audit-deferral" cargo xtask audit-deferral - - name: 2d. audit-dependency-updates - run: | - . .github/lexlean-ci/lib.sh - gate "xtask audit-dependency-updates" cargo xtask audit-dependency-updates - - name: 3a. Install cargo-deny - run: | - . .github/lexlean-ci/lib.sh - gate "install cargo-deny" install_cargo_deny - - name: 3b. cargo deny (R6) - run: | - . .github/lexlean-ci/lib.sh - gate "cargo deny" cargo deny --all-features check - - name: 6. cargo test, as the SDK gate runs it (no installed conformance suite) - run: | - . .github/lexlean-ci/lib.sh - gate "cargo test" env -u MCP_CONFORMANCE_SUITE_ROOT cargo test --workspace --locked --no-fail-fast - lexlean: name: lexlean / ${{ matrix.label }} needs: prepare diff --git a/.github/workflows/template-update.yml b/.github/workflows/template-update.yml index b79e1ea..095dd2a 100644 --- a/.github/workflows/template-update.yml +++ b/.github/workflows/template-update.yml @@ -92,21 +92,46 @@ jobs: "$SDK_IMAGE" \ /template-policy/bootstrap/render.mjs "$SDK_IMAGE" "$ACTION_REFERENCE" "$TEMPLATE_REVISION" /sdk-platforms rm -r -- .template-policy + # The template check regenerates CONFORMANCE.md with the project's own + # xtask, which compiles every crate it locks. The SDK's Cargo home holds + # only the SDK's crates, so the locked crates are fetched first, by a + # step that runs no project code, and the check then runs offline. + cargo_home=$(mktemp -d) docker run --rm \ + --user "$(id -u):$(id -g)" \ + --cap-drop ALL \ + --security-opt no-new-privileges \ + --volume "$PWD:/workspace:ro" \ + --volume "$cargo_home:/cargo-home" \ + --env CARGO_HOME=/cargo-home \ + --workdir /workspace \ + --entrypoint cargo \ + "$SDK_IMAGE" \ + fetch --locked + if ! docker run --rm \ --user "$(id -u):$(id -g)" \ --network none \ --cap-drop ALL \ --security-opt no-new-privileges \ --volume "$PWD:/workspace" \ + --volume "$cargo_home:/cargo-home" \ + --env CARGO_HOME=/cargo-home \ + --env CARGO_NET_OFFLINE=true \ --workdir /workspace \ "$SDK_IMAGE" \ - prismpm --json template check >/tmp/template-check.json + prismpm --json template check >/tmp/template-check.json; then + cat /tmp/template-check.json >&2 + exit 1 + fi update=$(docker run --rm \ --user "$(id -u):$(id -g)" \ --network none \ --cap-drop ALL \ --security-opt no-new-privileges \ --volume "$PWD:/workspace" \ + --volume "$cargo_home:/cargo-home" \ + --env CARGO_HOME=/cargo-home \ + --env CARGO_NET_OFFLINE=true \ --workdir /workspace \ "$SDK_IMAGE" \ prismpm --json template update --sdk-image "$SDK_IMAGE" --template-revision "$TEMPLATE_REVISION") @@ -130,6 +155,7 @@ jobs: name: template-update-proposal if-no-files-found: error path: .template-update.patch + include-hidden-files: true retention-days: 1 open-pull-request: diff --git a/Justfile b/Justfile index 503dd18..d87c840 100644 --- a/Justfile +++ b/Justfile @@ -2,25 +2,24 @@ default: vv -# The whole gate. -vv: template-check fmt-check model lint test features bdd deny +# The whole gate. Each check runs once, the cheapest failure first. +vv: fmt-check model template-check lint test deny @echo "vv: the acceptance gate passed" -# R1, R4, R5 --- the repository gates, each falsifiable. +# R1, R4, R5, the bootstrap trust root and dependency ownership: every +# repository gate, each falsifiable, in one `xtask validate`. model: - cargo run -q -p xtask -- validate + cargo run -q --locked -p xtask -- validate -# The hand-reviewed trust root is checked independently of generated project -# content. PrismPM then validates the canonical contract and both locks. +# The SDK's own checks of the canonical contract and both locks. The +# repository gates they complement already ran in `model`. template-check: - cargo run -q -p xtask -- check-model - cargo run -q -p xtask -- audit-bootstrap prismpm template check prismpm lock check # Regenerate everything the model owns: CONFORMANCE.md. model-write: - cargo run -q -p xtask -- check-model --write + cargo run -q --locked -p xtask -- check-model --write fmt: cargo fmt --all @@ -28,25 +27,21 @@ fmt: fmt-check: cargo fmt --all -- --check +# A feature only its author has built is a feature that does not work, so +# Clippy compiles and lints every target at every optional feature: a rename +# upstream of an optional dependency, or a test behind a flag, fails here. lint: - cargo clippy --workspace --all-targets -- -D warnings + cargo clippy --workspace --all-targets --all-features --locked -- -D warnings +# The workspace suite at its default features, including the R3 meta-gate. test: - cargo test --workspace + cargo test --workspace --locked -# A feature only its author has built is a feature that does not work: nothing -# else in the gate compiles a crate at anything but its default features, so a -# rename upstream of an optional dependency fails nowhere until someone turns -# the flag on. `--all-targets` because the tests behind a flag are code too. -# -# Every optional feature compiles, with its tests. -features: - cargo check --workspace --all-features --all-targets - -# R3: every capability begins as a Gherkin scenario, and every scenario has a -# test whose name ends in its ID. +# R3 alone, while a scenario is being written: every capability begins as a +# Gherkin scenario, and every scenario has a test whose name ends in its ID. +# `test` already runs it, so it is not part of `vv`. bdd: - cargo test -p repo-conformance + cargo test --locked -p repo-conformance # R6: nothing shipped depends on a dev-only crate, no wildcard version # requirement, no advisory against anything in the tree. `cargo-deny` is diff --git a/crates/lifecycle-oracle/tests/conformance.rs b/crates/lifecycle-oracle/tests/conformance.rs index f206a7e..b86ad43 100644 --- a/crates/lifecycle-oracle/tests/conformance.rs +++ b/crates/lifecycle-oracle/tests/conformance.rs @@ -783,9 +783,20 @@ fn the_workspace_gate_needs_neither_node_nor_the_suite_and_the_job_runs_the_rest ci.contains("run_oracle_tests"), "a job runs the oracle tests" ); - // The cargo job is the workspace gate: it installs no suite and sets no root. - let cargo_job = &ci[ci.find(" cargo:").expect("the cargo job") - ..ci.find(" lexlean:").expect("the lexlean job")]; - assert!(!cargo_job.contains("install_suite")); - assert!(!cargo_job.contains("run_oracle_tests")); + // The workspace gate is `just test`, which `just vv` runs in the SDK: it + // installs no suite, sets no root and runs no oracle test. + let justfile = read("Justfile"); + let recipe = &justfile[justfile.find("\ntest:\n").expect("the test recipe") + 1..]; + let recipe = &recipe[..recipe.find("\n\n").unwrap_or(recipe.len())]; + assert!(recipe.contains("cargo test --workspace"), "{recipe}"); + for forbidden in [ + "install_suite", + "run_oracle_tests", + concat!("MCP_CONFORMANCE_", "SUITE_ROOT"), + ] { + assert!( + !recipe.contains(forbidden), + "the workspace gate uses {forbidden}" + ); + } } diff --git a/template.lock b/template.lock index 47a79cb..17c9fef 100644 --- a/template.lock +++ b/template.lock @@ -1 +1 @@ -{"contract_digest":"sha256:67a3292cfe6e6400bc18718b6a62e8741dec8d6d6b062cb0e4077fc8d9b616f5","policy_files":[{"path":".devcontainer/devcontainer.json","sha256":"sha256:450b0d0746452006563dc5beca189723d7c0e62d2d17254bf76518396a7429db"},{"path":".github/workflows/bootstrap.yml","sha256":"sha256:58274ed8eba76982133f7e970399e9063622d8aef4c5385bef3b920fe48ee58d"},{"path":"AGENTS.md","sha256":"sha256:9a1fe3f73ab2963812c35976909c331292e1ca39ce47c0711ec1aafe8b869d87"},{"path":"VERIFICATION.md","sha256":"sha256:0912821fea354276fff5faa2b6b6ded0cdf4ef86112ad035b41a0a7a0513bd21"},{"path":"prismpm.lock","sha256":"sha256:0fd71cd4c109151f37c7a2e9a5010dd3806771f7d1815c4d7c7292fb24bd3fa2"},{"path":"template-contract.json","sha256":"sha256:67a3292cfe6e6400bc18718b6a62e8741dec8d6d6b062cb0e4077fc8d9b616f5"}],"policy_tree_sha256":"sha256:0181e17e31cc4d68f425d4d7ca1ce62e962ade84490ba2910cd38af41bcf2a02","schema":"uor/template-lock/1","sdk_image":"ghcr.io/uor-foundation/prismpm-sdk-candidate@sha256:36da25ef924d84899453f24ec0c117a7a220e708037933eb8b499caa7723d99e","template_repository":"https://github.com/UOR-Foundation/template","template_revision":"1bea460bac6ea50bae53a7eeb674589d7900e6cb"} \ No newline at end of file +{"contract_digest":"sha256:67a3292cfe6e6400bc18718b6a62e8741dec8d6d6b062cb0e4077fc8d9b616f5","policy_files":[{"path":".devcontainer/devcontainer.json","sha256":"sha256:450b0d0746452006563dc5beca189723d7c0e62d2d17254bf76518396a7429db"},{"path":".github/workflows/bootstrap.yml","sha256":"sha256:4461275d96f70e6feda725f2226a35c5a96416300801bc82dc954e02386a7bdd"},{"path":"AGENTS.md","sha256":"sha256:9a1fe3f73ab2963812c35976909c331292e1ca39ce47c0711ec1aafe8b869d87"},{"path":"VERIFICATION.md","sha256":"sha256:0912821fea354276fff5faa2b6b6ded0cdf4ef86112ad035b41a0a7a0513bd21"},{"path":"prismpm.lock","sha256":"sha256:0fd71cd4c109151f37c7a2e9a5010dd3806771f7d1815c4d7c7292fb24bd3fa2"},{"path":"template-contract.json","sha256":"sha256:67a3292cfe6e6400bc18718b6a62e8741dec8d6d6b062cb0e4077fc8d9b616f5"}],"policy_tree_sha256":"sha256:448bb267e09afc9881e738303035cdbfa398b228552cce1c844ca7849ac76613","schema":"uor/template-lock/1","sdk_image":"ghcr.io/uor-foundation/prismpm-sdk-candidate@sha256:36da25ef924d84899453f24ec0c117a7a220e708037933eb8b499caa7723d99e","template_repository":"https://github.com/UOR-Foundation/template","template_revision":"8ebc1319702889d158de370735b926734323a5a4"} \ No newline at end of file