mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-03 06:31:42 +01:00
CI: check the lockfile as Cargo reads it, and pin the release checkout
The git-sources step fails when Cargo.lock is missing or out of date with the manifests, when .cargo/config.toml replaces or patches a source, or when the parsed lockfile has a git source outside github.com/storytold. The release job's checkout is pinned to a commit.
This commit is contained in:
1 parent
37463ae532
commit
82a7cfa3c5
2 files changed
+36
-6
No files matched your search
@@ -52,9 +52,24 @@ jobs:
|
||||
fetch-depth: 0
|
||||
- name: Git dependencies come from storytold
|
||||
run: |
|
||||
if grep -E '^source = "git\+' Cargo.lock | grep -v '"git+https://github.com/storytold/'; then
|
||||
echo "Cargo.lock has a git dependency outside github.com/storytold"; exit 1
|
||||
set -euo pipefail
|
||||
test -f Cargo.lock || { echo "Cargo.lock is missing"; exit 1; }
|
||||
# Source replacement and patches in cargo config never show up in Cargo.lock.
|
||||
if grep -qE '^[[:space:]]*(replace-with|\[patch)' .cargo/config.toml 2>/dev/null; then
|
||||
echo ".cargo/config.toml replaces or patches a source"; exit 1
|
||||
fi
|
||||
# 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
|
||||
- id: pick
|
||||
env:
|
||||
EVENT: ${{ github.event_name }}
|
||||
|
||||
@@ -24,12 +24,27 @@ jobs:
|
||||
permissions:
|
||||
contents: read
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Check Cargo.lock
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
- name: Git dependencies come from storytold
|
||||
run: |
|
||||
if grep -E '^source = "git\+' Cargo.lock | grep -v '"git+https://github.com/storytold/'; then
|
||||
echo "Cargo.lock has a git dependency outside github.com/storytold"; exit 1
|
||||
set -euo pipefail
|
||||
test -f Cargo.lock || { echo "Cargo.lock is missing"; exit 1; }
|
||||
# Source replacement and patches in cargo config never show up in Cargo.lock.
|
||||
if grep -qE '^[[:space:]]*(replace-with|\[patch)' .cargo/config.toml 2>/dev/null; then
|
||||
echo ".cargo/config.toml replaces or patches a source"; exit 1
|
||||
fi
|
||||
# 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
|
||||
|
||||
release:
|
||||
needs: git-sources
|
||||
|
||||
Reference in new issue
Block a user