From 4e968b2d237fc26c8335ea010b1bdfa05e7e269a Mon Sep 17 00:00:00 2001 From: Rafael Fontenelle Date: Sun, 27 Oct 2024 16:15:35 -0300 Subject: [PATCH 01/14] Create check.yml --- .github/workflows/check.yml | 60 +++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 .github/workflows/check.yml diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml new file mode 100644 index 00000000000..3c78f8dac69 --- /dev/null +++ b/.github/workflows/check.yml @@ -0,0 +1,60 @@ +name: Check + +on: + workflow_dispatch: + inputs: + cpython_version: + description: "Python version to build docs" + required: true + type: string + languages: + description: "List of language codes to build. e.g. '[pt_BR, de, zh_CN]'" + required: true + type: string + +jobs: + check: + runs-on: ubuntu-latest + permissions: + contents: read + strategy: + max-parallel: 4 + fail-fast: false + matrix: + cpython_version: ${{fromJson(inputs.cpython_version)}} + language: ${{fromJson(needs.trigger.outputs.languages)}} + steps: + - name: Check out ${{ github.repository }} + uses: actions/checkout@v4.2.1 + + - name: Check out ${{ matrix.cpython_version }} branch of CPython + uses: actions/checkout@v4.2.1 + with: + repository: python/cpython + persist-credentials: false + ref: ${{ matrix.cpython_version }} + path: cpython + + - name: Check out ${{ matrix.cpython_version }} branch of ${{ github.repository }} + uses: actions/checkout@v4.2.1 + with: + ref: ${{ matrix.cpython_version }} + path: cpython/Doc/locales + + - name: Set up Python 3 + uses: actions/setup-python@v5.2.0 + with: + python-version: '3' + cache: 'pip' + cache-dependency-path: cpython/Doc/requirements.txt + + - name: Install dependencies + run: | + pip3 install --upgrade pip + pip3 install sphinx-lint + + - name: Set up problem-matcher for sphinx-build + uses: sphinx-doc/github-problem-matcher@1.0 + + - name: Build ${{ matrix.language }} translation for Python ${{ matrix.cpython_version }} + run: make -C cpython/Doc venv html SPHINXOPTS='-Dlanguage=${{ matrix.language }} --keep-going -W' From d0b0123649573c827df7c1c2b2c2a85d0c791e8b Mon Sep 17 00:00:00 2001 From: Rafael Fontenelle Date: Sun, 27 Oct 2024 16:43:00 -0300 Subject: [PATCH 02/14] Call check workflow from ci.yml --- .github/workflows/ci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 95e6d3813e2..65c8907dedd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -278,3 +278,9 @@ jobs: env: TX_TOKEN: ${{ secrets.TX_TOKEN }} + call-check: + uses: .github/workflows/reusable-workflow.yml@check-docs + with: + cpython_version: ${{ needs.trigger.outputs.current }} + languages: ${{ needs.trigger.outputs.languages }} + secrets: inherit From 7aa65617d0cd9f35452860f2cb4e7c02d256898e Mon Sep 17 00:00:00 2001 From: Rafael Fontenelle Date: Sun, 27 Oct 2024 16:44:39 -0300 Subject: [PATCH 03/14] Fix syntax for local workflow call in ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 65c8907dedd..c89cafdcef6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -279,7 +279,7 @@ jobs: TX_TOKEN: ${{ secrets.TX_TOKEN }} call-check: - uses: .github/workflows/reusable-workflow.yml@check-docs + uses: ./.github/workflows/reusable-workflow.yml@check-docs with: cpython_version: ${{ needs.trigger.outputs.current }} languages: ${{ needs.trigger.outputs.languages }} From 3a5d501eceeae133749cfeadbdd894ee05282edc Mon Sep 17 00:00:00 2001 From: Rafael Fontenelle Date: Sun, 27 Oct 2024 16:46:31 -0300 Subject: [PATCH 04/14] Remove version from local workflow call in ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c89cafdcef6..11a96a13ea1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -279,7 +279,7 @@ jobs: TX_TOKEN: ${{ secrets.TX_TOKEN }} call-check: - uses: ./.github/workflows/reusable-workflow.yml@check-docs + uses: ./.github/workflows/reusable-workflow.yml with: cpython_version: ${{ needs.trigger.outputs.current }} languages: ${{ needs.trigger.outputs.languages }} From 3de84a885c29e9b6dc8c9c105d23d4044fccc0fe Mon Sep 17 00:00:00 2001 From: Rafael Fontenelle Date: Sun, 27 Oct 2024 16:50:14 -0300 Subject: [PATCH 05/14] Fix called name of ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 11a96a13ea1..87017c168c8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -279,7 +279,7 @@ jobs: TX_TOKEN: ${{ secrets.TX_TOKEN }} call-check: - uses: ./.github/workflows/reusable-workflow.yml + uses: ./.github/workflows/check.yml with: cpython_version: ${{ needs.trigger.outputs.current }} languages: ${{ needs.trigger.outputs.languages }} From 24f2e80f01bd4ccdd7890f5cd7209815bb6ceaf3 Mon Sep 17 00:00:00 2001 From: Rafael Fontenelle Date: Sun, 27 Oct 2024 16:54:32 -0300 Subject: [PATCH 06/14] Add workflow_call to check.yml --- .github/workflows/check.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 3c78f8dac69..0481e14be53 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -11,6 +11,16 @@ on: description: "List of language codes to build. e.g. '[pt_BR, de, zh_CN]'" required: true type: string + workflow_call: + inputs: + cpython_version: + description: "Python version to build docs" + required: true + type: string + languages: + description: "List of language codes to build. e.g. '[pt_BR, de, zh_CN]'" + required: true + type: string jobs: check: From 14d136326d100914d38502d1ee2959eb5e9e65ab Mon Sep 17 00:00:00 2001 From: Rafael Fontenelle Date: Sun, 27 Oct 2024 18:01:40 -0300 Subject: [PATCH 07/14] move cpython_version outside matrix --- .github/workflows/check.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 0481e14be53..63149075ec8 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -27,28 +27,29 @@ jobs: runs-on: ubuntu-latest permissions: contents: read + env: + python_version: ${{ inputs.cpython_version }} strategy: max-parallel: 4 fail-fast: false matrix: - cpython_version: ${{fromJson(inputs.cpython_version)}} language: ${{fromJson(needs.trigger.outputs.languages)}} steps: - name: Check out ${{ github.repository }} uses: actions/checkout@v4.2.1 - - name: Check out ${{ matrix.cpython_version }} branch of CPython + - name: Check out ${{ env.cpython_version }} branch of CPython uses: actions/checkout@v4.2.1 with: repository: python/cpython persist-credentials: false - ref: ${{ matrix.cpython_version }} + ref: ${{ env.cpython_version }} path: cpython - - name: Check out ${{ matrix.cpython_version }} branch of ${{ github.repository }} + - name: Check out ${{ env.cpython_version }} branch of ${{ github.repository }} uses: actions/checkout@v4.2.1 with: - ref: ${{ matrix.cpython_version }} + ref: ${{ env.cpython_version }} path: cpython/Doc/locales - name: Set up Python 3 @@ -66,5 +67,5 @@ jobs: - name: Set up problem-matcher for sphinx-build uses: sphinx-doc/github-problem-matcher@1.0 - - name: Build ${{ matrix.language }} translation for Python ${{ matrix.cpython_version }} + - name: Build ${{ matrix.language }} translation for Python ${{ env.cpython_version }} run: make -C cpython/Doc venv html SPHINXOPTS='-Dlanguage=${{ matrix.language }} --keep-going -W' From e1037922599cbebea9dadcd8dde4f23d9b8fac71 Mon Sep 17 00:00:00 2001 From: Rafael Fontenelle Date: Sun, 27 Oct 2024 18:04:36 -0300 Subject: [PATCH 08/14] Temporarily disable other jobs in ci.yml --- .github/workflows/ci.yml | 199 --------------------------------------- 1 file changed, 199 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 87017c168c8..b877d9d51ac 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -78,205 +78,6 @@ jobs: echo current: ${{ steps.version.outputs.current }} echo version_pairs: ${{ steps.version.outputs.version_pairs }} echo languages: ${{ steps.languages.outputs.languages }} - - - update: - runs-on: ubuntu-latest - needs: trigger - permissions: - contents: write - strategy: - max-parallel: 1 - fail-fast: false - matrix: - cpython_version: ${{fromJson(needs.trigger.outputs.all_versions)}} - # must match existent projects in Transifex - - steps: - - name: Check out ${{ github.repository }} - uses: actions/checkout@v4.2.1 - - - name: Check out ${{ matrix.cpython_version }} branch of CPython - uses: actions/checkout@v4.2.1 - with: - repository: python/cpython - persist-credentials: false - ref: ${{ matrix.cpython_version }} - path: cpython - - - name: Check out ${{ matrix.cpython_version }} branch of ${{ github.repository }} - uses: actions/checkout@v4.2.1 - with: - ref: ${{ matrix.cpython_version }} - path: cpython/Doc/locales - - - name: Set up Python 3 - uses: actions/setup-python@v5.2.0 - with: - python-version: '3' - cache: 'pip' - cache-dependency-path: | - requirements.txt - cpython/Doc/requirements.txt - - - name: Install Transifex CLI - working-directory: /usr/local/bin - run: | - curl -o- https://raw.githubusercontent.com/transifex/cli/master/install.sh | bash -s -- v${{ env.TX_CLI_VERSION }} - - - name: Install dependencies - run: | - sudo apt update -y && sudo apt install gettext -y - pip3 install --upgrade pip - pip3 install -r requirements.txt -r cpython/Doc/requirements.txt - - - name: Change Transifex project name if Python version != python-newest - if: ${{ matrix.cpython_version != needs.trigger.outputs.current }} - shell: bash - run: | - ver=$(echo ${{ matrix.cpython_version }} | sed 's|\.||') - echo "TX_PROJECT=python-$ver" >> $GITHUB_ENV - echo ${{ env.TX_PROJECT }} - - # required for generating .tx/config - - name: Generate POT files - working-directory: cpython/Doc - run: | - (cd locales; rm -r pot;) - sphinx-build -E -b gettext -D gettext_compact=0 -d build/.doctrees . locales/pot - - - name: Include obsolete catalog templates (pot files) for removal - run: | - deleted_files=$(git status -s | grep ^' D' | cut -d' ' -f3) - if [ -n "$deleted_files" ]; then git rm -v $deleted_files; else echo "no POT files to remove"; fi - - # See issue #15 - - name: Patch POT files - run: | - scripts/remove-ilegal-strings.sh cpython/Doc/locales/pot - - - name: Generate Transifex configuration file (.tx/config) - working-directory: cpython/Doc/locales - run: | - rm .tx/config - sphinx-intl create-txconfig - sphinx-intl update-txconfig-resources --pot-dir pot --locale-dir . --transifex-organization-name python-doc --transifex-project-name ${{ env.TX_PROJECT }} - sed -i '/^minimum_perc *= 0$/s/0/1/' .tx/config - git diff .tx/config - - - name: Push source strings to Transifex - if: ${{ github.event_name == 'schedule' || - (github.event_name == 'workflow_dispatch' && github.event.inputs.push == 'true') }} - working-directory: cpython/Doc/locales - id: tx_push - run: | - tx push --source --skip - env: - TX_TOKEN: ${{ secrets.TX_TOKEN }} - - - name: Lock unused translations - if: steps.tx_push.outcome == 'success' - run: | - python3 scripts/lock-translations.py cpython/Doc/locales/.tx/config ${{ env.TX_PROJECT }} - env: - TX_TOKEN: ${{ secrets.TX_TOKEN }} - - - name: Pull translations for all languages - if: ${{ github.event_name == 'schedule' || - (github.event_name == 'workflow_dispatch' && github.event.inputs.pull == 'true') }} - working-directory: cpython/Doc/locales - run: | - tx pull --all --translations --force - env: - TX_TOKEN: ${{ secrets.TX_TOKEN }} - - - name: Powrap POT files and modified PO files - working-directory: cpython/Doc/locales - run: | - powrap --modified - powrap pot/{**/,}*.pot - - - name: Commit changes - working-directory: cpython/Doc/locales - run: | - git config user.name github-actions[bot] - git config user.email 41898282+github-actions[bot]@users.noreply.github.com - git status - shopt -s globstar - git diff -I'^"POT-Creation-Date: ' --numstat **/*.po **/*.pot | cut -f3 | xargs -r git add -v - git add -v $(git ls-files -o --exclude-standard *.po *.pot) .tx/config - git diff-index --cached --quiet HEAD || { git commit -vm "Update translations from Transifex"; } - - - name: Push changes - working-directory: cpython/Doc/locales - if: ${{ contains(fromJSON('["schedule", "workflow_dispatch"]'), github.event_name) }} - run: | - git push - - - propagate_translations: - runs-on: ubuntu-latest - needs: [trigger, update] - permissions: - contents: read - strategy: - max-parallel: 4 - fail-fast: false - matrix: - branch: ${{fromJson(needs.trigger.outputs.version_pairs)}} - language: ${{fromJson(needs.trigger.outputs.languages)}} - - steps: - - name: Check out main - uses: actions/checkout@v4.2.1 - - - name: Check out branch ${{ matrix.branch.new }} - uses: actions/checkout@v4.2.1 - with: - ref: ${{ matrix.branch.new }} - path: ${{ matrix.branch.new }} - - - name: Check out branch ${{ matrix.branch.prev }} - uses: actions/checkout@v4.2.1 - with: - ref: ${{ matrix.branch.prev }} - path: ${{ matrix.branch.prev }} - - - name: Set up Python 3 - uses: actions/setup-python@v5.2.0 - with: - python-version: '3' - cache: 'pip' - cache-dependency-path: | - requirements.txt - - - name: Install Transifex CLI - working-directory: /usr/local/bin - run: | - curl -o- https://raw.githubusercontent.com/transifex/cli/master/install.sh | bash -s -- v${{ env.TX_CLI_VERSION }} - - - name: Install dependencies - run: | - python3 -m pip install --upgrade pip - python3 -m pip install pomerge - - - name: Merge ${{ matrix.language }} translations from ${{ matrix.branch.new }} into ${{ matrix.branch.prev }} - run: | - if test -d ${{ matrix.branch.prev }}/${{ matrix.language }}; then - shopt -s globstar - pomerge --from-files ${{ matrix.branch.new }}/${{ matrix.language }}/**/*.po --to-files ${{ matrix.branch.prev }}/${{ matrix.language }}/**/*.po - else - echo "Branch ${{ matrix.branch.prev }} has no lang code ${{ matrix.language }}." - fi - - - name: Push ${{ matrix.language }} translations for Python ${{ matrix.branch.prev }} documentation to Transifex - if: ${{ github.event_name == 'schedule' || - (github.event_name == 'workflow_dispatch' && github.event.inputs.push == 'true') }} - working-directory: ${{ matrix.branch.prev }} - run: | - tx push -t -l ${{ matrix.language }} - env: - TX_TOKEN: ${{ secrets.TX_TOKEN }} call-check: uses: ./.github/workflows/check.yml From ba2b4d0a3d3990781cebf04d04fcfff48a140142 Mon Sep 17 00:00:00 2001 From: Rafael Fontenelle Date: Sun, 27 Oct 2024 18:08:13 -0300 Subject: [PATCH 09/14] Adds needs trigger when calling in ci.yml --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b877d9d51ac..458a6c8a3f6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -81,6 +81,7 @@ jobs: call-check: uses: ./.github/workflows/check.yml + needs: trigger with: cpython_version: ${{ needs.trigger.outputs.current }} languages: ${{ needs.trigger.outputs.languages }} From 06d2a39d105e16648ca129613993adbe58fe04ce Mon Sep 17 00:00:00 2001 From: Rafael Fontenelle Date: Sun, 27 Oct 2024 18:13:07 -0300 Subject: [PATCH 10/14] Fix matrix variable in check.yml --- .github/workflows/check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 63149075ec8..d6dc319ef54 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -33,7 +33,7 @@ jobs: max-parallel: 4 fail-fast: false matrix: - language: ${{fromJson(needs.trigger.outputs.languages)}} + language: ${{fromJson(inputs.languages)}} steps: - name: Check out ${{ github.repository }} uses: actions/checkout@v4.2.1 From b02e9705b1bd7811b220c991f757ca51787a1403 Mon Sep 17 00:00:00 2001 From: Rafael Fontenelle Date: Sun, 27 Oct 2024 18:17:36 -0300 Subject: [PATCH 11/14] Fix version of problem matcher in check.yml --- .github/workflows/check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index d6dc319ef54..a4047a35c38 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -65,7 +65,7 @@ jobs: pip3 install sphinx-lint - name: Set up problem-matcher for sphinx-build - uses: sphinx-doc/github-problem-matcher@1.0 + uses: sphinx-doc/github-problem-matcher@v1 - name: Build ${{ matrix.language }} translation for Python ${{ env.cpython_version }} run: make -C cpython/Doc venv html SPHINXOPTS='-Dlanguage=${{ matrix.language }} --keep-going -W' From d3f1414901c9cdf153084057e52794c8648a8b8b Mon Sep 17 00:00:00 2001 From: Rafael Fontenelle Date: Sun, 27 Oct 2024 18:27:30 -0300 Subject: [PATCH 12/14] Change the use of inputs.cpython_version in check.yml --- .github/workflows/check.yml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index a4047a35c38..b9fb4a7d50d 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -27,8 +27,6 @@ jobs: runs-on: ubuntu-latest permissions: contents: read - env: - python_version: ${{ inputs.cpython_version }} strategy: max-parallel: 4 fail-fast: false @@ -38,18 +36,18 @@ jobs: - name: Check out ${{ github.repository }} uses: actions/checkout@v4.2.1 - - name: Check out ${{ env.cpython_version }} branch of CPython + - name: Check out ${{ inputs.cpython_version }} branch of CPython uses: actions/checkout@v4.2.1 with: repository: python/cpython persist-credentials: false - ref: ${{ env.cpython_version }} + ref: ${{ inputs.cpython_version }} path: cpython - - name: Check out ${{ env.cpython_version }} branch of ${{ github.repository }} + - name: Check out ${{ inputs.cpython_version }} branch of ${{ github.repository }} uses: actions/checkout@v4.2.1 with: - ref: ${{ env.cpython_version }} + ref: ${{ inputs.cpython_version }} path: cpython/Doc/locales - name: Set up Python 3 @@ -67,5 +65,5 @@ jobs: - name: Set up problem-matcher for sphinx-build uses: sphinx-doc/github-problem-matcher@v1 - - name: Build ${{ matrix.language }} translation for Python ${{ env.cpython_version }} + - name: Build ${{ matrix.language }} translation for Python ${{ inputs.cpython_version }} run: make -C cpython/Doc venv html SPHINXOPTS='-Dlanguage=${{ matrix.language }} --keep-going -W' From 8e3c7229b9302db63f7f4ff7f02cf9e25d806089 Mon Sep 17 00:00:00 2001 From: Rafael Fontenelle Date: Thu, 7 Nov 2024 22:45:20 -0300 Subject: [PATCH 13/14] place pofiles in correct dir to build --- .github/workflows/check.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index b9fb4a7d50d..1c20168a1b8 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -62,6 +62,15 @@ jobs: pip3 install --upgrade pip pip3 install sphinx-lint + - name: Put translation files in correct place + run: | + cd cpython/Doc/locales/${{ matrix.language }} + mkdir LC_MESSAGES + for pofile in $(find -name '*.po') + do + install -Dm644 -t LC_MESSAGES $pofile + done + - name: Set up problem-matcher for sphinx-build uses: sphinx-doc/github-problem-matcher@v1 From 358307cc820696fb00b29ec26bf2654f0df01633 Mon Sep 17 00:00:00 2001 From: Rafael Fontenelle Date: Fri, 8 Nov 2024 00:09:21 -0300 Subject: [PATCH 14/14] Remove file placement code --- .github/workflows/check.yml | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 1c20168a1b8..19a9e09fdff 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -61,18 +61,9 @@ jobs: run: | pip3 install --upgrade pip pip3 install sphinx-lint - - - name: Put translation files in correct place - run: | - cd cpython/Doc/locales/${{ matrix.language }} - mkdir LC_MESSAGES - for pofile in $(find -name '*.po') - do - install -Dm644 -t LC_MESSAGES $pofile - done - name: Set up problem-matcher for sphinx-build uses: sphinx-doc/github-problem-matcher@v1 - name: Build ${{ matrix.language }} translation for Python ${{ inputs.cpython_version }} - run: make -C cpython/Doc venv html SPHINXOPTS='-Dlanguage=${{ matrix.language }} --keep-going -W' + run: make -C cpython/Doc venv html SPHINXOPTS='-Dlanguage=${{ matrix.language }} --keep-going'