Skip to content

Translation and Linting Workflow #34475

Translation and Linting Workflow

Translation and Linting Workflow #34475

name: Translation and Linting Workflow
on:
schedule:
- cron: '*/30 * * * *'
push:
branches:
- '*'
workflow_dispatch:
jobs:
update-translation:
runs-on: ubuntu-latest
strategy:
matrix:
version: [3.13, 3.12, 3.11, '3.10', 3.9, 3.8]
steps:
- uses: styfle/cancel-workflow-action@main
with:
access_token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-python@master
with:
python-version: 3
- run: sudo apt-get install -y gettext
- run: pip install requests cogapp polib transifex-python sphinx-intl blurb six
- run: curl -o- https://raw.githubusercontent.com/transifex/cli/master/install.sh | bash
working-directory: /usr/local/bin
- uses: actions/checkout@master
with:
ref: ${{ matrix.version }}
fetch-depth: 0
- run: ./manage_translation.py recreate_tx_config
env:
TX_TOKEN: ${{ secrets.TX_TOKEN }}
- run: ./manage_translation.py fetch
env:
TX_TOKEN: ${{ secrets.TX_TOKEN }}
# Process README.md
- run: python -Werror -m cogapp -rP README.md
env:
TX_TOKEN: ${{ secrets.TX_TOKEN }}
# Process README.en.md
- run: python -Werror -m cogapp -rP README.en.md
if: ${{ hashFiles('README.en.md') != '' }}
env:
TX_TOKEN: ${{ secrets.TX_TOKEN }}
- run: git config --local user.email [email protected]
- run: git config --local user.name "GitHub Action's update-translation job"
# Check for changes in README.md
- run: >
! git diff -I'^"POT-Creation-Date: ' -I'^"Language-Team: ' -I'^# Copyright (C) 2001-' --exit-code && echo "SIGNIFICANT_CHANGES=1" >> $GITHUB_ENV || exit 0
- run: >
! git diff -G'\!\[[0-9]{2,3}\.[0-9]{2}% przełącznika języków\]' --exit-code README.md && echo "SWITCHER_PROGRESS=1" >> $GITHUB_ENV || exit 0
- run: git add .
- run: git commit -m 'Update translation from Transifex'
if: env.SIGNIFICANT_CHANGES
- run: pip install gitpython matplotlib
if: env.SWITCHER_PROGRESS
- run: python update_switcher_chart.py
if: env.SWITCHER_PROGRESS
- run: git add .
if: env.SWITCHER_PROGRESS
- run: git commit -m 'Update switcher progress chart'
if: env.SWITCHER_PROGRESS
- uses: ad-m/github-push-action@master
if: env.SIGNIFICANT_CHANGES
with:
branch: ${{ matrix.version }}
github_token: ${{ secrets.GITHUB_TOKEN }}
- uses: peter-evans/repository-dispatch@main
with:
token: ${{ secrets.GITHUB_TOKEN }}
event-type: translation-updated
lint:
runs-on: ubuntu-latest
strategy:
matrix:
version: [3.13, 3.12, 3.11]
needs: ['update-translation']
continue-on-error: true
steps:
- uses: actions/setup-python@master
with:
python-version: 3
- run: pip install sphinx-lint
- uses: actions/checkout@master
with:
ref: ${{ matrix.version }}
- run: sphinx-lint
build-translation:
runs-on: ubuntu-latest
strategy:
matrix:
version: [3.13, 3.12, 3.11, '3.10', 3.9, 3.8]
format: [html, latex]
needs: ['update-translation']
steps:
- uses: actions/setup-python@master
with:
python-version: 3
- uses: actions/checkout@master
with:
repository: python/cpython
ref: ${{ matrix.version }}
- run: make venv
working-directory: ./Doc
- uses: actions/checkout@master
with:
ref: ${{ matrix.version }}
path: Doc/locales/pl/LC_MESSAGES
- run: git pull
working-directory: ./Doc/locales/pl/LC_MESSAGES
- run: make -e SPHINXOPTS="-D language='pl' -D gettext_compact=0 -W --keep-going" ${{ matrix.format }}
working-directory: ./Doc
- uses: actions/upload-artifact@master
with:
name: build-${{ matrix.version }}-${{ matrix.format }}
path: Doc/build/${{ matrix.format }}
output-pdf:
runs-on: ubuntu-latest
strategy:
matrix:
version: [3.13, 3.12, 3.11, '3.10', 3.9, 3.8]
needs: ['build-translation']
steps:
- uses: actions/download-artifact@master
with:
name: build-${{ matrix.version }}-latex
- run: sudo apt-get update
- run: sudo apt-get install -y latexmk texlive-xetex fonts-freefont-otf xindy
- run: make
- uses: actions/upload-artifact@master
with:
name: build-${{ matrix.version }}-pdf
path: .