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

Commit76451e7

Browse files
committed
Refactor github actions
+ just use shell scripts, not docker image.+ rewrite transifex pull command to speed up.+ show error message with logging commands.
1 parentd499d11 commit76451e7

File tree

13 files changed

+123
-104
lines changed

13 files changed

+123
-104
lines changed

‎.github/actions/commit/Dockerfile

Lines changed: 0 additions & 10 deletions
This file was deleted.

‎.github/actions/commit/action.yml

Lines changed: 0 additions & 5 deletions
This file was deleted.

‎.github/actions/commit/entrypoint.sh

Lines changed: 0 additions & 13 deletions
This file was deleted.

‎.github/actions/update/Dockerfile

Lines changed: 0 additions & 12 deletions
This file was deleted.

‎.github/actions/update/action.yml

Lines changed: 0 additions & 16 deletions
This file was deleted.

‎.github/actions/update/entrypoint.sh

Lines changed: 0 additions & 36 deletions
This file was deleted.

‎.github/scripts/build.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
set -e
4+
set -o pipefail
5+
6+
error() {
7+
whileread -r line;do
8+
echo
9+
echo ::error::"$line"
10+
done
11+
}
12+
13+
cd cpython/Doc||exit 1
14+
mkdir -p locales/"$LOCALE"/
15+
ln -sfn"$(realpath ../../docs)" locales/"$LOCALE"/LC_MESSAGES
16+
make venv
17+
make html SPHINXOPTS="-D language=$LOCALE -D gettext_compact=0 -W --keep-going -j2"2>>(error)

‎.github/scripts/commit.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
set -ex
4+
5+
cd docs||exit 1
6+
git config user.email"github-actions[bot]@users.noreply.github.com"
7+
git config user.name"github-actions[bot]"
8+
if! git status -s|grep'\.po';then
9+
echo"Nothing to commit"
10+
exit 0
11+
fi
12+
git add.
13+
git commit -m'[po] auto sync'
14+
header="$(echo -n token:"$GITHUB_TOKEN"| base64)"
15+
git -c http.extraheader="AUTHORIZATION: basic$header" push

‎.github/scripts/prepare.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
set -ex
4+
5+
git clone --depth=1 --branch="$VERSION" https://github.com/python/cpython cpython
6+
git clone --branch="$VERSION" https://github.com/"$GITHUB_REPOSITORY" docs
7+
8+
pip3 install --user setuptools
9+
pip3 install --user transifex-client
10+
sudo apt-get update
11+
sudo apt-get install -y python3-venv

‎.github/scripts/transifex_pull.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env python3
2+
3+
fromtxclibimportproject
4+
fromtxclib.utilsimportperform_parallel_requests
5+
6+
7+
defpull(path,lang):
8+
skip_decode=False
9+
params= {}
10+
parallel=True
11+
12+
prj=project.Project(path)
13+
resource_list=prj.get_chosen_resources([])
14+
forresourceinresource_list:
15+
project_slug,resource_slug=resource.split(".",1)
16+
host=prj.get_resource_host(resource)
17+
prj._set_url_info(host=host,project=project_slug,resource=resource_slug)
18+
19+
files=prj.get_resource_files(resource)
20+
url=prj._get_url_by_pull_mode(None)
21+
local_file=files.get(lang)
22+
prj.do_url_request(
23+
url,
24+
language=lang,
25+
skip_decode=skip_decode,
26+
params=params,
27+
parallel=parallel,
28+
callback=prj._save_file,
29+
callback_args={"local_file":local_file},
30+
)
31+
32+
perform_parallel_requests()
33+
34+
35+
if__name__=="__main__":
36+
importos
37+
38+
pull(os.getcwd(),os.getenv("LOCALE","zh_CN"))

‎.github/scripts/update.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
set -ex
4+
5+
script_dir="$(dirname"$(realpath"$0")")"
6+
7+
if [[-n"$TRANSIFEX_APIKEY" ]];then
8+
cat>~/.transifexrc<<EOF
9+
[https://www.transifex.com]
10+
api_hostname = https://api.transifex.com
11+
hostname = https://www.transifex.com
12+
password =$TRANSIFEX_APIKEY
13+
username = api
14+
EOF
15+
fi
16+
17+
cd docs||exit 1
18+
"$script_dir"/transifex_pull.py

‎.github/workflows/python-37.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,24 @@ on:
88
-cron:"38 * * * *"
99

1010
jobs:
11-
update:
11+
sync:
1212
runs-on:ubuntu-latest
13+
env:
14+
LOCALE:zh_CN
15+
VERSION:"3.7"
1316
steps:
1417
-uses:actions/checkout@v1
1518
with:
1619
fetch-depth:1
17-
-uses:./.github/actions/update
18-
with:
19-
pythonVersion:"3.7"
20-
locale:zh_CN
20+
-name:prepare
21+
run:.github/scripts/prepare.sh
22+
-name:update
23+
run:.github/scripts/update.sh
2124
env:
2225
TRANSIFEX_APIKEY:${{ secrets.TRANSIFEX_APIKEY }}
23-
-uses:./.github/actions/commit
26+
-name:build
27+
run:.github/scripts/build.sh
28+
-name:commit
29+
run:.github/scripts/commit.sh
2430
env:
2531
GITHUB_TOKEN:${{ secrets.GITHUB_TOKEN }}

‎.github/workflows/python-38.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,24 @@ on:
88
-cron:"18 * * * *"
99

1010
jobs:
11-
update:
11+
sync:
1212
runs-on:ubuntu-latest
13+
env:
14+
LOCALE:zh_CN
15+
VERSION:"3.8"
1316
steps:
1417
-uses:actions/checkout@v1
1518
with:
1619
fetch-depth:1
17-
-uses:./.github/actions/update
18-
with:
19-
pythonVersion:"3.8"
20-
locale:zh_CN
20+
-name:prepare
21+
run:.github/scripts/prepare.sh
22+
-name:update
23+
run:.github/scripts/update.sh
2124
env:
2225
TRANSIFEX_APIKEY:${{ secrets.TRANSIFEX_APIKEY }}
23-
-uses:./.github/actions/commit
26+
-name:build
27+
run:.github/scripts/build.sh
28+
-name:commit
29+
run:.github/scripts/commit.sh
2430
env:
2531
GITHUB_TOKEN:${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp