Skip to content

Commit f4f7d73

Browse files
authored
Fix ci/cd (#26)
1 parent 7eb1de4 commit f4f7d73

File tree

5 files changed

+514
-474
lines changed

5 files changed

+514
-474
lines changed

.github/scripts/manage_translation.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@
1515

1616
RESOURCE_NAME_MAP = {'glossary_': 'glossary'}
1717

18+
LANG = 'uk'
19+
1820
ORGANISATION_ID = 'o:python-doc'
1921
PROJECT_ID = 'o:python-doc:p:python-newest'
20-
LANGUAGE_ID = 'l:uk'
22+
LANGUAGE_ID = f'l:{LANG}'
2123
ORGANISATION = transifex_api.Organization.get(id=ORGANISATION_ID)
2224
PROJECT = transifex_api.Project.get(id=PROJECT_ID)
2325
LANGUAGE = transifex_api.Language.get(id=LANGUAGE_ID)
@@ -46,6 +48,10 @@ def recreate_config() -> None:
4648
f'file_filter = {path}\n',
4749
'type = PO\n',
4850
'source_lang = en\n',
51+
'minimum_perc = 0\n',
52+
f'trans.{LANG} = {path}\n',
53+
f'source_file = {path}\n',
54+
f'resource_name = {resource.name}\n'
4955
))
5056

5157

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

9096

91-
def fetch_translations():
92-
"""Fetch translations from Transifex, remove source lines."""
93-
pull_return_code = os.system(f'tx pull -l uk --force --skip')
94-
if pull_return_code != 0:
95-
exit(pull_return_code)
96-
97-
9897
if __name__ == "__main__":
99-
RUNNABLE_SCRIPTS = ('recreate_config', 'recreate_resource_stats', 'recreate_team_stats', 'fetch_translations')
98+
RUNNABLE_SCRIPTS = ('recreate_config', 'recreate_resource_stats', 'recreate_team_stats')
10099

101100
parser = ArgumentParser()
102101
parser.add_argument('cmd', nargs=1, choices=RUNNABLE_SCRIPTS)

.github/workflows/update-and-build.yml

Lines changed: 47 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ on:
55
- cron: '0 6 * * *'
66
push:
77
branches: ['main']
8+
pull_request:
9+
branches: ['main']
810
workflow_dispatch:
911

