From 9e6986372721d3a00883329da7694a5c0a131f17 Mon Sep 17 00:00:00 2001 From: lacatoire Date: Tue, 7 Jul 2026 15:25:04 +0200 Subject: [PATCH 1/2] CI: check the EN-Revision hash of changed files --- .github/workflows/check-en-revision.yml | 47 +++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/check-en-revision.yml diff --git a/.github/workflows/check-en-revision.yml b/.github/workflows/check-en-revision.yml new file mode 100644 index 00000000..d776d196 --- /dev/null +++ b/.github/workflows/check-en-revision.yml @@ -0,0 +1,47 @@ +# https://docs.github.com/en/actions +# Checks that the EN-Revision comment of the .xml files changed in a PR points to +# the latest doc-en commit for that file. Emits a ::error annotation and fails if +# the hash is missing, wrong, from another file, or outdated. + +name: "Structure" + +on: + pull_request: + branches: ["master"] + types: [opened, synchronize] + +permissions: + contents: read + +jobs: + revision: + name: "Check EN-Revision" + runs-on: ubuntu-latest + steps: + - name: "Checkout translation" + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: "Checkout php/doc-en" + uses: actions/checkout@v4 + with: + path: en + repository: php/doc-en + fetch-depth: 0 + + - name: "Check EN-Revision" + run: | + BASE="${{ github.event.pull_request.base.sha }}" + git fetch --no-tags --depth=1 origin "$BASE" + fail=0 + while IFS= read -r f; do + [ -f "$f" ] && [ -f "en/$f" ] || continue + declared=$(grep -oiP 'EN-Revision:\s*\K[0-9a-f]+' "$f" | head -1 || true) + latest=$(git -C en log -1 --format=%H -- "$f") + if [ "$declared" != "$latest" ]; then + echo "::error file=$f::EN-Revision ${declared:-missing} != latest doc-en commit $latest" + fail=1 + fi + done < <(git diff --name-only "$BASE"...HEAD -- '*.xml') + exit $fail From 11d51974dd2fa96ab5e4e299a5b7c044464ea262 Mon Sep 17 00:00:00 2001 From: lacatoire Date: Mon, 17 Aug 2026 13:48:22 +0200 Subject: [PATCH 2/2] CI: check the EN-Revision of the PR head, not of the merge commit --- .github/workflows/check-en-revision.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/check-en-revision.yml b/.github/workflows/check-en-revision.yml index d776d196..f61e022a 100644 --- a/.github/workflows/check-en-revision.yml +++ b/.github/workflows/check-en-revision.yml @@ -18,9 +18,15 @@ jobs: name: "Check EN-Revision" runs-on: ubuntu-latest steps: + # The explicit ref takes the real head of the pull request, not the merge + # commit actions/checkout builds by default: that one has master as its + # second parent, so the diff below would also list every file landed on + # master since the last push to the pull request. + - name: "Checkout translation" uses: actions/checkout@v4 with: + ref: ${{ github.event.pull_request.head.sha }} fetch-depth: 0 - name: "Checkout php/doc-en"