|
1 | 1 | name: Vendor drift (MEOS-API) |
2 | 2 |
|
3 | 3 | # 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. |
5 | 6 | # |
6 | 7 | # 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 |
8 | 10 | # |
9 | 11 | # make vendor-meos-api |
10 | 12 | # |
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. |
12 | 16 | # |
13 | 17 | # Step 3 of `docs/MEOS_API_INGESTION_PLAN.md`. |
14 | 18 |
|
|
26 | 30 | - cron: '0 6 * * *' |
27 | 31 | workflow_dispatch: |
28 | 32 |
|
| 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 | + |
29 | 39 | jobs: |
30 | 40 | vendor-drift: |
31 | 41 | name: Refresh & diff vendored artefacts |
32 | 42 | runs-on: ubuntu-latest |
33 | 43 | steps: |
34 | 44 | - 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 |
35 | 64 |
|
36 | 65 | # libclang (the Python wheel) bundles the .so but not the system C |
37 | 66 | # headers MEOS depends on (json-c, gsl, proj, postgres). Without them, |
|
50 | 79 | - name: Refresh vendored MEOS-API artefacts from master |
51 | 80 | run: make vendor-meos-api |
52 | 81 |
|
| 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. |
53 | 91 | - name: Detect drift |
54 | 92 | id: drift |
55 | 93 | run: | |
|
58 | 96 | echo "::notice::vendor/meos-api/ is up to date with MEOS-API master." |
59 | 97 | else |
60 | 98 | echo "drift=true" >> "$GITHUB_OUTPUT" |
61 | | - echo "::error::vendor/meos-api/ is stale. Run \`make vendor-meos-api\` locally and open a refresh PR." |
62 | 99 | 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 |
64 | 109 | 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