diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 8f5a4d3ad..12602d179 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -41,11 +41,16 @@ env: jobs: - # Build documentation handling warnings as errors. - # If success, upload built docs. If failure, notify telegram and upload logs. + # Build documentation handling warnings as errors in both HTML and PDF. + # If success, upload built docs as artifact. + # If failure in HTML, notify telegram and upload logs. build: - name: Build translated docs + name: Build docs runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + format: [ html, latex, epub ] steps: - uses: actions/checkout@v5 with: @@ -70,20 +75,13 @@ jobs: - name: Build docs id: build - run: ./scripts/build.sh - - - name: Upload artifact - docs - if: steps.build.outcome == 'success' - uses: actions/upload-artifact@v4.3.5 - with: - name: docs - path: cpython/Doc/build/html + run: ./scripts/build.sh ${{ matrix.format }} - name: Prepare notification (only on error) - if: always() && steps.build.outcome == 'failure' + if: always() && steps.build.outcome == 'failure' && matrix.format == 'html' id: prepare run: | - scripts/prepmsg.sh logs/sphinxwarnings.txt logs/notify.txt + scripts/prepmsg.sh logs/sphinxwarnings-${format}.txt logs/notify.txt cat logs/notify.txt env: GITHUB_JOB: ${{ github.job }} @@ -101,11 +99,34 @@ jobs: - name: Upload artifact - log files if: always() && steps.build.outcome == 'failure' - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v4.3.5 with: - name: ${{ inputs.version }}-build-logs + name: logs-${{ inputs.version }}-${{ matrix.format }} path: logs/* + + - name: Upload artifact - docs + if: always() && steps.build.outcome == 'success' + uses: actions/upload-artifact@v4.3.5 + with: + name: python-docs-pt-br-${{ inputs.version }}-${{ matrix.format }} + path: cpython/Doc/build/${{ matrix.format }} + # Build Python docs in PDF format and make available for download. + output-pdf: + name: Build docs (pdf) + runs-on: ubuntu-latest + needs: [ 'build' ] + steps: + - uses: actions/download-artifact@v5 + with: + name: python-docs-pt-br-${{ inputs.version }}-latex + - run: sudo apt-get update + - run: sudo apt-get install -y latexmk texlive-xetex fonts-freefont-otf xindy texlive-lang-portuguese + - run: make + - uses: actions/upload-artifact@v4 + with: + name: python-docs-pt-br-${{ inputs.version }}-pdf + path: ./*.pdf # Run sphinx-lint to find wrong reST syntax in PO files. Always store logs. # If issues are found, notify telegram and upload logs. diff --git a/scripts/build.sh b/scripts/build.sh index ee338368e..1e01af409 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -1,10 +1,17 @@ #!/bin/sh -# Build translated docs to pop up errors +# Build translated docs +# Expects input like 'html' and 'latex', defaults to 'html'. # # SPDX-License-Identifier: CC0-1.0 set -xeu +if [ -z "$1" ]; then + format=html +else + format="$1" +fi + # Fail earlier if required variables are not set test -n ${PYDOC_LANGUAGE+x} @@ -14,15 +21,15 @@ mkdir -p logs # If version is 3.12 or older, set gettext_compact. # This confval is not needed since 3.12. # In 3.13, its presence messes 3.13's syntax checking (?) -opts="-D language=${PYDOC_LANGUAGE} --keep-going -w ../../logs/sphinxwarnings.txt" +opts="-D language=${PYDOC_LANGUAGE} --keep-going -w ../../logs/sphinxwarnings-${format}.txt" minor_version=$(git -C cpython/Doc branch --show-current | sed 's|^3\.||') if [ $minor_version -lt 12 ]; then opts="$opts -D gettext_compact=False" fi -make -C cpython/Doc html SPHINXOPTS="${opts}" +make -C cpython/Doc "${format}" SPHINXOPTS="${opts}" # Remove empty file -if [ ! -s logs/sphinxwarnings.txt ]; then - rm logs/sphinxwarnings.txt +if [ ! -s "logs/sphinxwarnings-${format}.txt" ]; then + rm "logs/sphinxwarnings-${format}.txt" fi