ci: align release tooling with the upstream deterministic pipeline
- add tools/release/package.py: sorted, commit-timestamped, uid/gid-normalised deterministic archive; refuses dirty trees, source-SHA mismatch and stale versions; emits SOURCE_SHA, FILES.sha256 and RELEASE_INFO.json with binaries, protocol revisions, core baseline and manifest digest - add tools/release/smoke.py: verifies checksum/manifest/source/version then cold-installs the archive through a real core CLI into an isolated MARQDO_TOOL_HOME and exercises help/compile/query/check/remove, writing smoke evidence - add tools/ci/test_release_metadata.py: single CI gate for version/fact consistency across Cargo files, tool.json, spec, CHANGELOG, release notes, README and CI configuration - Woodpecker and GitHub pipelines now run the metadata gate and use the Python packager/smoke test in the tag-only release lane; shell release scripts are thin wrappers; docs/ci.md and docs/releasing.md document gates and non-gates
This commit is contained in:
1 parent
85458c1d93
commit
835f61dc01
13 files changed
+663
-122
No files matched your search
@@ -23,6 +23,7 @@ cd "$ROOT"
|
||||
|
||||
lane_test() {
|
||||
echo "== lane: test =="
|
||||
python3 tools/ci/test_release_metadata.py
|
||||
"$CARGO" fmt --all -- --check
|
||||
"$CARGO" clippy --all-targets --locked -- -D warnings
|
||||
"$CARGO" test --workspace --locked
|
||||
|
||||
+11
-57
@@ -1,62 +1,16 @@
|
||||
#!/bin/sh
|
||||
# Build a reproducible release archive from the exact current commit.
|
||||
# Thin wrapper around the deterministic Python packager.
|
||||
#
|
||||
# Refuses a dirty tree (unless ALLOW_DIRTY=1), records SOURCE_SHA and
|
||||
# RELEASE_INFO.json inside the bundle, and emits a sha256 checksum. CI sets
|
||||
# SOURCE_SHA=CI_COMMIT_SHA; the value must match HEAD or packaging fails.
|
||||
# SOURCE_SHA=<40-hex> scripts/package-release.sh [--out-dir dist]
|
||||
#
|
||||
# Requires a clean tree matching HEAD, a locked release build in
|
||||
# target/release/marqdo-knowledge and the version declared in Cargo.toml.
|
||||
set -eu
|
||||
ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
|
||||
VERSION=$(sed -n 's/^version = "\(.*\)"/\1/p' "$ROOT/Cargo.toml" | head -1)
|
||||
TARGET=${TARGET:-x86_64-unknown-linux-gnu}
|
||||
SPEC_SHA=${SOURCE_SHA:-$(git -C "$ROOT" rev-parse HEAD)}
|
||||
HEAD_SHA=$(git -C "$ROOT" rev-parse HEAD)
|
||||
DIRTY=$(git -C "$ROOT" status --porcelain)
|
||||
|
||||
if [ "${ALLOW_DIRTY:-0}" != "1" ] && [ -n "$DIRTY" ]; then
|
||||
echo "package-release: working tree is dirty; commit or pass ALLOW_DIRTY=1" >&2
|
||||
exit 2
|
||||
fi
|
||||
if [ "$SPEC_SHA" != "$HEAD_SHA" ]; then
|
||||
echo "package-release: SOURCE_SHA $SPEC_SHA does not match HEAD $HEAD_SHA" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
"$ROOT/scripts/cargo.sh" build --release --locked
|
||||
|
||||
DIST="$ROOT/dist/marqdo-knowledge-$VERSION-$TARGET"
|
||||
rm -rf "$DIST"
|
||||
mkdir -p "$DIST/bin" "$DIST/docs" "$DIST/spec" "$DIST/docs/releases"
|
||||
cp "$ROOT/target/release/marqdo-knowledge" "$DIST/bin/marqdo-knowledge"
|
||||
chmod 755 "$DIST/bin/marqdo-knowledge"
|
||||
cp "$ROOT/packaging/tool.json" "$DIST/tool.json"
|
||||
cp "$ROOT/README.md" "$ROOT/CHANGELOG.md" "$ROOT/LICENSE-APACHE" "$DIST/"
|
||||
cp "$ROOT/docs/STATUS.md" "$DIST/docs/"
|
||||
cp -r "$ROOT/docs/architecture" "$DIST/docs/"
|
||||
cp -r "$ROOT/docs/releases/." "$DIST/docs/releases/"
|
||||
cp "$ROOT/spec/knowledge.md" "$DIST/spec/"
|
||||
printf '%s\n' "$SPEC_SHA" > "$DIST/SOURCE_SHA"
|
||||
cat > "$DIST/RELEASE_INFO.json" <<JSON
|
||||
{
|
||||
"schema": "marqdo.knowledge.release",
|
||||
"schema_version": 1,
|
||||
"tool": "marqdo-knowledge",
|
||||
"version": "$VERSION",
|
||||
"channel": "beta",
|
||||
"source_sha": "$SPEC_SHA",
|
||||
"target": "$TARGET",
|
||||
"tool_api_revision": 1,
|
||||
"analysis_revision": 3,
|
||||
"sqlite_schema_revision": 1,
|
||||
"core_baseline": "cflmy/marqdo-cli@4bbefc92449ee480c8a2c89b0308feb4cda8d0e7 (3.0.0-rc.4)",
|
||||
"rust": "$(rustc --version)",
|
||||
"cargo": "$(cargo --version)",
|
||||
"built_at_utc": "$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
||||
}
|
||||
JSON
|
||||
cp "$DIST/RELEASE_INFO.json" "$ROOT/dist/RELEASE_INFO.json"
|
||||
|
||||
ARCHIVE="$DIST.tar.gz"
|
||||
tar -C "$(dirname "$DIST")" -czf "$ARCHIVE" "$(basename "$DIST")"
|
||||
( cd "$(dirname "$ARCHIVE")" && sha256sum "$(basename "$ARCHIVE")" > "$(basename "$ARCHIVE").sha256" )
|
||||
printf 'archive: %s\n' "$ARCHIVE"
|
||||
cat "$ARCHIVE.sha256"
|
||||
SOURCE_SHA=${SOURCE_SHA:-$(git -C "$ROOT" rev-parse HEAD)}
|
||||
OUT_DIR=${OUT_DIR:-dist}
|
||||
python3 "$ROOT/tools/release/package.py" \
|
||||
--source-sha "$SOURCE_SHA" \
|
||||
--version "$VERSION" \
|
||||
--out-dir "$OUT_DIR"
|
||||
@@ -1,51 +1,13 @@
|
||||
#!/bin/sh
|
||||
# Cold-install the packaged release archive through a real core CLI and run the
|
||||
# documented smoke path: install -> help -> compile -> query -> check -> remove.
|
||||
# Thin wrapper around the cold-install smoke test.
|
||||
#
|
||||
# MARQDO_BIN=/path/to/marqdo scripts/verify-release.sh [ARCHIVE]
|
||||
set -eu
|
||||
ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
|
||||
MARQDO=${MARQDO_BIN:?set MARQDO_BIN to the core marqdo binary}
|
||||
VERSION=$(sed -n 's/^version = "\(.*\)"/\1/p' "$ROOT/Cargo.toml" | head -1)
|
||||
TARGET=${TARGET:-x86_64-unknown-linux-gnu}
|
||||
ARCHIVE="$ROOT/dist/marqdo-knowledge-$VERSION-$TARGET.tar.gz"
|
||||
|
||||
test -f "$ARCHIVE"
|
||||
( cd "$ROOT/dist" && sha256sum -c "$(basename "$ARCHIVE").sha256" )
|
||||
WORK=$(mktemp -d)
|
||||
TOOL_HOME=$(mktemp -d)
|
||||
trap 'rm -rf "$WORK" "$TOOL_HOME"' EXIT
|
||||
tar -xzf "$ARCHIVE" -C "$WORK"
|
||||
PKG="$WORK/marqdo-knowledge-$VERSION-$TARGET"
|
||||
export MARQDO_TOOL_HOME="$TOOL_HOME"
|
||||
|
||||
"$MARQDO" tool install "$PKG"
|
||||
"$MARQDO" tool list | grep -q knowledge
|
||||
"$MARQDO" knowledge --help >/dev/null
|
||||
"$MARQDO" knowledge compile "$ROOT/examples/mixed" --json > "$WORK/compile.json"
|
||||
"$MARQDO" knowledge query '归一化' --root "$ROOT/examples/mixed" --format json > "$WORK/query.json"
|
||||
"$MARQDO" knowledge check "$ROOT/examples/mixed" --json > "$WORK/check.json"
|
||||
python3 - "$WORK" <<'PY'
|
||||
import json, sys
|
||||
work = sys.argv[1]
|
||||
compile_report = json.load(open(f"{work}/compile.json"))
|
||||
query_report = json.load(open(f"{work}/query.json"))
|
||||
check_report = json.load(open(f"{work}/check.json"))
|
||||
assert compile_report["success"] and compile_report["payload"]["documents"] > 0
|
||||
assert query_report["success"] and len(query_report["hits"]) > 0
|
||||
assert check_report["success"] and check_report["payload"]["errors"] == 0
|
||||
assert check_report["payload"]["database"] == "current"
|
||||
print(
|
||||
"smoke: compile documents=%s query_hits=%s database=%s"
|
||||
% (
|
||||
compile_report["payload"]["documents"],
|
||||
len(query_report["hits"]),
|
||||
check_report["payload"]["database"],
|
||||
)
|
||||
)
|
||||
PY
|
||||
"$MARQDO" tool remove knowledge
|
||||
if "$MARQDO" tool list | grep -q knowledge; then
|
||||
echo "verify-release: tool was not removed" >&2
|
||||
exit 1
|
||||
fi
|
||||
printf 'verify-release: ok (v%s, core %s, sha %s)\n' \
|
||||
"$VERSION" "$("$MARQDO" --version)" "$(cat "$PKG/SOURCE_SHA")"
|
||||
ARCHIVE=${1:-"$ROOT/dist/marqdo-knowledge-$VERSION-$TARGET.tar.gz"}
|
||||
MARQDO_BIN="$MARQDO" python3 "$ROOT/tools/release/smoke.py" \
|
||||
--archive "$ARCHIVE" \
|
||||
--evidence-out "$ROOT/dist/smoke-evidence.json"
|
||||
Reference in new issue
Block a user