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.yml b/.github/workflows/docbook-cs.yml new file mode 100644 index 000000000000..e98c3ae79b34 --- /dev/null +++ b/.github/workflows/docbook-cs.yml @@ -0,0 +1,94 @@ +# https://docs.github.com/en/actions + +name: "DocBook Lint" + +on: + push: + branches: + - "master" + 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" + + 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: "Fetch base branch with merge-base" + working-directory: "${{ matrix.language }}" + run: | + git fetch origin ${{ github.base_ref }} --depth=50 + # Deepen until we find the merge-base (handles long-lived PRs) + for i in 1 2 3 4 5; do + if git merge-base origin/${{ github.base_ref }} HEAD >/dev/null 2>&1; then + break + fi + git fetch --deepen=100 origin ${{ github.base_ref }} + done + + - name: "Setup PHP" + uses: "shivammathur/setup-php@v2" + with: + php-version: "8.5" + extensions: "dom, libxml, simplexml" + tools: composer:v2, cs2pr:^1.8 + + - 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: "${{ matrix.language }}" + run: composer require jordikroon/docbook-cs:^1.1 + + - name: "Run docbook-cs with diff" + working-directory: "${{ matrix.language }}" + run: | + set -o pipefail + git diff origin/${{ github.base_ref }}...HEAD | vendor/bin/docbook-cs \ + --report=checkstyle \ + --diff \ + --no-colors > docbook-report.xml || true + + - 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..5083cf03fa43 --- /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/* + + +