ci: fail when the parity floor falls below the base commit
A test sees one tree; it cannot see that the floor used to be higher. `scripts/parity-floor.sh <base-ref>` reads the floor from `git show <base-ref>:docs/parity.md` and from the working tree and fails if the working tree's number is lower, printing both. A base without a floor line passes and says so, so older refs are not punished. check.yml fetches one extra commit (fetch-depth: 2) and, on a PR, the base branch; the step before `just check` compares against HEAD^1 on a push and origin/<base> on a pull request. The Rust test still runs inside `just check` as part of the workspace's tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
76b64f99c2
commit
6c6ffa9d46
2 files changed
+59
No files matched your search
@@ -21,7 +21,16 @@ jobs:
|
|||||||
CARGO_PROFILE_DEV_DEBUG: line-tables-only
|
CARGO_PROFILE_DEV_DEBUG: line-tables-only
|
||||||
CARGO_PROFILE_TEST_DEBUG: line-tables-only
|
CARGO_PROFILE_TEST_DEBUG: line-tables-only
|
||||||
steps:
|
steps:
|
||||||
|
# The parity floor compares against the commit before this one, so
|
||||||
|
# the checkout needs one more commit than the default.
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 2
|
||||||
|
- name: The base branch, for the parity floor
|
||||||
|
if: github.event_name == 'pull_request'
|
||||||
|
run: |
|
||||||
|
git fetch --no-tags --depth=1 origin \
|
||||||
|
"+refs/heads/${{ github.base_ref }}:refs/remotes/origin/${{ github.base_ref }}"
|
||||||
- name: Room for the build (the image ships toolchains we never use)
|
- name: Room for the build (the image ships toolchains we never use)
|
||||||
run: |
|
run: |
|
||||||
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc \
|
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc \
|
||||||
@@ -30,6 +39,16 @@ jobs:
|
|||||||
- uses: jdx/mise-action@v2
|
- uses: jdx/mise-action@v2
|
||||||
- name: GUI build dependencies
|
- name: GUI build dependencies
|
||||||
run: sudo apt-get update && sudo apt-get install -y libxkbcommon-dev libgtk-3-dev
|
run: sudo apt-get update && sudo apt-get install -y libxkbcommon-dev libgtk-3-dev
|
||||||
|
# docs/parity.md's floor never decreases (AGENTS.md, "Parity
|
||||||
|
# tracking"); a test checks it inside `just check`, this checks the
|
||||||
|
# commit's floor against its base.
|
||||||
|
- name: The parity floor holds
|
||||||
|
run: |
|
||||||
|
if [ "${{ github.event_name }}" = "pull_request" ]; then
|
||||||
|
scripts/parity-floor.sh "origin/${{ github.base_ref }}"
|
||||||
|
else
|
||||||
|
scripts/parity-floor.sh HEAD^1
|
||||||
|
fi
|
||||||
- run: just check
|
- run: just check
|
||||||
- name: What the build used
|
- name: What the build used
|
||||||
if: always()
|
if: always()
|
||||||
|
|||||||
Executable
+40
@@ -0,0 +1,40 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# The parity catalog's floor never decreases (docs/parity.md; AGENTS.md,
|
||||||
|
# "Parity tracking"). `crates/ledger-cli/tests/parity_floor.rs` checks the
|
||||||
|
# floor against the rows in one commit; this checks it against the base
|
||||||
|
# commit, which a test cannot do.
|
||||||
|
#
|
||||||
|
# Usage: scripts/parity-floor.sh <base-ref>
|
||||||
|
# prints both floors; exits 1 when the working tree's floor is lower.
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
base_ref="${1:?usage: scripts/parity-floor.sh <base-ref>}"
|
||||||
|
cd "$(git rev-parse --show-toplevel)"
|
||||||
|
|
||||||
|
floor_of() {
|
||||||
|
# The first `**Floor: N done**` line, or nothing.
|
||||||
|
sed -n 's/^\*\*Floor: \([0-9][0-9]*\) done\*\*.*/\1/p' | head -n 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if ! base_doc=$(git show "${base_ref}:docs/parity.md" 2>/dev/null); then
|
||||||
|
echo "parity floor: cannot read docs/parity.md at ${base_ref}" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
base_floor=$(printf '%s\n' "$base_doc" | floor_of)
|
||||||
|
|
||||||
|
if [ -z "$base_floor" ]; then
|
||||||
|
echo "parity floor: ${base_ref} has no floor line; nothing to compare"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
work_floor=$(floor_of < docs/parity.md)
|
||||||
|
if [ -z "$work_floor" ]; then
|
||||||
|
echo "parity floor: docs/parity.md in the working tree has no floor line" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "parity floor: ${base_ref} says ${base_floor} done; the working tree says ${work_floor} done"
|
||||||
|
if [ "$work_floor" -lt "$base_floor" ]; then
|
||||||
|
echo "parity floor: the floor never decreases (docs/parity.md; AGENTS.md, \"Parity tracking\")" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
Reference in new issue
Block a user