Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit79b70e4

Browse files
committed
chore: new build/update workflows
Introduce new workflows and scripts, deprecating previously usedworkflow and Makefile.Worklows: - update.yml: pull translations from Transifex, then commit&push - build.yml: build translated docs and notify on errors - compendium.yml: generate a compendium of all PO filesupdate is scheduled to 11 PM UTC, and will call build and compendiumworkflows as well. All them can also be trigger manually by admins.Scripts: - update.sh: update pot to update .tx/config to update translations - build.sh: use sphinx-build to build translated Python docs - prepmsg.sh: used by build workflow to prepare a notification msgbuild.sh is probably the more interesting script to run outsideGitHub Actions CI environment, although update.sh can be used topull new translations.In case you want to build locally, here the instructions:This implementation expects a CPython checkout in the repositoryroot directory, set to the correct branch. So, one must clone therepository cd python-docs-pt-br git clonehttps://github.com/python/cpythonor update the checkout if existent already cd cpython git pull --rebasethen set the correct translation branch, as 'main' branch isnormally *not* a translation branch. For instance, iftranslation happens in 3.10, make sure to set branch to 3.10 \# from cpython directory git checkout 3.10Now set up a virtual environment, and enter it python3 -m venv venv source venv/bin/activateInstall dependencies pip install -r requirements.txt -r cpython/Doc/requirements.txtAlso, make sure you have 'gettext' installed. For instance, if youare on Ubuntu, run: sudo apt update sudo apt install gettextNow you are ready to use the scripts. To build: scripts/build.shOnce it is built, you can't web browse the HTML files availableat cpython/Doc/build/html/. You can also serve it as a tinyweb server on port 8000 and browse with your web server. Forthis run: python cpython/Tools/scripts/serve.py cpython/Doc/build/html
1 parentb493d3b commit79b70e4

File tree

8 files changed

+377
-0
lines changed

8 files changed

+377
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"problemMatcher": [
3+
{
4+
"owner":"sphinx-problem-matcher",
5+
"pattern": [
6+
{
7+
"regexp":"^(.*):(\\d+):\\s+(\\w*):\\s+(.*)$",
8+
"file":1,
9+
"line":2,
10+
"severity":3,
11+
"message":4
12+
}
13+
]
14+
},
15+
{
16+
"owner":"sphinx-problem-matcher-loose",
17+
"pattern": [
18+
{
19+
"_comment":"A bit of a looser pattern, doesn't look for line numbers, just looks for file names relying on them to start with / and end with .rst",
20+
"regexp":"(\/.*\\.rst):\\s+(\\w*):\\s+(.*)$",
21+
"file":1,
22+
"severity":2,
23+
"message":3
24+
}
25+
]
26+
},
27+
{
28+
"owner":"sphinx-problem-matcher-loose-no-severity",
29+
"pattern": [
30+
{
31+
"_comment":"Looks for file names ending with .rst and line numbers but without severity",
32+
"regexp":"^(.*\\.rst):(\\d+):(.*)$",
33+
"file":1,
34+
"line":2,
35+
"message":3
36+
}
37+
]
38+
}
39+
]
40+
}

