|
| 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. |
0 commit comments