ci: keep the contract lane short and make Bundle materialization idempotent
Woodpecker executes the job commands as one shell script; the inline contract block plus its trailing commands exceeded the runner's command buffer and the last command was truncated mid-argument (the raw log shows the shell received 'python3 tools/c'). Move the lane into tools/ci/contract_lane.sh and keep the CI commands short, preserving every check. CI jobs share one workspace, so a second job saw 'output already exists' from the first fetch. The helper now reuses an output only after verifying it against the pin, builds into a temporary sibling and moves it into place atomically. Refs cflmy/marqdo-cli#11
This commit was merged in pull request #17.
This commit is contained in:
1 parent
72f57beee0
commit
deadf6edee
10 files changed
+31907
-20
No files matched your search
Executable
+21
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
# Fast public-contract lane: the real CLI against the frozen Analysis /
|
||||
# Observation / Tool fixtures, with one explicit verified stdlib Bundle.
|
||||
# Kept as a script so the CI command lines stay short and reviewable.
|
||||
set -eux
|
||||
bundle="${MARQDO_TEST_STDLIB_BUNDLE:?set MARQDO_TEST_STDLIB_BUNDLE}"
|
||||
export MARQDO_STDLIB_DIR="$bundle"
|
||||
bin="./target/debug/marqdo"
|
||||
"$bin" check tests/consumers/fixtures/observation/basic.mq.md --emit /tmp/analysis.json
|
||||
"$bin" run tests/consumers/fixtures/observation/basic.mq.md --output jsonl --observation-file /tmp/observation.json > /tmp/observation.jsonl
|
||||
python3 tests/consumers/analysis_consumer.py /tmp/analysis.json
|
||||
python3 tests/consumers/observation_consumer.py --validate-schema /tmp/observation.jsonl
|
||||
python3 tests/consumers/observation_consumer.py --snapshot --analysis /tmp/analysis.json /tmp/observation.json
|
||||
"$bin" check tests/conformance/semantics/85-nested-loop-control.mq.md --emit /tmp/control-analysis.json
|
||||
"$bin" run tests/conformance/semantics/85-nested-loop-control.mq.md --output jsonl --observation-file /tmp/control-observation.json > /tmp/control-events.jsonl
|
||||
python3 tests/consumers/validate_protocols.py /tmp/control-analysis.json /tmp/control-observation.json examples/tool-unknown-name/tool.json
|
||||
python3 tests/consumers/analysis_consumer.py /tmp/control-analysis.json --require-transfers
|
||||
python3 tests/consumers/observation_consumer.py --snapshot --analysis /tmp/control-analysis.json /tmp/control-observation.json
|
||||
python3 tests/consumers/observation_consumer.py --validate-schema --analysis /tmp/control-analysis.json /tmp/control-events.jsonl
|
||||
python3 tools/ci/verify_observation_stream.py /tmp/control-events.jsonl /tmp/control-observation.json
|
||||
python3 tools/ci/assert_stale_analysis.py /tmp/control-analysis.json /tmp/control-events.jsonl
|
||||
@@ -25,6 +25,7 @@ from __future__ import annotations
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
@@ -109,17 +110,27 @@ def fetch_root(pin: dict, cache: Path) -> Path:
|
||||
|
||||
|
||||
def build_bundle(root: Path, out: Path) -> Path:
|
||||
if out.exists():
|
||||
raise FetchError(f"output already exists: {out}")
|
||||
"""Build the Bundle; an existing output is reused only after verification.
|
||||
|
||||
CI jobs share one workspace, so a parallel or earlier job may already have
|
||||
materialized the same pinned Bundle. The output is built in a temporary
|
||||
sibling and moved into place atomically; a mismatch is rebuilt, never used.
|
||||
"""
|
||||
temp = out.with_name(out.name + ".partial-" + str(os.getpid()))
|
||||
if temp.exists():
|
||||
shutil.rmtree(temp)
|
||||
run(
|
||||
[
|
||||
sys.executable,
|
||||
str(root / "scripts" / "build-stdlib.py"),
|
||||
"--out",
|
||||
str(out),
|
||||
str(temp),
|
||||
],
|
||||
cwd=root,
|
||||
)
|
||||
if out.exists():
|
||||
shutil.rmtree(out)
|
||||
temp.rename(out)
|
||||
return out
|
||||
|
||||
|
||||
@@ -152,6 +163,14 @@ def main(argv: list[str]) -> int:
|
||||
cache = Path(args.cache).resolve()
|
||||
try:
|
||||
pin = load_pin()
|
||||
if out.is_dir():
|
||||
try:
|
||||
verify(pin, out)
|
||||
except (FetchError, OSError, json.JSONDecodeError):
|
||||
pass
|
||||
else:
|
||||
print(out)
|
||||
return 0
|
||||
root = fetch_root(pin, cache)
|
||||
bundle = build_bundle(root, out)
|
||||
verify(pin, bundle)
|
||||
|
||||
Reference in new issue
Block a user