Skip to content

Commit ec74a5d

Browse files
Fail a drift only on the pull request that owns the vendored copy
1 parent 5429c76 commit ec74a5d

1 file changed

Lines changed: 22 additions & 3 deletions

File tree

.github/workflows/vendor-drift.yml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,25 @@ jobs:
4242
runs-on: ubuntu-latest
4343
steps:
4444
- uses: actions/checkout@v4
45+
with:
46+
# `git diff` against the base needs the history the two share.
47+
fetch-depth: 0
48+
49+
# A pull request that changes the vendored copy, or the target that
50+
# writes it, owns keeping it current. One that changes only this
51+
# workflow does not, and failing it for a staleness it did not cause
52+
# would block the very change that stops the staleness failing.
53+
- name: Note whether this pull request owns the vendored copy
54+
id: owns
55+
if: github.event_name == 'pull_request'
56+
run: |
57+
git fetch --no-tags origin "${{ github.base_ref }}"
58+
if git diff --name-only FETCH_HEAD...HEAD -- vendor/meos-api Makefile | grep -q .; then
59+
echo "owns=true" >> "$GITHUB_OUTPUT"
60+
else
61+
echo "owns=false" >> "$GITHUB_OUTPUT"
62+
echo "::notice::This pull request changes neither vendor/meos-api nor the Makefile, so a drift is reported rather than failed."
63+
fi
4564
4665
# libclang (the Python wheel) bundles the .so but not the system C
4766
# headers MEOS depends on (json-c, gsl, proj, postgres). Without them,
@@ -60,8 +79,8 @@ jobs:
6079
- name: Refresh vendored MEOS-API artefacts from master
6180
run: make vendor-meos-api
6281

63-
# A pull request touching the vendored copy or the target that writes it
64-
# must not leave it stale, and its author is there to act, so there the
82+
# A pull request that changes the vendored copy or the target that writes
83+
# it must not leave it stale, and its author is there to act, so there the
6584
# drift is an error.
6685
#
6786
# Nobody is there to act on a schedule or on a push already made, and
@@ -78,7 +97,7 @@ jobs:
7897
else
7998
echo "drift=true" >> "$GITHUB_OUTPUT"
8099
git diff --stat -- vendor/meos-api/
81-
if [ "${{ github.event_name }}" = "pull_request" ]; then
100+
if [ "${{ steps.owns.outputs.owns }}" = "true" ]; then
82101
echo "::error::vendor/meos-api/ is stale. Run \`make vendor-meos-api\` locally and include the result."
83102
exit 1
84103
fi

0 commit comments

Comments
 (0)