Skip to content

Commit e389ed5

Browse files
committed
Run pospell/hunspell skipping literal blocks
1 parent a98ae26 commit e389ed5

2 files changed

Lines changed: 81 additions & 0 deletions

File tree

‎.github/workflows/spellcheck.yml‎

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: spellcheck
2+
3+
on:
4+
pull_request:
5+
workflow_dispatch:
6+
workflow_call:
7+
inputs:
8+
version:
9+
description: CPython documentation version
10+
required: true
11+
type: string
12+
translations-ref:
13+
description: Translation branch updated by the calling workflow
14+
required: true
15+
type: string
16+
17+
permissions:
18+
contents: read
19+
20+
jobs:
21+
pospell:
22+
runs-on: ubuntu-latest
23+
defaults:
24+
run:
25+
working-directory: cpython/Doc
26+
steps:
27+
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
28+
with:
29+
python-version: '3.12'
30+
- uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
31+
- name: Check out CPython documentation
32+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
33+
with:
34+
repository: python/cpython
35+
ref: ${{ inputs.version || github.base_ref || github.ref_name }}
36+
path: cpython
37+
persist-credentials: false
38+
- name: Check out translations
39+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
40+
with:
41+
ref: ${{ inputs.translations-ref }}
42+
path: cpython/Doc/locales/pl/LC_MESSAGES
43+
persist-credentials: false
44+
- name: Install dependencies
45+
run: |
46+
sudo apt-get update
47+
sudo apt-get install -y hunspell hunspell-pl
48+
make venv
49+
# Pospell needs newer Docutils than the Sphinx used by older branches.
50+
uv venv "$RUNNER_TEMP/spellcheck-venv"
51+
uv pip install --python "$RUNNER_TEMP/spellcheck-venv/bin/python" sphinx-intl pospell
52+
- name: Generate POT files without literal blocks
53+
run: |
54+
if make -n gettext >/dev/null 2>&1; then
55+
make gettext SPHINXOPTS="-D gettext_additional_targets=index -D gettext_compact=False"
56+
else
57+
# CPython 3.10 and 3.11 do not have a dedicated gettext target.
58+
make build BUILDER=gettext SPHINXOPTS="-D gettext_additional_targets=index -D gettext_compact=False"
59+
fi
60+
- name: Update temporary PO files
61+
# Drop obsolete entries so removed literal blocks are not spellchecked.
62+
run: >
63+
"$RUNNER_TEMP/spellcheck-venv/bin/sphinx-intl" update -p build/gettext -d locales
64+
-l pl
65+
--no-obsolete
66+
- name: Check Polish spelling
67+
run: >
68+
"$RUNNER_TEMP/spellcheck-venv/bin/pospell" --language pl
69+
--glob 'locales/pl/LC_MESSAGES/**/*.po'
70+
# PO updates exist only in this disposable checkout; nothing is committed.

‎.github/workflows/update-and-build.yml‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,17 @@ jobs:
7272
branch: ${{ matrix.version }}
7373
github_token: ${{ secrets.GITHUB_TOKEN }}
7474

75+
spellcheck:
76+
needs: [update]
77+
# These are the runs in which update publishes the fetched translations.
78+
if: github.event_name == 'schedule' || github.ref_name == github.event.repository.default_branch
79+
permissions:
80+
contents: read
81+
uses: ./.github/workflows/spellcheck.yml
82+
with:
83+
version: ${{ github.ref_name }}
84+
translations-ref: ${{ github.ref_name }}
85+
7586
build:
7687
runs-on: ubuntu-latest
7788
strategy:

0 commit comments

Comments
 (0)