Skip to content

Commit de6f9f1

Browse files
Merge pull request #14 from estebanzimanyi/ci/vendor-drift-auto-pr
Open the vendored MEOS-API refresh instead of failing the schedule
2 parents 58ab017 + 427027a commit de6f9f1

1 file changed

Lines changed: 71 additions & 5 deletions

File tree

.github/workflows/vendor-drift.yml

Lines changed: 71 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
name: Vendor drift (MEOS-API)
22

33
# Re-runs the `make vendor-meos-api` target against the live MEOS-API master
4-
# and fails if the vendored artefacts under `vendor/meos-api/` are out of date.
4+
# and reports when the vendored artefacts under `vendor/meos-api/` are out of
5+
# date.
56
#
67
# Surfaces upstream changes as actionable PR diffs instead of letting them
7-
# silently rot. The CI failure message tells the maintainer to run
8+
# silently rot. On a pull request touching the vendored copy the drift fails
9+
# the run, and the message tells the author to run
810
#
911
# make vendor-meos-api
1012
#
11-
# locally and submit a refresh PR.
13+
# locally and include the result. Every other run opens that refresh pull
14+
# request itself, since MEOS-API master moves most days and there is no author
15+
# to address.
1216
#
1317
# Step 3 of `docs/MEOS_API_INGESTION_PLAN.md`.
1418

@@ -26,12 +30,37 @@ on:
2630
- cron: '0 6 * * *'
2731
workflow_dispatch:
2832

33+
# The scheduled run commits the refreshed artefacts to a branch and opens a
34+
# pull request for them.
35+
permissions:
36+
contents: write
37+
pull-requests: write
38+
2939
jobs:
3040
vendor-drift:
3141
name: Refresh & diff vendored artefacts
3242
runs-on: ubuntu-latest
3343
steps:
3444
- 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
3564
3665
# libclang (the Python wheel) bundles the .so but not the system C
3766
# headers MEOS depends on (json-c, gsl, proj, postgres). Without them,
@@ -50,6 +79,15 @@ jobs:
5079
- name: Refresh vendored MEOS-API artefacts from master
5180
run: make vendor-meos-api
5281

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
84+
# drift is an error.
85+
#
86+
# Nobody is there to act on a schedule or on a push already made, and
87+
# MEOS-API master moves most days, so failing whenever it had moved would
88+
# fail most days and report a difference no one could address from a run
89+
# log. Those runs open the refresh instead, and the pull request they
90+
# open carries the diff.
5391
- name: Detect drift
5492
id: drift
5593
run: |
@@ -58,7 +96,35 @@ jobs:
5896
echo "::notice::vendor/meos-api/ is up to date with MEOS-API master."
5997
else
6098
echo "drift=true" >> "$GITHUB_OUTPUT"
61-
echo "::error::vendor/meos-api/ is stale. Run \`make vendor-meos-api\` locally and open a refresh PR."
6299
git diff --stat -- vendor/meos-api/
63-
exit 1
100+
if [ "${{ steps.owns.outputs.owns }}" = "true" ]; then
101+
echo "::error::vendor/meos-api/ is stale. Run \`make vendor-meos-api\` locally and include the result."
102+
exit 1
103+
fi
104+
if [ "${{ github.event_name }}" = "pull_request" ]; then
105+
echo "::notice::vendor/meos-api/ is stale, which this pull request does not cause and does not have to fix."
106+
else
107+
echo "::notice::vendor/meos-api/ is stale; opening a refresh pull request."
108+
fi
64109
fi
110+
111+
# `add-paths` stages only what it lists, so it names every path
112+
# `make vendor-meos-api` writes; anything omitted would be regenerated
113+
# and then silently discarded. The action reuses its branch, so a later
114+
# run updates this pull request rather than opening another one.
115+
- name: Open a refresh pull request
116+
if: github.event_name != 'pull_request' && steps.drift.outputs.drift == 'true'
117+
uses: peter-evans/create-pull-request@v6
118+
with:
119+
add-paths: vendor/meos-api
120+
branch: tooling/refresh-meos-api-vendor
121+
delete-branch: true
122+
commit-message: "Refresh the vendored MEOS-API artefacts"
123+
title: "Refresh the vendored MEOS-API artefacts"
124+
body: |
125+
`make vendor-meos-api` regenerates `vendor/meos-api/` from MEOS-API
126+
master and the MobilityDB headers it parses, and the result differs
127+
from the committed copy.
128+
129+
Opened by the scheduled `Vendor drift (MEOS-API)` run, which reruns
130+
daily and updates this pull request while the difference stands.

0 commit comments

Comments
 (0)