Skip to content

Update 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

Merged
merged 1 commit into from
May 1, 2025
Merged
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
Jump to file
Failed to load files.
Loading
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')

parser = ArgumentParser()
parser.add_argument('cmd', nargs=1, choices=RUNNABLE_SCRIPTS)
Expand Down
65 changes: 47 additions & 18 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 @@ -20,48 +22,74 @@ jobs:
access_token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-python@master
with:
python-version: 3
- run: sudo apt-get install -y gettext
python-version: '3.12'
- run: sudo apt-get install -y gettext rsync
- 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
repository: python/cpython
ref: main
- run: make gettext
working-directory: ./Doc
- run: sphinx-intl create-txconfig
working-directory: ./Doc/build
- run: sphinx-intl update-txconfig-resources --transifex-organization-name python-doc --transifex-project-name python-newest -d . -p gettext
working-directory: ./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: ./Doc/build
env:
TX_TOKEN: ${{ secrets.TX_TOKEN }}
- run: git config --local user.email github-actions@github.com
- 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 {} {} \;
working-directory: ./Doc/build
- uses: actions/checkout@master
with:
ref: ${{ matrix.version }}
path: ./Doc/build/uk/LC_MESSAGES
- run: |
git config --local user.email github-actions@github.com
git config --local user.name "GitHub Action's update-translation job"
git add -f .
git commit -m 'Update translation from Transifex' || true
working-directory: ./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
directory: ./Doc/build/uk/LC_MESSAGES

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
python-version: '3.12'
- run: pip install sphinx-lint
- uses: actions/checkout@master
with:
ref: ${{ matrix.version }}
- uses: rffontenelle/sphinx-lint-problem-matcher@v1.0.0
- 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]
needs: ['update-translation']
steps:
- uses: actions/setup-python@master
with:
python-version: 3.12 # pin for Sphinx 3.4.3 in 3.10 branch (see #63)
python-version: '3.12'
- uses: actions/checkout@master
with:
repository: python/cpython
Expand All @@ -75,16 +103,17 @@ jobs:
- run: git pull
working-directory: ./Doc/locales/uk/LC_MESSAGES
- uses: sphinx-doc/github-problem-matcher@v1.1
- run: make -e SPHINXOPTS=" -D language='uk' -W --keep-going" ${{ matrix.format }}
- run: make -e SPHINXOPTS="-D language='uk' -D gettext_compact=0 --keep-going --color" SPHINXERRORHANDLING="" ${{ matrix.format }}
working-directory: ./Doc
- uses: actions/upload-artifact@master
if: success() || failure()
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 All @@ -94,7 +123,7 @@ jobs:
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 -i
- run: make
- uses: actions/upload-artifact@master
with:
name: build-${{ matrix.version }}-pdf
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ ensure_prerequisites:
exit 1; \
fi

.PHONY: sphinx-lint
sphinx-lint:
@echo "Checking all files using sphinx-lint..."
@sphinx-lint --enable all --disable line-too-long **/*.po

.PHONY: serve
serve:
$(MAKE) -C $(CPYTHON_PATH)/Doc/ serve
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Python Software Foundation [по ліцензії CC0](https://creativecommons.o

**Оновлення локального перекладу**
* `.github/scripts/manage_translation.py recreate_config`
* `.github/scripts/manage_translation.py fetch_translations`
* `tx pull -l uk --force --skip`

**Подяка**
* Maciej Olko - Polish team
Expand Down
Loading
Loading