From 257f90a77a04741135cdb87c52edcb14d6f440f9 Mon Sep 17 00:00:00 2001 From: Jordi Kroon Date: Tue, 9 Jun 2026 19:48:20 +0200 Subject: [PATCH] add docbook-cs, squash for testing --- .github/workflows/check-whitespace.yml | 29 ------- .github/workflows/docbook-cs.yaml | 107 +++++++++++++++++++++++++ docbookcs.xml | 37 +++++++++ 3 files changed, 144 insertions(+), 29 deletions(-) delete mode 100644 .github/workflows/check-whitespace.yml create mode 100644 .github/workflows/docbook-cs.yaml create mode 100644 docbookcs.xml diff --git a/.github/workflows/check-whitespace.yml b/.github/workflows/check-whitespace.yml deleted file mode 100644 index 91c5e6419562..000000000000 --- a/.github/workflows/check-whitespace.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: check-whitespace - -# Get the repository with all commits to ensure that we can analyze -# all of the commits contributed via the Pull Request. -# Process `git log --check` output to extract just the check errors. -# Exit with failure upon white-space issues. - -on: - pull_request: - types: [opened, synchronize] - -permissions: - contents: read - -jobs: - check-whitespace: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v6 - with: - fetch-depth: 0 - - - run: | - git config --global user.name "check-whitespace" - git config --global user.email "check-whitespace@example.com" - - run: git checkout ${{github.event.pull_request.base.sha}} - - run: git merge --squash ${{github.event.pull_request.head.sha}} - - run: git commit -m "Squashed" - - run: git log --check HEAD^..HEAD diff --git a/.github/workflows/docbook-cs.yaml b/.github/workflows/docbook-cs.yaml new file mode 100644 index 000000000000..1af8eead7f5a --- /dev/null +++ b/.github/workflows/docbook-cs.yaml @@ -0,0 +1,107 @@ +# https://docs.github.com/en/actions + +name: "DocBook Lint" + +on: + push: + pull_request: + branches: + - "master" + +permissions: + contents: "read" + +concurrency: + group: "${{ github.workflow }}-${{ github.ref }}" + cancel-in-progress: true + +jobs: + docbook-cs: + name: "DocBook Style Check" + runs-on: "ubuntu-latest" + + env: + # Base commit to diff against: PR base on pull_request, pre-push tip on push. + BASE_SHA: |- + ${{ + case( + github.event_name == 'pull_request', github.event.pull_request.base.sha, + github.event_name == 'push', github.event.before, + 'INVALID' + ) + }} + + strategy: + matrix: + language: + - "en" + + steps: + - name: "Checkout php/doc-${{ matrix.language }}" + uses: "actions/checkout@v6" + with: + ref: "${{ github.event.pull_request.head.sha }}" + path: "${{ matrix.language }}" + fetch-depth: 50 + + - name: "Checkout php/doc-base" + uses: "actions/checkout@v6" + with: + path: "doc-base" + repository: "php/doc-base" + + - name: "Checkout php/docbook-cs" + uses: "actions/checkout@v6" + with: + path: "docbook-cs" + repository: "php/docbook-cs" + + - name: "Fetch diff base" + working-directory: "${{ matrix.language }}" + run: | + git fetch origin "$BASE_SHA" --depth=50 + # Deepen until the merge-base is reachable (long-lived branches) + for i in 1 2 3 4 5; do + git merge-base "$BASE_SHA" HEAD >/dev/null 2>&1 && break + git fetch --deepen=100 origin "$BASE_SHA" + done + + - name: "Setup PHP" + uses: "shivammathur/setup-php@v2" + with: + php-version: "8.5" + extensions: "dom, libxml, simplexml" + tools: composer, cs2pr + + - name: "Build documentation" + run: | + php doc-base/configure.php \ + --disable-libxml-check \ + --enable-xml-details \ + --redirect-stderr-to-stdout \ + --with-lang=${{ matrix.language }} + + - name: "Install docbook-cs" + working-directory: "docbook-cs" + run: composer install --no-interaction --no-progress + + - name: "Run docbook-cs with diff" + working-directory: "${{ matrix.language }}" + run: | + set -o pipefail + git diff "$BASE_SHA"...HEAD | php ../docbook-cs/bin/docbook-cs \ + --report=checkstyle \ + --diff \ + --no-colors > docbook-report.xml + + - name: "Upload report" + if: ${{ ! cancelled() }} + uses: "actions/upload-artifact@v7" + with: + name: "docbook-report" + path: "${{ matrix.language }}/docbook-report.xml" + + - name: "Annotate PR with violations" + if: ${{ ! cancelled() }} + working-directory: "${{ matrix.language }}" + run: cs2pr docbook-report.xml --colorize --prepend-filename diff --git a/docbookcs.xml b/docbookcs.xml new file mode 100644 index 000000000000..25ab97eca29e --- /dev/null +++ b/docbookcs.xml @@ -0,0 +1,37 @@ + + + + + en + doc-base + + + + + + + + + + + . + + + + contributors.ent + extensions.ent + language-defs.ent + language-snippets.ent + ../doc-base/entities/ + ../doc-base/temp/file-entities.ent + ../doc-base/temp/file-entities + + + + output/* + + +