1012
jobs:
13+
1114
update-translation:
1215
runs-on: ubuntu-latest
1316
strategy:
14-
fail-fast: false
1517
matrix:
1618
version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
1719
steps:
@@ -20,48 +22,74 @@ jobs:
2022
access_token: ${{ secrets.GITHUB_TOKEN }}
2123
- uses: actions/setup-python@master
2224
with:
23-
python-version: 3
24-
- run: sudo apt-get install -y gettext
25+
python-version: '3.12'
26+
- run: sudo apt-get install -y gettext rsync
27+
- run: pip install transifex-python six sphinx-intl blurb
2528
- run: curl -o- https://raw.githubusercontent.com/transifex/cli/master/install.sh | bash
2629
working-directory: /usr/local/bin
27-
- run: pip install requests cogapp polib transifex-python sphinx-lint sphinx-intl blurb six
2830
- uses: actions/checkout@master
2931
with:
30-
ref: ${{ matrix.version }}
31-
- run: .github/scripts/manage_translation.py recreate_config
32+
repository: python/cpython
33+
ref: main
34+
- run: make gettext
35+
working-directory: ./Doc
36+
- run: sphinx-intl create-txconfig
37+
working-directory: ./Doc/build
38+
- run: sphinx-intl update-txconfig-resources --transifex-organization-name python-doc --transifex-project-name python-newest -d . -p gettext
39+
working-directory: ./Doc/build
3240
env:
3341
TX_TOKEN: ${{ secrets.TX_TOKEN }}
34-
- run: .github/scripts/manage_translation.py fetch_translations
42+
- run: tx pull -l uk --force --skip
43+
working-directory: ./Doc/build
3544
env:
3645
TX_TOKEN: ${{ secrets.TX_TOKEN }}
37-
- run: git config --local user.email [email protected]
38-
- run: git config --local user.name "GitHub Action's update-translation job"
39-
- run: git add .
40-
- run: git commit -m 'Update translation from Transifex' || true
46+
- run: find -name "*.po" -exec msgcat --no-location -o {} {} \;
47+
working-directory: ./Doc/build
48+
- uses: actions/checkout@master
49+
with:
50+
ref: ${{ matrix.version }}
51+
path: ./Doc/build/uk/LC_MESSAGES
52+
- run: |
53+
git config --local user.email [email protected]
54+
git config --local user.name "GitHub Action's update-translation job"
55+
git add -f .
56+
git commit -m 'Update translation from Transifex' || true
57+
working-directory: ./Doc/build/uk/LC_MESSAGES
4158
- uses: ad-m/github-push-action@master
4259
with:
4360
branch: ${{ matrix.version }}
4461
github_token: ${{ secrets.GITHUB_TOKEN }}
45-
- uses: peter-evans/repository-dispatch@main
62+
directory: ./Doc/build/uk/LC_MESSAGES
63+
64+
lint-translation:
65+
runs-on: ubuntu-latest
66+
strategy:
67+
matrix:
68+
version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
69+
needs: ['update-translation']
70+
continue-on-error: true
71+
steps:
72+
- uses: actions/setup-python@master
4673
with:
47-
python-version: 3
74+
python-version: '3.12'
75+
- run: pip install sphinx-lint
4876
- uses: actions/checkout@master
4977
with:
5078
ref: ${{ matrix.version }}
5179
- uses: rffontenelle/[email protected]
5280
- run: sphinx-lint
81+
5382
build-translation:
5483
runs-on: ubuntu-latest
5584
strategy:
56-
fail-fast: false
5785
matrix:
5886
version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
5987
format: [html, latex]
6088
needs: ['update-translation']
6189
steps:
6290
- uses: actions/setup-python@master
6391
with:
64-
python-version: 3.12 # pin for Sphinx 3.4.3 in 3.10 branch (see #63)
92+
python-version: '3.12'
6593
- uses: actions/checkout@master
6694
with:
6795
repository: python/cpython
@@ -75,16 +103,17 @@ jobs:
75103
- run: git pull
76104
working-directory: ./Doc/locales/uk/LC_MESSAGES
77105
- uses: sphinx-doc/[email protected]
78-
- run: make -e SPHINXOPTS=" -D language='uk' -W --keep-going" ${{ matrix.format }}
106+
- run: make -e SPHINXOPTS="-D language='uk' -D gettext_compact=0 --keep-going --color" SPHINXERRORHANDLING="" ${{ matrix.format }}
79107
working-directory: ./Doc
80108
- uses: actions/upload-artifact@master
109+
if: success() || failure()
81110
with:
82111
name: build-${{ matrix.version }}-${{ matrix.format }}
83112
path: Doc/build/${{ matrix.format }}
113+
84114
output-pdf:
85115
runs-on: ubuntu-latest
86116
strategy:
87-
fail-fast: false
88117
matrix:
89118
version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
90119
needs: ['build-translation']
@@ -94,7 +123,7 @@ jobs:
94123
name: build-${{ matrix.version }}-latex
95124
- run: sudo apt-get update
96125
- run: sudo apt-get install -y latexmk texlive-xetex fonts-freefont-otf xindy
97-
- run: make -i
126+
- run: make
98127
- uses: actions/upload-artifact@master
99128
with:
100129
name: build-${{ matrix.version }}-pdf

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ ensure_prerequisites:
102102
exit 1; \
103103
fi
104104

105+
.PHONY: sphinx-lint
106+
sphinx-lint:
107+
@echo "Checking all files using sphinx-lint..."
108+
@sphinx-lint --enable all --disable line-too-long **/*.po
109+
105110
.PHONY: serve
106111
serve:
107112
$(MAKE) -C $(CPYTHON_PATH)/Doc/ serve

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Python Software Foundation [по ліцензії CC0](https://creativecommons.o
4949

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

5454
**Подяка**
5555
* Maciej Olko - Polish team

0 commit comments

Comments
 (0)