Skip to content

Fix ci/cd #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
17 changes: 8 additions & 9 deletions .github/scripts/manage_translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@

RESOURCE_NAME_MAP = {'glossary_': 'glossary'}

LANG = 'uk'

ORGANISATION_ID = 'o:python-doc'
PROJECT_ID = 'o:python-doc:p:python-newest'
LANGUAGE_ID = 'l:uk'
LANGUAGE_ID = f'l:{LANG}'
ORGANISATION = transifex_api.Organization.get(id=ORGANISATION_ID)
PROJECT = transifex_api.Project.get(id=PROJECT_ID)
LANGUAGE = transifex_api.Language.get(id=LANGUAGE_ID)
Expand Down Expand Up @@ -46,6 +48,10 @@ def recreate_config() -> None:
f'file_filter = {path}\n',
'type = PO\n',
'source_lang = en\n',
'minimum_perc = 0\n',
f'trans.{LANG} = {path}\n',
f'source_file = {path}\n',
f'resource_name = {resource.name}\n'
))


Expand Down Expand Up @@ -88,15 +94,8 @@ def recreate_team_stats() -> None:
fo.writelines(f"| {user} | {role} | {translators[user]} | {reviewers[user]} | {proofreaders[user]} |\n")


def fetch_translations():
"""Fetch translations from Transifex, remove source lines."""
pull_return_code = os.system(f'tx pull -l uk --force --skip')
if pull_return_code != 0:
exit(pull_return_code)


if __name__ == "__main__":
RUNNABLE_SCRIPTS = ('recreate_config', 'recreate_resource_stats', 'recreate_team_stats', 'fetch_translations')
RUNNABLE_SCRIPTS = ('recreate_config', 'recreate_resource_stats', 'recreate_team_stats', 'fetch_translations', 'format_translations')

parser = ArgumentParser()
parser.add_argument('cmd', nargs=1, choices=RUNNABLE_SCRIPTS)
Expand Down
44 changes: 33 additions & 11 deletions .github/workflows/update-and-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ on:
- cron: '0 6 * * *'
push:
branches: ['main']
pull_request:
branches: ['main']
workflow_dispatch:

jobs:

update-translation:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
steps:
Expand All @@ -22,38 +24,57 @@ jobs:
with:
python-version: 3
- run: sudo apt-get install -y gettext
- run: pip install transifex-python six sphinx-intl blurb
- run: curl -o- https://raw.githubusercontent.com/transifex/cli/master/install.sh | bash
working-directory: /usr/local/bin
- run: pip install requests cogapp polib transifex-python sphinx-lint sphinx-intl blurb six
- uses: actions/checkout@master
with:
ref: ${{ matrix.version }}
- run: .github/scripts/manage_translation.py recreate_config
- run: git clone --branch main --single-branch --depth 1 https://github.com/python/cpython.git
- run: make -C cpython/Doc/ gettext
- run: sphinx-intl create-txconfig
working-directory: cpython/Doc/build
- run: sphinx-intl update-txconfig-resources --transifex-organization-name python-doc --transifex-project-name python-newest -d . -p gettext
working-directory: cpython/Doc/build
env:
TX_TOKEN: ${{ secrets.TX_TOKEN }}
- run: .github/scripts/manage_translation.py fetch_translations
- run: tx pull -l uk --force --skip
working-directory: cpython/Doc/build
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"
- run: git add .
- run: git commit -m 'Update translation from Transifex' || true
- run: find -name "*.po" -exec msgcat --no-location -o {} {} \;
- run: |
git config --local user.email [email protected]
git config --local user.name "GitHub Action's update-translation job"
git add .
git commit -m 'Update translation from Transifex' || true
working-directory: cpython/Doc/build/uk/LC_MESSAGES
- uses: ad-m/github-push-action@master
with:
branch: ${{ matrix.version }}
github_token: ${{ secrets.GITHUB_TOKEN }}
- uses: peter-evans/repository-dispatch@main

lint-translation:
runs-on: ubuntu-latest
strategy:
matrix:
version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
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 }}
- uses: rffontenelle/[email protected]
- run: sphinx-lint

build-translation:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
format: [html, latex]
Expand All @@ -77,14 +98,15 @@ jobs:
- uses: sphinx-doc/[email protected]
- run: make -e SPHINXOPTS=" -D language='uk' -W --keep-going" ${{ matrix.format }}
working-directory: ./Doc
- run: make sphinx-lint
- uses: actions/upload-artifact@master
with:
name: build-${{ matrix.version }}-${{ matrix.format }}
path: Doc/build/${{ matrix.format }}

output-pdf:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
needs: ['build-translation']
Expand Down
Loading