‎.github/workflows/build.yml‎

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Build translated docs and notify in case of errors
2+
3+
name:Build
4+
5+
on:
6+
workflow_dispatch:
7+
workflow_call:
8+
secrets:
9+
TELEGRAM_TO:
10+
required:true
11+
TELEGRAM_TOKEN:
12+
required:true
13+
push:
14+
paths:
15+
-'.github/workflows/build.yml'
16+
-'scripts/build.sh'
17+
-'scripts/prepmsg.sh'
18+
-'*.po'
19+
-'**/*.po'
20+
21+
env:
22+
CPYTHON_BRANCH:'3.10'
23+
LANGUAGE:'pt_BR'
24+
25+
jobs:
26+
build:
27+
runs-on:ubuntu-latest
28+
steps:
29+
-name:Check out ${{ github.repository }}
30+
uses:actions/checkout@v2
31+
with:
32+
persist-credentials:false
33+
-name:Check out CPython
34+
uses:actions/checkout@v2
35+
with:
36+
repository:python/cpython
37+
persist-credentials:false
38+
ref:${{ env.CPYTHON_BRANCH }}
39+
path:cpython
40+
-name:Set up Python 3.9
41+
uses:actions/setup-python@v2
42+
with:
43+
python-version:'3.9'
44+
-name:Install dependencies
45+
run:|
46+
sudo apt update -y && sudo apt install gettext -y
47+
pip3 install --upgrade pip
48+
pip3 install -r requirements.txt -r cpython/Doc/requirements.txt
49+
-name:Build docs
50+
run:|
51+
mkdir logs
52+
echo "::add-matcher::.github/problem-matchers/sphinx.json"
53+
sh scripts/build.sh 2> >(tee -a logs/error.log >&2)
54+
env:
55+
LANGUAGE:${{ env.LANGUAGE }}
56+
-name:Prepare notification on error
57+
if:failure()
58+
run:|
59+
sh scripts/prepmsg.sh logs/error.log logs/notify.log
60+
env:
61+
GITHUB_JOB:${{ github.job }}
62+
GITHUB_RUN_ID:${{ github.run_id }}
63+
GITHUB_REPOSITORY:${{ github.repository }}
64+
-name:Notify via Telegram on build errors if any
65+
if:failure()
66+
uses:appleboy/telegram-action@master
67+
with:
68+
to:${{ secrets.TELEGRAM_TO }}
69+
token:${{ secrets.TELEGRAM_TOKEN }}
70+
format:markdown
71+
disable_web_page_preview:true
72+
message_file:logs/notify.log
73+
-name:Upload artifact - docs
74+
if:always()
75+
uses:actions/upload-artifact@v2
76+
with:
77+
name:docs
78+
path:cpython/Doc/build/html
79+
-name:Upload artifact - logs
80+
if:always()
81+
uses:actions/upload-artifact@v2
82+
with:
83+
name:build-logs
84+
path:logs/

