Skip to content

Commit f8eeac2

Browse files
authored
Fix build and deploy workflow + RTD workflow (#46)
Also skip RTD workflow on non-documentation changes
1 parent bbd73ec commit f8eeac2

3 files changed

Lines changed: 34 additions & 15 deletions

File tree

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

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,10 @@ jobs:
4141
with:
4242
path: Doc/locales/fa/LC_MESSAGES
4343

44-
- name: Strip stray fuzzy markers
45-
run: python3 Doc/locales/fa/LC_MESSAGES/scripts/strip_fuzzy.py $(find Doc/locales/fa/LC_MESSAGES -name "*.po" -not -path "*/.git/*")
46-
47-
- name: Install gettext
48-
run: sudo apt-get install -y gettext
49-
50-
- name: Compile .po files to .mo
51-
run: |
52-
find Doc/locales/fa/LC_MESSAGES -name "*.po" -not -path "*/.git/*" | while read f; do
53-
msgfmt "$f" -o "${f%.po}.mo"
54-
done
44+
- name: Strip fuzzy markers and compile .po to .mo
45+
run: find Doc/locales/fa/LC_MESSAGES -name "*.po" -not -path "*/.git/*" | python3 Doc/locales/fa/LC_MESSAGES/scripts/compile_mo.py
46+
env:
47+
MSGFMT_TOOLS_PATH: Tools/i18n
5548

5649
- name: Setup problem matcher
5750
uses: sphinx-doc/github-problem-matcher@v1.1

.readthedocs.yml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,31 @@ build:
44
os: ubuntu-24.04
55
tools:
66
python: "3.12"
7-
87
commands:
8+
- |
9+
set +e
10+
if git rev-parse --verify -q HEAD^ >/dev/null; then
11+
CHANGED_FILES=$(git diff --name-only HEAD^ HEAD)
12+
else
13+
CHANGED_FILES=""
14+
fi
15+
echo "Changed files: $CHANGED_FILES"
16+
17+
SKIP=1
18+
for f in $CHANGED_FILES; do
19+
case "$f" in
20+
*.po|*.yaml|*.yml)
21+
SKIP=0
22+
;;
23+
esac
24+
done
25+
26+
if [ -n "$CHANGED_FILES" ] && [ "$SKIP" -eq 1 ]; then
27+
echo "No documentation-relevant files changed, skipping build."
28+
exit 183
29+
fi
30+
echo "Continuing build."
31+
exit 0
932
- git clone --depth 1 --branch v3.14.6 https://github.com/python/cpython venv/cpython
1033
- pip install -r venv/cpython/Doc/requirements.txt
1134
- mkdir -p venv/cpython/Doc/locales/fa/LC_MESSAGES
@@ -20,4 +43,4 @@ build:
2043
-D gettext_allow_fuzzy_translations=1
2144
-D html_theme_options.is_rtl=1
2245
venv/cpython/Doc
23-
$READTHEDOCS_OUTPUT/html
46+
$READTHEDOCS_OUTPUT/html

scripts/compile_mo.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@
1616
import sys
1717
import os
1818

19-
# venv/cpython/Tools/i18n/msgfmt.py, relative to repo root.
20-
sys.path.insert(0, os.path.join("venv", "cpython", "Tools", "i18n"))
19+
_venv_tools = os.environ.get(
20+
"MSGFMT_TOOLS_PATH",
21+
os.path.join("venv", "cpython", "Tools", "i18n"),
22+
)
23+
sys.path.insert(0, _venv_tools)
2124
import msgfmt # noqa: E402
2225

2326

0 commit comments

Comments
 (0)