ci: require pinned external conformance on the Linux release archive
This commit is contained in:
1 parent
995f6026c9
commit
0ded4e245d
6 files changed
+175
-20
No files matched your search
@@ -183,9 +183,33 @@ jobs:
|
|||||||
assert document["code"] == "strict.probe_unavailable", document
|
assert document["code"] == "strict.probe_unavailable", document
|
||||||
PY
|
PY
|
||||||
|
|
||||||
|
frozen-extensions:
|
||||||
|
name: frozen Linux archive and external extensions
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
persist-credentials: false
|
||||||
|
- uses: dtolnay/rust-toolchain@stable
|
||||||
|
- uses: Swatinem/rust-cache@v2
|
||||||
|
- name: Build and check the frozen archive
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
cargo build --release --locked -p marqdo-cli -p marqdo-provider-worker
|
||||||
|
version="$(cargo metadata --no-deps --format-version 1 --offline \
|
||||||
|
| python3 -c 'import json,sys; print(next(p["version"] for p in json.load(sys.stdin)["packages"] if p["name"]=="marqdo-cli"))')"
|
||||||
|
python3 tools/release/package.py --source-sha "$GITHUB_SHA" --version "$version"
|
||||||
|
tools/ci/run_frozen_extensions.sh dist/marqdo-*.tar.gz "$GITHUB_SHA" dist/frozen-extension-evidence.json
|
||||||
|
- uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: frozen-extension-evidence-${{ github.sha }}
|
||||||
|
path: dist/frozen-extension-evidence.json
|
||||||
|
if-no-files-found: error
|
||||||
|
|
||||||
release-evidence:
|
release-evidence:
|
||||||
name: release evidence manifest
|
name: release evidence manifest
|
||||||
needs: [test, schema, cross-platform]
|
needs: [test, schema, cross-platform, frozen-extensions]
|
||||||
if: always()
|
if: always()
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
@@ -197,6 +221,7 @@ jobs:
|
|||||||
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
||||||
LINUX_RESULT: ${{ needs.test.result }}
|
LINUX_RESULT: ${{ needs.test.result }}
|
||||||
SCHEMA_RESULT: ${{ needs.schema.result }}
|
SCHEMA_RESULT: ${{ needs.schema.result }}
|
||||||
|
EXTENSIONS_RESULT: ${{ needs.frozen-extensions.result }}
|
||||||
PORTABLE_RESULT: ${{ needs.cross-platform.result }}
|
PORTABLE_RESULT: ${{ needs.cross-platform.result }}
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
@@ -209,7 +234,7 @@ jobs:
|
|||||||
}
|
}
|
||||||
linux="$(state "$LINUX_RESULT")"
|
linux="$(state "$LINUX_RESULT")"
|
||||||
portable="$(state "$PORTABLE_RESULT")"
|
portable="$(state "$PORTABLE_RESULT")"
|
||||||
if [ "$(state "$SCHEMA_RESULT")" != "PASS" ]; then
|
if [ "$(state "$SCHEMA_RESULT")" != "PASS" ] || [ "$(state "$EXTENSIONS_RESULT")" != "PASS" ]; then
|
||||||
linux="FAIL"
|
linux="FAIL"
|
||||||
fi
|
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::"
|
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::"
|
||||||
@@ -235,7 +260,7 @@ jobs:
|
|||||||
|
|
||||||
release-candidate:
|
release-candidate:
|
||||||
name: release candidate artifact (${{ matrix.os }})
|
name: release candidate artifact (${{ matrix.os }})
|
||||||
needs: [test, schema, cross-platform]
|
needs: [test, schema, cross-platform, frozen-extensions]
|
||||||
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch'
|
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch'
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ steps:
|
|||||||
image: rust:1.100-bookworm
|
image: rust:1.100-bookworm
|
||||||
depends_on: [test]
|
depends_on: [test]
|
||||||
commands:
|
commands:
|
||||||
|
- apt-get update
|
||||||
|
- apt-get install -y --no-install-recommends ca-certificates git openssl python3 build-essential
|
||||||
# Release archives must ship both binaries: the provider worker is the
|
# Release archives must ship both binaries: the provider worker is the
|
||||||
# only supported transport and resolution is a sibling-of-CLI lookup.
|
# only supported transport and resolution is a sibling-of-CLI lookup.
|
||||||
- cargo build --release --locked -p marqdo-cli -p marqdo-provider-worker
|
- cargo build --release --locked -p marqdo-cli -p marqdo-provider-worker
|
||||||
@@ -48,3 +50,5 @@ steps:
|
|||||||
| python3 -c 'import json,sys; print(next(p["version"] for p in json.load(sys.stdin)["packages"] if p["name"]=="marqdo-cli"))')"
|
| python3 -c 'import json,sys; print(next(p["version"] for p in json.load(sys.stdin)["packages"] if p["name"]=="marqdo-cli"))')"
|
||||||
python3 tools/release/package.py --source-sha "$CI_COMMIT_SHA" --version "$version"
|
python3 tools/release/package.py --source-sha "$CI_COMMIT_SHA" --version "$version"
|
||||||
python3 tools/release/smoke.py --archive dist/marqdo-*.tar.gz
|
python3 tools/release/smoke.py --archive dist/marqdo-*.tar.gz
|
||||||
|
tools/ci/run_frozen_extensions.sh dist/marqdo-*.tar.gz "$CI_COMMIT_SHA" dist/frozen-extension-evidence.json
|
||||||
|
cat dist/frozen-extension-evidence.json
|
||||||
@@ -30,6 +30,15 @@
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"pattern": "^[0-9a-f]{64}$"
|
"pattern": "^[0-9a-f]{64}$"
|
||||||
},
|
},
|
||||||
|
"provider_worker_sha256": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^[0-9a-f]{64}$"
|
||||||
|
},
|
||||||
|
"reference_applications": {
|
||||||
|
"type": "object",
|
||||||
|
"minProperties": 1,
|
||||||
|
"additionalProperties": { "const": "PASS" }
|
||||||
|
},
|
||||||
"fixture_repo_sha": {
|
"fixture_repo_sha": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"pattern": "^[0-9a-f]{40}$"
|
"pattern": "^[0-9a-f]{40}$"
|
||||||
|
|||||||
Executable
+38
@@ -0,0 +1,38 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Run the mandatory Linux lane with only the installed archive and pinned fixtures.
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
if [[ $# != 3 ]]; then
|
||||||
|
echo "usage: $0 ARCHIVE SOURCE_SHA OUTPUT_MANIFEST" >&2
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
archive="$1"
|
||||||
|
source_sha="$2"
|
||||||
|
manifest="$3"
|
||||||
|
root="$(cd "$(dirname "$0")/../.." && pwd)"
|
||||||
|
fixture_remote=https://git.cflmy.cn/cflmy/marqdo-extension-conformance.git
|
||||||
|
fixture_sha=cf92e1ae7d22cb4bd1f5609c5fa8daa11e8980ec
|
||||||
|
|
||||||
|
work="$(mktemp -d)"
|
||||||
|
trap 'rm -rf -- "$work"' EXIT
|
||||||
|
git init -q "$work/fixtures"
|
||||||
|
git -C "$work/fixtures" fetch --no-tags --depth=1 "$fixture_remote" "$fixture_sha"
|
||||||
|
git -C "$work/fixtures" checkout -q --detach "$fixture_sha"
|
||||||
|
|
||||||
|
mkdir "$work/install"
|
||||||
|
tar -xzf "$archive" -C "$work/install"
|
||||||
|
installations=("$work"/install/*)
|
||||||
|
if [[ ${#installations[@]} != 1 || ! -d "${installations[0]}" ]]; then
|
||||||
|
echo "expected one installation directory in the release archive" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
install="${installations[0]}"
|
||||||
|
test "$(cat "$install/SOURCE_SHA")" = "$source_sha"
|
||||||
|
test -x "$install/marqdo"
|
||||||
|
test -x "$install/marqdo-provider-worker"
|
||||||
|
|
||||||
|
python3 "$root/tools/ci/verify_extension_contracts.py" \
|
||||||
|
--source-repo "$root" --tested-sha "$source_sha" \
|
||||||
|
--cli "$install/marqdo" --release-info "$install/RELEASE_INFO.json" \
|
||||||
|
--fixtures "$work/fixtures" --out "$manifest"
|
||||||
@@ -65,6 +65,24 @@ class ValidateManifestTests(unittest.TestCase):
|
|||||||
problems = evidence.validate_manifest(manifest)
|
problems = evidence.validate_manifest(manifest)
|
||||||
self.assertTrue(any("commands" in item for item in problems), problems)
|
self.assertTrue(any("commands" in item for item in problems), problems)
|
||||||
|
|
||||||
|
def test_reference_failure_is_rejected(self) -> None:
|
||||||
|
manifest = valid_manifest()
|
||||||
|
manifest["reference_applications"] = {"live SSE": "FAIL"}
|
||||||
|
self.assertTrue(evidence.validate_manifest(manifest))
|
||||||
|
manifest["reference_applications"] = {"live SSE": "PASS"}
|
||||||
|
self.assertEqual(evidence.validate_manifest(manifest), [])
|
||||||
|
|
||||||
|
def test_report_identity_must_match_binaries_and_fixture_commit(self) -> None:
|
||||||
|
report = {
|
||||||
|
"schema": "marqdo.ext-fixture-results",
|
||||||
|
"schema_version": 1,
|
||||||
|
"tool_sha": "a" * 40,
|
||||||
|
"cli_binary_sha256": "b" * 64,
|
||||||
|
"provider_worker_sha256": "c" * 64,
|
||||||
|
}
|
||||||
|
self.assertEqual(evidence.verify_report_identity(report, "a" * 40, "b" * 64, "c" * 64), [])
|
||||||
|
self.assertEqual(len(evidence.verify_report_identity(report, "f" * 40, "f" * 64, "f" * 64)), 3)
|
||||||
|
|
||||||
def test_documented_schema_is_valid_json(self) -> None:
|
def test_documented_schema_is_valid_json(self) -> None:
|
||||||
schema_path = (
|
schema_path = (
|
||||||
evidence.REPO
|
evidence.REPO
|
||||||
|
|||||||
@@ -97,6 +97,14 @@ def validate_manifest(manifest: dict) -> list[str]:
|
|||||||
cli = manifest.get("cli_binary_sha256", "")
|
cli = manifest.get("cli_binary_sha256", "")
|
||||||
if not (isinstance(cli, str) and len(cli) == 64 and all(c in "0123456789abcdef" for c in cli)):
|
if not (isinstance(cli, str) and len(cli) == 64 and all(c in "0123456789abcdef" for c in cli)):
|
||||||
problems.append("cli_binary_sha256 must be a 64-character lowercase sha256")
|
problems.append("cli_binary_sha256 must be a 64-character lowercase sha256")
|
||||||
|
if "provider_worker_sha256" in manifest:
|
||||||
|
worker = manifest["provider_worker_sha256"]
|
||||||
|
if not (isinstance(worker, str) and len(worker) == 64 and all(c in "0123456789abcdef" for c in worker)):
|
||||||
|
problems.append("provider_worker_sha256 must be a 64-character lowercase sha256")
|
||||||
|
if "reference_applications" in manifest:
|
||||||
|
references = manifest["reference_applications"]
|
||||||
|
if not isinstance(references, dict) or not references or any(value != "PASS" for value in references.values()):
|
||||||
|
problems.append("reference_applications must be a non-empty object with all cases PASS")
|
||||||
if manifest.get("os") not in {"linux", "macos", "windows"}:
|
if manifest.get("os") not in {"linux", "macos", "windows"}:
|
||||||
problems.append("os must be linux, macos or windows")
|
problems.append("os must be linux, macos or windows")
|
||||||
results = manifest.get("results")
|
results = manifest.get("results")
|
||||||
@@ -125,37 +133,52 @@ def validate_manifest(manifest: dict) -> list[str]:
|
|||||||
|
|
||||||
|
|
||||||
def run_suite(fixtures: Path, cli: Path) -> tuple[bool, dict, list[str]]:
|
def run_suite(fixtures: Path, cli: Path) -> tuple[bool, dict, list[str]]:
|
||||||
"""Run the external suite and return (ok, results, commands)."""
|
"""Run the external suite and return its fresh raw report."""
|
||||||
results: dict[str, str] = {}
|
|
||||||
commands: list[str] = []
|
|
||||||
env = dict(os.environ)
|
env = dict(os.environ)
|
||||||
env["MARQDO_BIN"] = str(cli)
|
env["MARQDO_BIN"] = str(cli)
|
||||||
env["MARQDO_FROZEN_CLI"] = str(cli)
|
env["MARQDO_FROZEN_CLI"] = str(cli)
|
||||||
runner = fixtures / "tests" / "run_all.py"
|
runner = fixtures / "tests" / "run_all.py"
|
||||||
if not runner.is_file():
|
if not runner.is_file():
|
||||||
return False, results, commands
|
return False, {}, []
|
||||||
commands.append(f"python3 {runner} (cwd={fixtures})")
|
commands = [f"python3 {runner} (cwd={fixtures})"]
|
||||||
|
results_path = fixtures / "evidence" / "results.json"
|
||||||
|
results_path.unlink(missing_ok=True)
|
||||||
completed = subprocess.run(
|
completed = subprocess.run(
|
||||||
[sys.executable, str(runner)],
|
[sys.executable, str(runner)],
|
||||||
cwd=fixtures,
|
cwd=fixtures,
|
||||||
env=env,
|
env=env,
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
text=True,
|
text=True,
|
||||||
|
timeout=180,
|
||||||
)
|
)
|
||||||
print(completed.stdout, end="")
|
print(completed.stdout, end="")
|
||||||
print(completed.stderr, end="", file=sys.stderr)
|
print(completed.stderr, end="", file=sys.stderr)
|
||||||
results_path = fixtures / "evidence" / "results.json"
|
payload = json.loads(results_path.read_text(encoding="utf-8")) if results_path.is_file() else {}
|
||||||
if results_path.is_file():
|
return completed.returncode == 0, payload, commands
|
||||||
with results_path.open("r", encoding="utf-8") as handle:
|
|
||||||
payload = json.load(handle)
|
|
||||||
for key, value in (payload.get("results") or {}).items():
|
def verify_report_identity(
|
||||||
results[key] = str(value).upper()
|
payload: dict, fixture_sha: str, cli_hash: str, worker_hash: str | None
|
||||||
return completed.returncode == 0, results, commands
|
) -> list[str]:
|
||||||
|
problems = []
|
||||||
|
if payload.get("schema") != "marqdo.ext-fixture-results" or payload.get("schema_version") != 1:
|
||||||
|
problems.append("external suite did not produce a supported results report")
|
||||||
|
if payload.get("tool_sha") != fixture_sha:
|
||||||
|
problems.append("external report fixture SHA does not match the checked-out commit")
|
||||||
|
if payload.get("cli_binary_sha256") != cli_hash:
|
||||||
|
problems.append("external report CLI hash does not match the tested executable")
|
||||||
|
if "provider_worker_sha256" in payload and payload["provider_worker_sha256"] != worker_hash:
|
||||||
|
problems.append("external report provider worker hash does not match the tested executable")
|
||||||
|
return problems
|
||||||
|
|
||||||
|
|
||||||
def main() -> int:
|
def main() -> int:
|
||||||
parser = argparse.ArgumentParser(description=__doc__)
|
parser = argparse.ArgumentParser(description=__doc__)
|
||||||
parser.add_argument("--cli", type=Path, help="Absolute/relative frozen marqdo binary")
|
parser.add_argument("--cli", type=Path, help="Absolute/relative frozen marqdo binary")
|
||||||
|
parser.add_argument(
|
||||||
|
"--release-info", type=Path,
|
||||||
|
help="Verify the installed archive's source and binary digests and require reference results",
|
||||||
|
)
|
||||||
parser.add_argument("--fixtures", type=Path, help="External fixture repository root")
|
parser.add_argument("--fixtures", type=Path, help="External fixture repository root")
|
||||||
parser.add_argument("--source-repo", type=Path, default=REPO, help="marqdo-cli checkout")
|
parser.add_argument("--source-repo", type=Path, default=REPO, help="marqdo-cli checkout")
|
||||||
parser.add_argument("--out", type=Path, help="Evidence manifest output path")
|
parser.add_argument("--out", type=Path, help="Evidence manifest output path")
|
||||||
@@ -217,6 +240,8 @@ def main() -> int:
|
|||||||
)
|
)
|
||||||
return 2
|
return 2
|
||||||
cli_before = sha256_file(cli)
|
cli_before = sha256_file(cli)
|
||||||
|
worker = cli.with_name("marqdo-provider-worker")
|
||||||
|
worker_before = sha256_file(worker) if worker.is_file() else None
|
||||||
tested_sha = git_sha(source_repo)
|
tested_sha = git_sha(source_repo)
|
||||||
if args.tested_sha and args.tested_sha != tested_sha:
|
if args.tested_sha and args.tested_sha != tested_sha:
|
||||||
print(
|
print(
|
||||||
@@ -224,12 +249,37 @@ def main() -> int:
|
|||||||
file=sys.stderr,
|
file=sys.stderr,
|
||||||
)
|
)
|
||||||
return 2
|
return 2
|
||||||
|
if args.release_info:
|
||||||
|
info = json.loads(args.release_info.read_text(encoding="utf-8"))
|
||||||
|
binaries = info.get("binaries", {})
|
||||||
|
if (
|
||||||
|
info.get("source_sha") != tested_sha
|
||||||
|
or binaries.get("marqdo", {}).get("sha256") != cli_before
|
||||||
|
or worker_before is None
|
||||||
|
or binaries.get(worker.name, {}).get("sha256") != worker_before
|
||||||
|
):
|
||||||
|
print("error: installed archive source or binary digest mismatch", file=sys.stderr)
|
||||||
|
return 1
|
||||||
fixture_sha = git_sha(fixtures)
|
fixture_sha = git_sha(fixtures)
|
||||||
ok, results, commands = run_suite(fixtures, cli)
|
try:
|
||||||
cli_after = sha256_file(cli)
|
ok, payload, commands = run_suite(fixtures, cli)
|
||||||
if cli_before != cli_after:
|
except (ValueError, subprocess.TimeoutExpired) as error:
|
||||||
|
print(f"error: invalid or incomplete external suite report: {error}", file=sys.stderr)
|
||||||
|
return 1
|
||||||
|
if not cli.is_file() or cli_before != sha256_file(cli):
|
||||||
print("error: frozen CLI hash changed during the external suite", file=sys.stderr)
|
print("error: frozen CLI hash changed during the external suite", file=sys.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
if (sha256_file(worker) if worker.is_file() else None) != worker_before:
|
||||||
|
print("error: frozen provider worker hash changed during the external suite", file=sys.stderr)
|
||||||
|
return 1
|
||||||
|
if git_sha(fixtures) != fixture_sha or git_sha(source_repo) != tested_sha:
|
||||||
|
print("error: a checkout changed during the external suite", file=sys.stderr)
|
||||||
|
return 1
|
||||||
|
|
||||||
|
results = payload.get("results", {})
|
||||||
|
if not isinstance(results, dict):
|
||||||
|
print("error: external suite results must be an object", file=sys.stderr)
|
||||||
|
return 1
|
||||||
|
|
||||||
failures = [name for name, value in results.items() if value == "FAIL"]
|
failures = [name for name, value in results.items() if value == "FAIL"]
|
||||||
unverified = [
|
unverified = [
|
||||||
@@ -251,13 +301,24 @@ def main() -> int:
|
|||||||
"failures": failures,
|
"failures": failures,
|
||||||
"unverified": unverified,
|
"unverified": unverified,
|
||||||
}
|
}
|
||||||
|
if worker_before is not None:
|
||||||
|
manifest["provider_worker_sha256"] = worker_before
|
||||||
|
if "reference_applications" in payload:
|
||||||
|
manifest["reference_applications"] = payload["reference_applications"]
|
||||||
problems = validate_manifest(manifest)
|
problems = validate_manifest(manifest)
|
||||||
|
problems.extend(verify_report_identity(payload, fixture_sha, cli_before, worker_before))
|
||||||
|
if args.release_info:
|
||||||
|
if "reference_applications" not in payload:
|
||||||
|
problems.append("frozen archive gate requires reference application results")
|
||||||
|
if "provider_worker_sha256" not in payload:
|
||||||
|
problems.append("frozen archive gate requires the provider worker digest")
|
||||||
|
if missing:
|
||||||
|
problems.append(f"missing external results: {', '.join(missing)}")
|
||||||
if unverified and not args.allow_unverified:
|
if unverified and not args.allow_unverified:
|
||||||
problems.append(
|
problems.append(
|
||||||
"UNSUPPORTED/SKIPPED results require --allow-unverified and an explicit report entry"
|
"UNSUPPORTED/SKIPPED results require --allow-unverified and an explicit report entry"
|
||||||
)
|
)
|
||||||
if not ok and not failures:
|
if not ok:
|
||||||
failures.append("external suite exited non-zero without structured results")
|
|
||||||
problems.append("external suite failed")
|
problems.append("external suite failed")
|
||||||
if problems:
|
if problems:
|
||||||
for problem in problems:
|
for problem in problems:
|
||||||
|
|||||||
Reference in new issue
Block a user