‎.github/workflows/compendium.yml‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name:Generate compendium
2+
3+
on:
4+
workflow_dispatch:
5+
workflow_call:
6+
push:
7+
paths:
8+
-'.github/workflows/compendium.yml'
9+
-'*.po'
10+
-'**/*.po'
11+
12+
jobs:
13+
compendium:
14+
runs-on:ubuntu-latest
15+
steps:
16+
-name:Check out ${{ github.repository }}
17+
uses:actions/checkout@v2
18+
with:
19+
persist-credentials:false
20+
-name:Set up Python 3.9
21+
uses:actions/setup-python@v2
22+
with:
23+
python-version:'3.9'
24+
-name:Install dependencies
25+
run:|
26+
sudo apt update -y && sudo apt install gettext -y
27+
pip3 install --upgrade pip
28+
pip3 install translate-toolkit
29+
-name:Generate compendium from PO files
30+
run:|
31+
pocompendium --correct compendium.po *.po **/*.po
32+
-name:Upload artifact
33+
uses:actions/upload-artifact@v2
34+
with:
35+
name:compendium
36+
path:compendium.po

‎.github/workflows/update.yml‎

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
name:Update translations
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
paths:
7+
-'.github/workflows/update.yml'
8+
-'scripts/update.sh'
9+
branches:
10+
-'*'
11+
-'*/*'
12+
-'**'
13+
-'!3.?'
14+
-'!2.*'
15+
schedule:
16+
-cron:'0 23 * * *'
17+
18+
env:
19+
CPYTHON_BRANCH:'3.10'
20+
LANGUAGE:'pt_BR'
21+
22+
jobs:
23+
update:
24+
# Job to pull translation from Transifex platform, and commit & push changes
25+
runs-on:ubuntu-latest
26+
steps:
27+
-name:Check out ${{ github.repository }}
28+
uses:actions/checkout@v2
29+
-name:Check out CPython
30+
uses:actions/checkout@v2
31+
with:
32+
repository:python/cpython
33+
persist-credentials:false
34+
ref:${{ env.CPYTHON_BRANCH }}
35+
path:cpython
36+
-name:Set up Python 3.9
37+
uses:actions/setup-python@v2
38+
with:
39+
python-version:'3.9'
40+
-name:Install dependencies
41+
run:|
42+
sudo apt update -y && sudo apt install gettext -y
43+
pip3 install --upgrade pip
44+
pip3 install -r requirements.txt -r cpython/Doc/requirements.txt
45+
-name:Update translations
46+
run:|
47+
sh scripts/update.sh
48+
env:
49+
TX_TOKEN:${{ secrets.TX_TOKEN }}
50+
LANGUAGE:${{ env.LANGUAGE }}
51+
-name:Wrap catalog message files
52+
run:|
53+
powrap --modified
54+
-name:Commit and push changes
55+
if:github.repository == 'rffontenelle/python-docs-pt-br'
56+
run:|
57+
git config user.name github-actions
58+
git config user.email github-actions@github.com
59+
git status
60+
git add -A
61+
git diff-index --quiet HEAD || ( git commit -m "Update translations from Transifex" && git push )
62+
63+
merge:
64+
# Merge translations previously updated into older branches to make sure
65+
# older versions of Python Docs gets translated as well.
66+
# 'overwrite=true' means strings previously translated will get overwritten;
67+
# other branches will preserve translated strings, only filling in new
68+
# translations.
69+
name:merge into ${{ matrix.branch }}
70+
needs:[update]
71+
strategy:
72+
matrix:
73+
branch:[ 3.9, 3.8, 3.7, 3.6, 2.7 ]
74+
include:
75+
-branch:3.9
76+
overwrite:true
77+
runs-on:ubuntu-latest
78+
steps:
79+
-name:Get current branch name
80+
shell:bash
81+
run:
82+
echo "CURRENT_BRANCH=$(echo ${GITHUB_REF#refs/heads/} | tr / -)" >> $GITHUB_ENV
83+
-name:Check out source branch (${{ env.CURRENT_BRANCH }})
84+
uses:actions/checkout@v2
85+
with:
86+
path:${{ env.CURRENT_BRANCH }}
87+
persist-credentials:false
88+
-name:Check out target branch (${{ matrix.branch }})
89+
uses:actions/checkout@v2
90+
with:
91+
ref:${{ matrix.branch }}
92+
path:${{ matrix.branch }}
93+
-name:Install dependencies
94+
run:|
95+
sudo apt update -y && sudo apt install gettext -y
96+
pip3 install pomerge powrap
97+
-name:Merge overwriting on stable release branch
98+
if:${{ matrix.overwrite == true }}
99+
run:|
100+
pomerge --from ${{ env.CURRENT_BRANCH }}/**/*.po --to ${{ matrix.branch }}/**/*.po
101+
-name:Merge without overwriting on EOL or security-fix release branch
102+
if:${{ matrix.overwrite != true }}
103+
run:|
104+
pomerge --no-overwrite --from ${{ env.CURRENT_BRANCH }}/**/*.po --to ${{ matrix.branch }}/**/*.po
105+
-name:Wrap catalog message files
106+
run:|
107+
powrap --modified -C ${{ matrix.branch }}
108+
-name:Commit and push changes
109+
if:github.repository == 'rffontenelle/python-docs-pt-br'
110+
run:|
111+
cd ${{ matrix.branch }}
112+
git config user.name github-actions
113+
git config user.email github-actions@github.com
114+
git status
115+
git add -A
116+
git diff-index --quiet HEAD || ( git commit -m "Merge ${{ env.CURRENT_BRANCH }} into ${{ matrix.branch }}" && git push )
117+
118+
call-build:
119+
# Call the build workflow after updating
120+
name:call
121+
needs:[update]
122+
uses:rffontenelle/python-docs-pt-br/.github/workflows/build.yml@3.10
123+
secrets:
124+
TELEGRAM_TO:${{ secrets.TELEGRAM_TO }}
125+
TELEGRAM_TOKEN:${{ secrets.TELEGRAM_TOKEN }}
126+
127+
call-compendium:
128+
# Call the compendium workflow after updating
129+
name:call
130+
needs:[update]
131+
uses:rffontenelle/python-docs-pt-br/.github/workflows/compendium.yml@3.10

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
.tx/**/*.po
33
venv/
44
.pospell/
5+
cpython/

