diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b9cf922..bd9347b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -213,6 +213,19 @@ jobs: linux="FAIL" fi python3 tools/ci/release_evidence.py --target-sha "$TARGET_SHA" --out "docs/evidence/ci/$TARGET_SHA/manifest.json" --gate "linux=$linux:$TARGET_SHA:$RUN_URL" --gate "windows=$portable:$TARGET_SHA:$RUN_URL" --gate "macos=$portable:$TARGET_SHA:$RUN_URL" --gate "strict_vm=UNVERIFIED::${{ github.server_url }}/${{ github.repository }}/actions/workflows/security-linux.yml" --gate "performance=UNVERIFIED::" + - name: Validate external-extension evidence when committed + shell: bash + env: + TARGET_SHA: ${{ github.sha }} + run: | + set -euo pipefail + manifest="docs/evidence/extension/$TARGET_SHA/manifest.json" + if [ -f "$manifest" ]; then + python3 tools/ci/verify_extension_contracts.py --validate "$manifest" + else + echo "UNVERIFIED: no external-extension manifest for $TARGET_SHA." + echo "Release requires tools/ci/verify_extension_contracts.py on the tagged SHA (docs/releasing.md §7)." + fi - name: Upload release manifest uses: actions/upload-artifact@v4 with: @@ -237,8 +250,10 @@ jobs: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - uses: Swatinem/rust-cache@v2 - - name: Build release binary - run: cargo build --release --locked -p marqdo-cli + - name: Build release binaries + run: | + cargo build --release --locked -p marqdo-cli -p marqdo-provider-worker + test -x target/release/marqdo-provider-worker - name: Package and checksum shell: bash run: | @@ -247,6 +262,9 @@ jobs: stage="dist/marqdo-${version}-${{ matrix.target }}" mkdir -p "$stage" install -m 0755 target/release/marqdo "$stage/" + # The provider worker is required for provider.json v2 and must be a + # sibling of the marqdo executable (no PATH fallback). + install -m 0755 target/release/marqdo-provider-worker "$stage/" cp LICENSE-MIT LICENSE-APACHE CHANGELOG.md COMPATIBILITY.md README.md "$stage/" cp -r spec examples "$stage/" mkdir -p "$stage/tests" @@ -273,6 +291,7 @@ jobs: cd marqdo-* ./marqdo --version ./marqdo --help >/dev/null + test -x ./marqdo-provider-worker ./marqdo check examples/multi-module/index.mq.md --refs --emit analysis.json ./marqdo run examples/hello.mq.md ./marqdo run examples/multi-module/index.mq.md --trace-file trace.json diff --git a/.woodpecker/main.yml b/.woodpecker/main.yml index 2d5681e..c90eb3a 100644 --- a/.woodpecker/main.yml +++ b/.woodpecker/main.yml @@ -15,14 +15,24 @@ steps: - apt-get install -y --no-install-recommends nodejs - cargo fmt --all -- --check - cargo clippy --workspace --all-targets -- -D warnings + # The provider CLI tests resolve a real provider worker next to the CLI + # binary. Build it once so the test harness does not need a nested build. + - cargo build --locked -p marqdo-provider-worker - cargo test --workspace --locked - cargo test -p marqdo-cli --test docs_consistency - cargo test -p marqdo-cli --test architecture_boundaries - python3 -m unittest discover -s tools/ci -p "test_*.py" - cargo test -p marqdo-cli --test stdlib_product + # Windows compile gate: runtime lanes are native on GitHub; this catches + # cfg/compile regressions on the Linux CI without a Windows runner. + - rustup target add x86_64-pc-windows-gnu + - cargo check --workspace --all-targets --target x86_64-pc-windows-gnu build: image: rust:1.100-bookworm depends_on: [test] commands: - - cargo build --release --locked -p marqdo-cli + # Release archives must ship both binaries: the provider worker is the + # only supported transport and resolution is a sibling-of-CLI lookup. + - cargo build --release --locked -p marqdo-cli -p marqdo-provider-worker + - test -x target/release/marqdo-provider-worker diff --git a/docs/ci.md b/docs/ci.md index 65be162..185c5cc 100644 --- a/docs/ci.md +++ b/docs/ci.md @@ -57,6 +57,25 @@ syntax; Debian bookworm's Node 18 fails those tests. `release-evidence` job produces a SHA-bound manifest artifact; it does not tag or upload a release. +## RFC-EXT-0001 CI/CD additions + +* The Woodpecker **test** lane builds `marqdo-provider-worker` before the + workspace tests so the provider CLI tests use the real helper, and adds a + `cargo check --workspace --all-targets --target x86_64-pc-windows-gnu` + compile gate (native Windows/macOS runtime lanes stay on the GitHub matrix). +* The Woodpecker **build** lane and the GitHub **release-candidate** lane build + `marqdo` **and** `marqdo-provider-worker` and package both as siblings; the + provider transport resolves only that sibling (no PATH fallback), so an + archive without it would silently lose provider support. +* `tools/ci/test_verify_extension_contracts.py` covers the external-extension + evidence validator in the existing `python3 -m unittest discover -s tools/ci` + step. +* The release-evidence job validates + `docs/evidence/extension//manifest.json` when it is committed for the + target SHA and prints `UNVERIFIED` otherwise; generating it is the mandatory + release action described in `docs/releasing.md` §7, not a substitute for + G3/G4/native lanes. + ## Local reproduction ```bash diff --git a/tools/ci/test_verify_extension_contracts.py b/tools/ci/test_verify_extension_contracts.py new file mode 100644 index 0000000..d475a2f --- /dev/null +++ b/tools/ci/test_verify_extension_contracts.py @@ -0,0 +1,81 @@ +#!/usr/bin/env python3 +"""Unit tests for the external-extension evidence validator (RFC-EXT-0001 §11.3).""" + +import json +import unittest + +import verify_extension_contracts as evidence + + +def valid_manifest() -> dict: + return { + "schema": "marqdo.extension-evidence", + "schema_version": 1, + "tested_sha": "a" * 40, + "cli_binary_sha256": "b" * 64, + "fixture_repo_sha": "c" * 40, + "os": "linux", + "arch": "x86_64", + "results": { + name: "PASS" for name in evidence.REQUIRED_RESULTS + }, + "commands": ["python3 tests/run_all.py"], + "failures": [], + "unverified": [], + } + + +class ValidateManifestTests(unittest.TestCase): + def test_valid_manifest_has_no_problems(self) -> None: + self.assertEqual(evidence.validate_manifest(valid_manifest()), []) + + def test_missing_result_is_rejected(self) -> None: + manifest = valid_manifest() + del manifest["results"]["resource_provider_cli"] + problems = evidence.validate_manifest(manifest) + self.assertTrue(any("resource_provider_cli" in item for item in problems), problems) + + def test_fail_result_is_rejected(self) -> None: + manifest = valid_manifest() + manifest["results"]["plugin_worker"] = "FAIL" + problems = evidence.validate_manifest(manifest) + self.assertTrue(any("plugin_worker" in item for item in problems), problems) + + def test_unknown_result_key_is_rejected(self) -> None: + manifest = valid_manifest() + manifest["results"]["surprise"] = "PASS" + problems = evidence.validate_manifest(manifest) + self.assertTrue(any("surprise" in item for item in problems), problems) + + def test_short_sha_is_rejected(self) -> None: + manifest = valid_manifest() + manifest["tested_sha"] = "deadbeef" + problems = evidence.validate_manifest(manifest) + self.assertTrue(any("tested_sha" in item for item in problems), problems) + + def test_wrong_schema_version_is_rejected(self) -> None: + manifest = valid_manifest() + manifest["schema_version"] = 2 + problems = evidence.validate_manifest(manifest) + self.assertTrue(any("schema_version" in item for item in problems), problems) + + def test_empty_commands_is_rejected(self) -> None: + manifest = valid_manifest() + manifest["commands"] = [] + problems = evidence.validate_manifest(manifest) + self.assertTrue(any("commands" in item for item in problems), problems) + + def test_documented_schema_is_valid_json(self) -> None: + schema_path = ( + evidence.REPO + / "docs" + / "evidence" + / "extension" + / "schema.json" + ) + schema = json.loads(schema_path.read_text(encoding="utf-8")) + self.assertEqual(schema["properties"]["schema"]["const"], "marqdo.extension-evidence") + + +if __name__ == "__main__": + unittest.main()