|
42 | 42 | runs-on: ubuntu-latest |
43 | 43 | steps: |
44 | 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 |
45 | 64 |
|
46 | 65 | # libclang (the Python wheel) bundles the .so but not the system C |
47 | 66 | # headers MEOS depends on (json-c, gsl, proj, postgres). Without them, |
|
60 | 79 | - name: Refresh vendored MEOS-API artefacts from master |
61 | 80 | run: make vendor-meos-api |
62 | 81 |
|
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 |
65 | 84 | # drift is an error. |
66 | 85 | # |
67 | 86 | # Nobody is there to act on a schedule or on a push already made, and |
|
78 | 97 | else |
79 | 98 | echo "drift=true" >> "$GITHUB_OUTPUT" |
80 | 99 | git diff --stat -- vendor/meos-api/ |
81 | | - if [ "${{ github.event_name }}" = "pull_request" ]; then |
| 100 | + if [ "${{ steps.owns.outputs.owns }}" = "true" ]; then |
82 | 101 | echo "::error::vendor/meos-api/ is stale. Run \`make vendor-meos-api\` locally and include the result." |
83 | 102 | exit 1 |
84 | 103 | fi |
|
0 commit comments