Skip to content

Commit 6a595f0

Browse files
committed
Fix ci/cd
1 parent 7eb1de4 commit 6a595f0

File tree

3 files changed

+38
-10
lines changed

3 files changed

+38
-10
lines changed

.github/scripts/manage_translation.py

+14-5
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

@@ -90,13 +96,16 @@ def recreate_team_stats() -> None:
9096

9197
def fetch_translations():
9298
"""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)
99+
return_code = os.system(f'./tx pull -l {LANG} --force --skip')
100+
exit(return_code)
96101

102+
def format_translations():
103+
"""Format translations using 'msgcat' from 'gettext'"""
104+
return_code = os.system('find -name "*.po" -exec msgcat --no-location -o {} {} \;')
105+
exit(return_code)
97106

98107
if __name__ == "__main__":
99-
RUNNABLE_SCRIPTS = ('recreate_config', 'recreate_resource_stats', 'recreate_team_stats', 'fetch_translations')
108+
RUNNABLE_SCRIPTS = ('recreate_config', 'recreate_resource_stats', 'recreate_team_stats', 'fetch_translations', 'format_translations')
100109

101110
parser = ArgumentParser()
102111
parser.add_argument('cmd', nargs=1, choices=RUNNABLE_SCRIPTS)

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

+19-5
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:
@@ -22,9 +24,9 @@ jobs:
2224
with:
2325
python-version: 3
2426
- run: sudo apt-get install -y gettext
27+
- run: pip install transifex-python six
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:
3032
ref: ${{ matrix.version }}
@@ -34,6 +36,7 @@ jobs:
3436
- run: .github/scripts/manage_translation.py fetch_translations
3537
env:
3638
TX_TOKEN: ${{ secrets.TX_TOKEN }}
39+
- run: find -name "*.po" -exec msgcat --no-location -o {} {} \;
3740
- run: git config --local user.email github-actions@github.com
3841
- run: git config --local user.name "GitHub Action's update-translation job"
3942
- run: git add .
@@ -42,18 +45,28 @@ jobs:
4245
with:
4346
branch: ${{ matrix.version }}
4447
github_token: ${{ secrets.GITHUB_TOKEN }}
45-
- uses: peter-evans/repository-dispatch@main
48+
49+
lint-translation:
50+
runs-on: ubuntu-latest
51+
strategy:
52+
matrix:
53+
version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
54+
needs: ['update-translation']
55+
continue-on-error: true
56+
steps:
57+
- uses: actions/setup-python@master
4658
with:
4759
python-version: 3
60+
- run: pip install sphinx-lint
4861
- uses: actions/checkout@master
4962
with:
5063
ref: ${{ matrix.version }}
5164
- uses: rffontenelle/sphinx-lint-problem-matcher@v1.0.0
5265
- run: sphinx-lint
66+
5367
build-translation:
5468
runs-on: ubuntu-latest
5569
strategy:
56-
fail-fast: false
5770
matrix:
5871
version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
5972
format: [html, latex]
@@ -77,14 +90,15 @@ jobs:
7790
- uses: sphinx-doc/github-problem-matcher@v1.1
7891
- run: make -e SPHINXOPTS=" -D language='uk' -W --keep-going" ${{ matrix.format }}
7992
working-directory: ./Doc
93+
- run: make sphinx-lint
8094
- uses: actions/upload-artifact@master
8195
with:
8296
name: build-${{ matrix.version }}-${{ matrix.format }}
8397
path: Doc/build/${{ matrix.format }}
98+
8499
output-pdf:
85100
runs-on: ubuntu-latest
86101
strategy:
87-
fail-fast: false
88102
matrix:
89103
version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
90104
needs: ['build-translation']

Makefile

+5
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

0 commit comments

Comments
 (0)