‎scripts/build.sh‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/sh
2+
# Build translated version of Python Docs
3+
4+
[-n"$GITHUB_ACTIONS" ]&&set -x
5+
set -e
6+
7+
# Allow language being passed as 1st argument, defaults to pt_BR
8+
LANGUAGE=${1:-pt_BR}
9+
10+
ROOTDIR="$(dirname$0)/.."
11+
12+
cd${ROOTDIR}
13+
14+
test -f cpython/Doc/conf.py|| (echo Unable to find proper CPython Doc folder;exit 1; )
15+
16+
pofiles=$(find. -maxdepth 2 -name'*.po'| sort -u)
17+
18+
forpoin${pofiles};do
19+
install -Dm644${po}"cpython/Doc/locales/${LANGUAGE}/LC_MESSAGES/${po}"
20+
done
21+
22+
sphinx-build -b html -d build/doctrees -q --keep-going -jauto -D locale_dirs=locales -D language=pt_BR -D gettext_compact=0 -D latex_engine=xelatex -D latex_elements.inputenc= -D latex_elements.fontenc= -W cpython/Doc cpython/Doc/build/html
23+
24+
if [-z"$GITHUB_ACTIONS" ];then
25+
echo"See file:/$(realpath${ROOTDIR})/cpython/Doc/build/html/index.html"
26+
echo"or serve it in http://localhost:8080 by running:"
27+
echo"python3 cpython/Tools/scripts/serve.py cpython/Doc/build/html"
28+
fi

‎scripts/prepmsg.sh‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/sh
2+
# Prepare message for Telegram notification
3+
set -ex
4+
5+
[$#-ne 2 ]&& (echo"Expected 1 input and 1 output files, got$#";exit; )
6+
[!-f$1 ]&& (echo"Input file$1 not found, skipping.";exit; )
7+
[-z"${GITHUB_REPOSITORY}" ]&& (echo"GITHUB_REPOSITORY is empty.";exit 1;)
8+
[-z"${GITHUB_RUN_ID}" ]&& (echo"GITHUB_RUN_ID is empty.";exit 1;)
9+
[-z"${GITHUB_JOB}" ]&& (echo"GITHUB_JOB is empty.";exit 1;)
10+
11+
URL="https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
12+
13+
echo"❌ *${GITHUB_JOB}* (ID [${GITHUB_RUN_ID}]($URL)):">$2
14+
echo"">>$2
15+
grep'cpython/Doc/.*WARNING:'$1| \
16+
sed's|.*/cpython/Doc|Doc|'| \
17+
uniq| \
18+
sed's|^|```\n|;s|$|\n```\n|' \
19+
>>$2
20+
echo"">>$2

‎scripts/update.sh‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/sh
2+
# Pull catalog message files from Transifex
3+
4+
[-n"$GITHUB_ACTIONS" ]&&set -x
5+
set -e
6+
7+
# Allow language being passed as 1st argument, defaults to pt_BR
8+
LANGUAGE=${1:-pt_BR}
9+
10+
ROOTDIR=$(dirname$0)/..
11+
12+
cd${ROOTDIR}
13+
14+
if!test -f cpython/Doc/conf.py;then
15+
echo Unable to find proper CPython Doc folder
16+
exit 1
17+
fi
18+
19+
# Create POT Files
20+
cd cpython/Doc
21+
sphinx-build -E -b gettext -D gettext_compact=0 -d build/.doctrees. locales/pot
22+
23+
# Update CPython's .tx/config
24+
cd locales
25+
sphinx-intl create-txconfig
26+
sphinx-intl update-txconfig-resources -p pot -d. --transifex-project-name python-newest
27+
28+
# Update the translation project's .tx/config
29+
cd ../../..# back to $ROOTDIR
30+
mkdir -p .tx
31+
sed cpython/Doc/locales/.tx/config \
32+
-e'/^source_file/d' \
33+
-e's|<lang>/LC_MESSAGES/||' \
34+
-e"s|^file_filter|trans.${LANGUAGE}|" \
35+
> .tx/config
36+
37+
tx pull -l${LANGUAGE} --use-git-timestamps --parallel

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp