diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml new file mode 100644 index 00000000000..19a9e09fdff --- /dev/null +++ b/.github/workflows/check.yml @@ -0,0 +1,69 @@ +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 + 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: + runs-on: ubuntu-latest + permissions: + contents: read + strategy: + max-parallel: 4 + fail-fast: false + matrix: + language: ${{fromJson(inputs.languages)}} + steps: + - name: Check out ${{ github.repository }} + uses: actions/checkout@v4.2.1 + + - name: Check out ${{ inputs.cpython_version }} branch of CPython + uses: actions/checkout@v4.2.1 + with: + repository: python/cpython + persist-credentials: false + ref: ${{ inputs.cpython_version }} + path: cpython + + - name: Check out ${{ inputs.cpython_version }} branch of ${{ github.repository }} + uses: actions/checkout@v4.2.1 + with: + ref: ${{ inputs.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@v1 + + - name: Build ${{ matrix.language }} translation for Python ${{ inputs.cpython_version }} + run: make -C cpython/Doc venv html SPHINXOPTS='-Dlanguage=${{ matrix.language }} --keep-going' diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 95e6d3813e2..458a6c8a3f6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -78,203 +78,11 @@ 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 + needs: trigger + with: + cpython_version: ${{ needs.trigger.outputs.current }} + languages: ${{ needs.trigger.outputs.languages }} + secrets: inherit