Skip to content

Commit ff06042

Browse files
Improve ci (#40)
* Use new Transifex CLI tool The Python implementation named transifex-client uses Transifex's APIv2, which is deprecated and will sunset in november 2022. The new tool, called Transifex CLI, is written in Golang and is APIv3-ready. So adjusting the CI and requirements.txt is required. * Fix condition in the merge job Having the proper condition is important to have the translation update in the latest Python version (python-newest project), and the condition wouldn't match the current repository. Co-authored-by: Maciej Olko <[email protected]> * Update sphinx-intl required version Last released sphinx-intl uses old transifex-client, which uses the deprecated Transifex APIv2. There is a fix committed, but it is unreleased. So using specific commit where new Transifex CLI tool works. * Update script to work with the new TX command Previous solution of patching .tx/config does not work with the new client, so the script had to be updated with new solution. Now, translations are pulled into a sub-directory of cpython, and then installed in the languages's repository. Also using 'realpath' tool in ROOTDIR to retrieve absolute path, which actually eases referencing the repository root directory. * Update actions versions One of the reason is that some of them use node.js 12, which is now deprecated. Actions is displaying warnings about it. v4 of setup-python is particular useful because it introduces package caching, which reduces the time of workflow run. * Disable pushing translations Source files auto-update is now done elsewhere Co-authored-by: Maciej Olko <[email protected]>
1 parent 5a36eec commit ff06042

File tree

3 files changed

+30
-26
lines changed

3 files changed

+30
-26
lines changed

Diff for: .github/workflows/update.yml

+18-6
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,24 @@ jobs:
2323
runs-on: ubuntu-latest
2424
steps:
2525
- name: Check out ${{ github.repository }}
26-
uses: actions/checkout@v2
26+
uses: actions/checkout@v3
2727
- name: Check out CPython
28-
uses: actions/checkout@v2
28+
uses: actions/checkout@v3
2929
with:
3030
repository: python/cpython
3131
persist-credentials: false
3232
ref: ${{ env.CPYTHON_BRANCH }}
3333
path: cpython
3434
- name: Set up Python 3.9
35-
uses: actions/setup-python@v2
35+
uses: actions/setup-python@v4
3636
with:
3737
python-version: '3.9'
38+
cache: 'pip'
39+
cache-dependency-path: '**/requirements*.txt'
40+
- name: Install Transifex CLI
41+
run: |
42+
curl -o- https://raw.githubusercontent.com/transifex/cli/master/install.sh | bash
43+
working-directory: /usr/local/bin
3844
- name: Install dependencies
3945
run: |
4046
sudo apt update -y && sudo apt install gettext -y
@@ -79,14 +85,20 @@ jobs:
7985
run:
8086
echo "CURRENT_BRANCH=$(echo ${GITHUB_REF#refs/heads/} | tr / -)" >> $GITHUB_ENV
8187
- name: Check out source branch (${{ env.CURRENT_BRANCH }})
82-
uses: actions/checkout@v1
88+
uses: actions/checkout@v3
8389
with:
8490
path: ${{ env.CURRENT_BRANCH }}
8591
- name: Check out target branch (${{ matrix.branch }})
86-
uses: actions/checkout@v2
92+
uses: actions/checkout@v3
8793
with:
8894
ref: ${{ matrix.branch }}
8995
path: ${{ matrix.branch }}
96+
- name: Set up Python 3.9
97+
uses: actions/setup-python@v4
98+
with:
99+
python-version: '3.9'
100+
cache: 'pip'
101+
cache-dependency-path: '**/requirements*.txt'
90102
- name: Install dependencies
91103
run: |
92104
sudo apt update -y && sudo apt install gettext -y
@@ -103,7 +115,7 @@ jobs:
103115
run: |
104116
powrap --modified -C ${{ matrix.branch }}
105117
- name: Commit and push changes
106-
if: github.repository == 'rffontenelle/python-docs-pt-br'
118+
if: github.repository == 'python/python-docs-ja'
107119
run: |
108120
cd ${{ matrix.branch }}
109121
git config user.name github-actions

Diff for: requirements.txt

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
transifex-client
21
sphinx
3-
sphinx-intl
2+
git+https://github.com/sphinx-doc/sphinx-intl@6b3913fea5a8c9b819818b9b28b6d0d0b6f022b3
43
powrap
54
pospell
65
pomerge

Diff for: scripts/update.sh

+11-18
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ set -e
77
# Allow language being passed as 1st argument, defaults to ja
88
LANGUAGE=${1:-ja}
99

10-
ROOTDIR=$(dirname $0)/..
10+
ROOTDIR=$(realpath "$(dirname $0)/..")
1111

12-
cd ${ROOTDIR}
12+
cd "${ROOTDIR}"
1313

1414
if ! test -f cpython/Doc/conf.py; then
1515
echo Unable to find proper CPython Doc folder
@@ -21,22 +21,15 @@ cd cpython/Doc
2121
sphinx-build -E -b gettext -D gettext_compact=0 -d build/.doctrees . locales/pot
2222

2323
# Update CPython's .tx/config
24-
cd locales
24+
cd locales
2525
sphinx-intl create-txconfig
26-
sphinx-intl update-txconfig-resources -p pot -d . --transifex-project-name python-newest
26+
sphinx-intl update-txconfig-resources -p pot -d . --transifex-organization-name python-doc --transifex-project-name python-newest
2727

28-
if [ "$CI" = true ]
29-
then
30-
tx push --source --no-interactive --skip
31-
fi
32-
33-
# Update the translation project's .tx/config
34-
cd ../../.. # back to $ROOTDIR
35-
mkdir -p .tx
36-
sed cpython/Doc/locales/.tx/config \
37-
-e '/^source_file/d' \
38-
-e 's|<lang>/LC_MESSAGES/||' \
39-
-e "s|^file_filter|trans.${LANGUAGE}|" \
40-
> .tx/config
28+
# Pull translations into cpython/Doc/locales/LANGUAGE/LC_MESSAGES/
29+
tx pull -l ${LANGUAGE} -t --use-git-timestamps
4130

42-
tx pull -l ${LANGUAGE} --use-git-timestamps --parallel
31+
# Finally, move downloaded translation files to the language's repository
32+
cd "${LANGUAGE}/LC_MESSAGES/"
33+
for po in $(find . -type f -name '*.po' | sort | sed 's|^\./||'); do
34+
install -Dm644 ${po} "${ROOTDIR}/${po}"
35+
done

0 commit comments

Comments
 (0)