Skip to content

PhotoCraft: An open-source, photo editor written by scratch in pure Rust

CI: check the lockfile as Cargo reads it, and pin the release checkout

aiongg82a7cfa3c540
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 07f54982a..c1ea76222 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -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 }}
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 4666f5a85..99028d8a3 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -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