Skip to content

Commit 610cdeb

Browse files
committed
Add documentation build workflow
1 parent 4d9c4f1 commit 610cdeb

3 files changed

Lines changed: 123 additions & 1 deletion

File tree

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# .github/workflows/build-docs-preview.yml
2+
name: Build Docs Preview
3+
4+
on:
5+
pull_request:
6+
paths:
7+
- '**/*.po'
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout CPython
14+
uses: actions/checkout@v4
15+
with:
16+
repository: python/cpython
17+
ref: v3.14.6
18+
19+
- name: Set up Python
20+
uses: actions/setup-python@v4
21+
with:
22+
python-version: '3.12'
23+
24+
- name: Setup virtual environment
25+
run: make venv
26+
working-directory: ./Doc
27+
28+
- name: Checkout translation files (this PR's branch)
29+
uses: actions/checkout@v4
30+
with:
31+
ref: ${{ github.event.pull_request.head.sha }} # <-- the PR's actual commit
32+
path: Doc/locales/fa/LC_MESSAGES
33+
34+
- name: Install gettext
35+
run: sudo apt-get install -y gettext
36+
37+
- name: Compile .po files to .mo
38+
run: |
39+
find Doc/locales/fa/LC_MESSAGES -name "*.po" | while read f; do
40+
msgfmt "$f" -o "${f%.po}.mo"
41+
done
42+
43+
- name: Build documentation
44+
id: build
45+
run: |
46+
set +e
47+
make -e SPHINXOPTS="--color -D language='fa' -D gettext_allow_fuzzy_translations=1 --keep-going" html 2>&1 | tee build.log
48+
echo "exit_code=${PIPESTATUS[0]}" >> $GITHUB_OUTPUT
49+
working-directory: ./Doc
50+
51+
- name: Save PR number
52+
run: echo "${{ github.event.pull_request.number }}" > pr_number.txt
53+
54+
- name: Upload build result
55+
uses: actions/upload-artifact@v4
56+
with:
57+
name: build-result
58+
path: |
59+
build.log
60+
pr_number.txt
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# .github/workflows/comment-docs-preview.yml
2+
name: Comment Docs Build Status
3+
4+
on:
5+
workflow_run:
6+
workflows: ["Build Docs Preview"]
7+
types:
8+
- completed
9+
10+
jobs:
11+
comment:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
pull-requests: write
15+
16+
steps:
17+
- name: Download build result
18+
uses: actions/download-artifact@v4
19+
with:
20+
name: build-result
21+
github-token: ${{ secrets.GITHUB_TOKEN }}
22+
run-id: ${{ github.event.workflow_run.id }}
23+
24+
- name: Read PR number
25+
id: pr
26+
run: echo "number=$(cat pr_number.txt)" >> $GITHUB_OUTPUT
27+
28+
- name: Read build log
29+
id: log
30+
run: |
31+
# Grab the last 20 lines so the comment isn't massive
32+
LOG=$(tail -20 build.log)
33+
# GitHub Actions has a specific way to handle multiline strings
34+
echo "content<<EOF" >> $GITHUB_OUTPUT
35+
echo "$LOG" >> $GITHUB_OUTPUT
36+
echo "EOF" >> $GITHUB_OUTPUT
37+
38+
- name: Post comment
39+
uses: actions/github-script@v7
40+
with:
41+
script: |
42+
const success = '${{ github.event.workflow_run.conclusion }}' === 'success';
43+
const icon = success ? '✅' : '❌';
44+
const status = success ? 'succeeded' : 'failed';
45+
46+
const body = `### ${icon} Docs build ${status}
47+
48+
<details>
49+
<summary>Build log (last 20 lines)</summary>
50+
51+
\`\`\`
52+
${{ steps.log.outputs.content }}
53+
\`\`\`
54+
55+
</details>`;
56+
57+
github.rest.issues.createComment({
58+
owner: context.repo.owner,
59+
repo: context.repo.repo,
60+
issue_number: ${{ steps.pr.outputs.number }},
61+
body: body
62+
});

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
CPYTHON_CURRENT_COMMIT := d26c2fe7a2833606b3fb8d9789149d8696978d86
2323
LANGUAGE := fa
24-
BRANCH := 3.13
24+
BRANCH := 3.14
2525

2626
EXCLUDED := \
2727
whatsnew/2.?.po \

0 commit comments

Comments
 (0)