Files
marqdo-cli/.github/workflows/ci.yml
cflmy 72f57beee0
ci/woodpecker/push/main Pipeline failed
ci/woodpecker/pr/main Pipeline failed
refactor: accept the ecosystem stdlib Bundle and remove the in-repo sources
Phase B of ADR-0070 (issue #11): the CLI no longer owns standard-library
sources. The pin names the accepted ecosystem Bundle (marqdo-stdlib@0.2.0,
root commit + tree/alias digests); tools/ci/fetch_ecosystem_bundle.py
materializes it from the pinned root commit and stdlib gitlinks and verifies
the digests. bundle.py and the test harness require an explicit verified Bundle
for the accepted identity, and runtime discovery has no compile-time source
fallback in any profile.

Delete stdlib/ (modules, self-tests, aliases manifest). Module and domain tests
stay with their component owners; the CLI product lane now verifies the
external Bundle's public surface, std: resolution and official print/打印 alias
routing (tests/product-stdlib). Composition assertions whose owner is the
ecosystem (Table split, print-format equivalence) moved to the root Bundle
acceptance; the generic TCP round-trip stays a CLI test. Spawned-CLI tests name
the verified Bundle explicitly.

CI (Woodpecker + GitHub) materializes the pinned Bundle before product tests,
packaging and performance lanes; packaging and release take --stdlib-dir from
that artifact. Docs, STATUS, ADR-0070 and a Phase B evidence record updated.

Refs cflmy/marqdo#9, cflmy/marqdo-cli#11
2026-11-27 01:04:01 +08:00

338 lines
15 KiB
YAML

name: CI
on:
push:
pull_request:
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
jobs:
test:
name: fmt + clippy + test (Linux x86_64)
runs-on: ubuntu-latest
env:
MARQDO_TEST_STDLIB_BUNDLE: ${{ github.workspace }}/target/ecosystem-stdlib
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Rust cache
uses: Swatinem/rust-cache@v2
- name: Materialize the pinned ecosystem stdlib Bundle
run: python3 tools/ci/fetch_ecosystem_bundle.py --out target/ecosystem-stdlib
- name: Verify the pinned stdlib Bundle
run: python3 tools/stdlib/bundle.py --stdlib-dir target/ecosystem-stdlib
- name: Formatting
run: cargo fmt --all -- --check
- name: Clippy
run: cargo clippy --workspace --all-targets -- -D warnings
- name: Tests
shell: bash
run: |
set +e
CARGO_TERM_COLOR=never cargo test --workspace 2>&1 | tee workspace-tests.log
status=${PIPESTATUS[0]}
set -e
if [ "$status" -ne 0 ]; then
python3 tools/ci/annotate_workspace_tests.py \
workspace-tests.log "Linux workspace tests"
fi
exit "$status"
- name: Documentation consistency
run: cargo test -p marqdo-cli --test docs_consistency
- name: Architecture boundaries
run: cargo test -p marqdo-cli --test architecture_boundaries
- name: Dependency-direction gate (Engine / Host Contract / Native Host)
run: python3 tools/ci/check_dependency_boundaries.py
- name: Engine independence and CLI differential execution
run: python3 tools/ci/check_engine_boundary.py
- name: Plugin SDK real consumption
run: python3 tools/ci/check_plugin_sdk.py
- name: CI evidence tool tests
run: python3 -m unittest discover -s tools/ci -p "test_*.py"
- name: Whole stdlib product tests (explicit pinned Bundle)
run: cargo test -p marqdo-cli --test stdlib_product
- name: Validate public JSON schemas
run: |
python3 - <<'PY'
import json, pathlib
for path in pathlib.Path("spec/schemas").glob("*.json"):
json.loads(path.read_text())
print("schemas parse")
PY
- name: Smoke test the CLI, protocols and examples
run: |
cargo build -p marqdo-cli
./target/debug/marqdo check examples/factorial.mq.md
./target/debug/marqdo call examples/factorial.mq.md 阶乘 --arg n=5
./target/debug/marqdo call examples/math.mq.md 计算圆面积
./target/debug/marqdo inspect examples/references.mq.md --refs
./target/debug/marqdo check examples/multi-module/index.mq.md --refs \
--emit /tmp/marqdo-analysis.json
./target/debug/marqdo run examples/multi-module/index.mq.md \
--observation-file /tmp/marqdo-observation.json
python3 tests/consumers/analysis_consumer.py /tmp/marqdo-analysis.json
python3 tests/consumers/observation_consumer.py --snapshot \
/tmp/marqdo-observation.json --analysis /tmp/marqdo-analysis.json
./target/debug/marqdo run examples/hello.mq.md \
--observation-file /tmp/marqdo-hello-observation.json
python3 - <<'PY'
import json
json.load(open("/tmp/marqdo-hello-observation.json"))
print("snapshot parses")
PY
./target/debug/marqdo run examples/packages-multi-version/index.mq.md
./target/debug/marqdo run examples/kernel-mock/demo.mq.md \
--kernel examples/kernel-mock/kernel.json --allow-foreign
export MARQDO_TOOL_HOME="$(mktemp -d)"
./target/debug/marqdo tool install examples/tool-unknown-name/tool.json
./target/debug/marqdo benchmark run .
./target/debug/marqdo tool remove benchmark
./examples/plugin-demo/build.sh
./target/debug/marqdo plugin inspect examples/plugin-demo/build
./target/debug/marqdo run examples/plugin-demo/plugin-call.mq.md \
--plugin examples/plugin-demo/build \
--trust-native-plugin \
--allow-plugin demo.solver
./examples/plugin-multi-export/build.sh
./target/debug/marqdo check examples/plugin-multi-export/plugin-call.mq.md \
--plugin examples/plugin-multi-export/build
./target/debug/marqdo run examples/plugin-multi-export/plugin-call.mq.md \
--plugin examples/plugin-multi-export/build \
--trust-native-plugin \
--allow-plugin demo.solver
independent-build:
name: independent CLI/worker build (no stdlib source)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Build from a copy without stdlib and run a language-only program
run: python3 tools/ci/independent_build.py
schema:
name: schema instance validation + consumers
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Install JSON Schema validator
run: python3 -m pip install --disable-pip-version-check "jsonschema==4.23.0"
- name: Validate real artifacts
run: |
cargo build -p marqdo-cli
./target/debug/marqdo check examples/multi-module/index.mq.md --refs \
--emit /tmp/analysis-simple.json
./target/debug/marqdo run examples/multi-module/index.mq.md \
--observation-file /tmp/observation.json
python3 tests/consumers/validate_protocols.py \
/tmp/analysis-simple.json /tmp/observation.json examples/tool-unknown-name/tool.json
python3 tests/consumers/analysis_consumer.py /tmp/analysis-simple.json
python3 tests/consumers/observation_consumer.py --snapshot \
/tmp/observation.json --analysis /tmp/analysis-simple.json
./target/debug/marqdo check tests/conformance/semantics/85-nested-loop-control.mq.md \
--emit /tmp/analysis-control.json
./target/debug/marqdo 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/analysis-control.json /tmp/control-observation.json examples/tool-unknown-name/tool.json
python3 tests/consumers/analysis_consumer.py /tmp/analysis-control.json --require-transfers
python3 tests/consumers/observation_consumer.py --snapshot /tmp/control-observation.json --analysis /tmp/analysis-control.json
python3 tests/consumers/observation_consumer.py /tmp/control-events.jsonl \
--analysis /tmp/analysis-control.json --validate-schema
python3 - <<'PY'
import json, pathlib
events = [json.loads(line) for line in pathlib.Path("/tmp/control-events.jsonl").read_bytes().splitlines()]
snapshot = json.loads(pathlib.Path("/tmp/control-observation.json").read_bytes())
assert snapshot["events"] == events
PY
cp /tmp/analysis-control.json /tmp/analysis-stale.json
printf ' ' >> /tmp/analysis-stale.json
if python3 tests/consumers/observation_consumer.py /tmp/control-events.jsonl \
--analysis /tmp/analysis-stale.json; then
exit 1
fi
cross-platform:
name: runtime contract (${{ matrix.os }})
strategy:
fail-fast: false
matrix:
os: [windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Host toolchain report
shell: bash
run: |
rustc -vV
(command -v cc && cc --version | head -1) || echo "cc: unavailable"
(command -v python3 && python3 --version) || echo "python3: unavailable"
(command -v node && node --version) || echo "node: unavailable"
- name: Workspace tests
shell: bash
run: |
set +e
CARGO_TERM_COLOR=never cargo test --workspace 2>&1 | tee workspace-tests.log
status=${PIPESTATUS[0]}
set -e
if [ "$status" -ne 0 ]; then
python3 tools/ci/annotate_workspace_tests.py \
workspace-tests.log "Workspace tests on ${{ matrix.os }}"
fi
exit "$status"
- name: Portable CLI, Analysis and Observation smoke
shell: bash
run: |
set -e
cargo run -q -p marqdo-cli -- check examples/multi-module/index.mq.md \
--refs --emit /tmp/marqdo-portable-analysis.json
python3 tests/consumers/analysis_consumer.py /tmp/marqdo-portable-analysis.json
cargo run -q -p marqdo-cli -- run examples/multi-module/index.mq.md \
--observation-file /tmp/marqdo-portable-observation.json
python3 tests/consumers/observation_consumer.py --snapshot \
/tmp/marqdo-portable-observation.json --analysis /tmp/marqdo-portable-analysis.json
- name: Strict isolation is unavailable and must fail closed
shell: bash
run: |
set +e
output=$(cargo run -q -p marqdo-cli -- run examples/hello.mq.md --mode strict 2>&1)
code=$?
set -e
test "$code" -eq 1
echo "$output" | grep -qi "strict"
echo "$output"
- name: Strict JSON refusal is exactly one document
shell: bash
run: |
set -euo pipefail
set +e
json=$(cargo run -q -p marqdo-cli -- run examples/hello.mq.md --mode strict --output json)
code=$?
set -e
test "$code" -eq 1
JSON_DOC="$json" python3 - <<'PY'
import json, os
document = json.loads(os.environ["JSON_DOC"])
assert document["schema"] == "marqdo.observation", document
assert document["run"]["status"] == "rejected", document
assert document["events"][-1]["payload"]["error"]["code"] == "strict.probe_unavailable", document
PY
frozen-extensions:
name: frozen Linux archive and external extensions
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Materialize the pinned ecosystem stdlib Bundle
run: python3 tools/ci/fetch_ecosystem_bundle.py --out target/ecosystem-stdlib
- 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" \
--stdlib-dir target/ecosystem-stdlib --bundle-pin tools/stdlib/bundle-pin.json
python3 tools/release/smoke.py --archive dist/marqdo-*.tar.gz
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
- uses: actions/upload-artifact@v4
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch'
with:
name: frozen-linux-archive-${{ github.sha }}
path: dist/marqdo-*.tar.gz*
if-no-files-found: error
release-evidence:
name: release evidence manifest
needs: [test, schema, cross-platform, frozen-extensions, independent-build]
if: always()
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build SHA-bound manifest
shell: bash
env:
TARGET_SHA: ${{ github.sha }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
LINUX_RESULT: ${{ needs.test.result }}
SCHEMA_RESULT: ${{ needs.schema.result }}
EXTENSIONS_RESULT: ${{ needs.frozen-extensions.result }}
INDEPENDENT_RESULT: ${{ needs.independent-build.result }}
run: |
set -euo pipefail
state() {
case "$1" in
success) echo PASS ;;
failure) echo FAIL ;;
*) echo UNVERIFIED ;;
esac
}
linux="$(state "$LINUX_RESULT")"
if [ "$(state "$SCHEMA_RESULT")" != "PASS" ] || [ "$(state "$EXTENSIONS_RESULT")" != "PASS" ] || [ "$(state "$INDEPENDENT_RESULT")" != "PASS" ]; then
linux="FAIL"
fi
python3 tools/ci/release_evidence.py --profile rc --target-sha "$TARGET_SHA" \
--out "docs/evidence/ci/$TARGET_SHA/manifest.json" \
--gate "linux=$linux:$TARGET_SHA:$RUN_URL" \
--gate "windows=UNSUPPORTED:$TARGET_SHA:linux-only-rc-scope" \
--gate "macos=UNSUPPORTED:$TARGET_SHA:linux-only-rc-scope" \
--gate "extension=$(state "$EXTENSIONS_RESULT"):$TARGET_SHA:$RUN_URL" \
--gate "strict_vm=UNVERIFIED::$RUN_URL" \
--gate "performance=UNVERIFIED::$RUN_URL"
- 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 §8)."
fi
- name: Upload release manifest
uses: actions/upload-artifact@v4
with:
name: release-evidence-${{ github.sha }}
path: docs/evidence/ci/${{ github.sha }}/manifest.json
if-no-files-found: error
release-candidate:
name: archive-only Linux candidate smoke
needs: [test, schema, cross-platform, frozen-extensions]
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/download-artifact@v4
with:
name: frozen-linux-archive-${{ github.sha }}
path: dist
- name: Cold install the checked archive
run: bash tools/release/cold-install.sh dist/marqdo-*.tar.gz "$GITHUB_SHA"