diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 933011a..98b42a8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -127,9 +127,54 @@ permissions: contents: read jobs: + # Fails fast before any build: git dependencies must come from github.com/storytold, and the + # lock file must not declare source replacement, patches or path overrides that could silently + # swap one. Lives here (not in each app's release.yml) so every craftapp gets the gate at @main. + # Every build job needs `version`, so these builds are gated transitively. + git-sources: + name: Git dependencies come from storytold + runs-on: ubuntu-latest + timeout-minutes: 10 + permissions: + contents: read + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - name: Git dependencies come from storytold + run: | + set -euo pipefail + test -f Cargo.lock || { echo "Cargo.lock is missing"; exit 1; } + # Source replacement, patches and path overrides in cargo config never show up + # in Cargo.lock. Parsed rather than grepped: TOML has many spellings of one key. + # Cargo still reads the legacy .cargo/config. + python3 - <<'PY' + import os, sys, tomllib + for path in (".cargo/config", ".cargo/config.toml"): + if not os.path.exists(path): + continue + config = tomllib.load(open(path, "rb")) + replaced = [name for name, source in config.get("source", {}).items() + if isinstance(source, dict) and "replace-with" in source] + if replaced or "patch" in config or "paths" in config: + print(f"{path} replaces, patches or overrides a source") + sys.exit(1) + PY + # Fails when Cargo.lock is out of date with the manifests. + cargo metadata --locked --format-version 1 > /dev/null + python3 - <<'PY' + import sys, tomllib + lock = tomllib.load(open("Cargo.lock", "rb")) + bad = sorted({p["source"] for p in lock.get("package", []) + if p.get("source", "").startswith("git+") + and not p["source"].startswith("git+https://github.com/storytold/")}) + if bad: + print("Git dependencies outside github.com/storytold:", *bad, sep="\n") + sys.exit(1) + PY + version: timeout-minutes: 10 name: version + needs: git-sources runs-on: ubuntu-latest outputs: version: ${{ steps.v.outputs.version }}