Repository navigation
149 lines (146 loc) · 6.68 KB
/
Copy pathspellcheck.yml
File metadata and controls
149 lines (146 loc) · 6.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
name: spellcheck
on:
pull_request:
workflow_dispatch:
workflow_call:
inputs:
advisory:
description: Report failures without failing the calling workflow
type: boolean
default: true
version:
description: CPython documentation version
required: true
type: string
translations-ref:
description: Translation branch updated by the calling workflow
required: true
type: string
secrets:
TX_TOKEN:
description: Transifex API token with access to the Polish terminology glossary
required: true
permissions:
contents: read
jobs:
pospell:
# Fork PRs cannot access TX_TOKEN; forks can run manually with their own secret.
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
runs-on: ubuntu-latest
continue-on-error: ${{ inputs.advisory || github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }}
timeout-minutes: 15
defaults:
run:
working-directory: cpython/Doc
steps:
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: 3
- uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
- name: Check out workflow tools
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
path: spellcheck-tools
sparse-checkout: |
/manage_translation.py
sparse-checkout-cone-mode: false
persist-credentials: false
- name: Check out CPython documentation
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: python/cpython
ref: ${{ inputs.version || github.base_ref || github.ref_name }}
path: cpython
persist-credentials: false
- name: Check out translations
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ inputs.translations-ref }}
path: cpython/Doc/locales/pl/LC_MESSAGES
persist-credentials: false
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y curl hunspell hunspell-pl unzip
make venv
# Pospell needs newer Docutils than the Sphinx used by older branches.
uv venv "$RUNNER_TEMP/spellcheck-venv"
# Pospell PR 24 provides --report; switch to a release when available.
uv pip install --python "$RUNNER_TEMP/spellcheck-venv/bin/python" \
sphinx-intl transifex-python six \
'pospell @ git+https://git.afpy.org/maciek/pospell.git@feat/json-reports'
- name: Prepare UTF-8 Polish dictionary
# The packaged dictionary uses ISO-8859-2, which cannot represent all prose.
run: |
mkdir -p "$RUNNER_TEMP/hunspell-utf8"
dictionary_encoding=$(sed -n 's/^SET //p' /usr/share/hunspell/pl_PL.aff)
iconv -f "$dictionary_encoding" -t UTF-8 /usr/share/hunspell/pl_PL.aff \
> "$RUNNER_TEMP/hunspell-utf8/pl_PL.aff"
sed -i 's/^SET .*/SET UTF-8/' "$RUNNER_TEMP/hunspell-utf8/pl_PL.aff"
iconv -f "$dictionary_encoding" -t UTF-8 /usr/share/hunspell/pl_PL.dic \
> "$RUNNER_TEMP/hunspell-utf8/pl_PL.dic"
- name: Download SJP Polish dictionary
run: |
curl --fail --location --retry 3 \
https://sjp.pl/sl/ort/sjp-hunspell-pl-20261101.zip \
--output "$RUNNER_TEMP/sjp-hunspell.zip"
echo "a29b40d80a2501ba1ad84fa17f7d177e2ebe313082f74f837a77b3135c05340c $RUNNER_TEMP/sjp-hunspell.zip" \
| sha256sum --check --strict
# SJP wraps the dictionary files in a second ZIP archive.
unzip -p "$RUNNER_TEMP/sjp-hunspell.zip" pl_PL.zip \
> "$RUNNER_TEMP/sjp-pl_PL.zip"
unzip -p "$RUNNER_TEMP/sjp-pl_PL.zip" pl_PL.aff \
> "$RUNNER_TEMP/sjp-pl_PL.aff"
unzip -p "$RUNNER_TEMP/sjp-pl_PL.zip" pl_PL.dic \
> "$RUNNER_TEMP/sjp-pl_PL.dic"
dictionary_encoding=$(sed -n 's/^SET //p' "$RUNNER_TEMP/sjp-pl_PL.aff")
iconv -f "$dictionary_encoding" -t UTF-8 "$RUNNER_TEMP/sjp-pl_PL.aff" \
> "$RUNNER_TEMP/hunspell-utf8/pl_SJP.aff"
sed -i 's/^SET .*/SET UTF-8/' "$RUNNER_TEMP/hunspell-utf8/pl_SJP.aff"
iconv -f "$dictionary_encoding" -t UTF-8 "$RUNNER_TEMP/sjp-pl_PL.dic" \
> "$RUNNER_TEMP/hunspell-utf8/pl_SJP.dic"
- name: Download Polish terminology glossary
working-directory: spellcheck-tools
env:
TX_TOKEN: ${{ secrets.TX_TOKEN }}
run: >
"$RUNNER_TEMP/spellcheck-venv/bin/python"
manage_translation.py fetch_glossary
--output "$RUNNER_TEMP/hunspell-glossary.dic"
- name: Generate POT files without literal blocks
run: |
if make -n gettext >/dev/null 2>&1; then
make gettext SPHINXOPTS="-D gettext_additional_targets=index -D gettext_compact=0"
else
# CPython 3.10 and 3.11 do not have a dedicated gettext target.
make build BUILDER=gettext SPHINXOPTS="-D gettext_additional_targets=index -D gettext_compact=0"
fi
- name: Prepare temporary PO files without literal blocks
run: |
# Only catalogs with a current POT have had literal blocks excluded.
while IFS= read -r -d '' po; do
resource=${po#locales/pl/LC_MESSAGES/}
if [ ! -f "build/gettext/${resource%.po}.pot" ]; then
rm "$po"
fi
done < <(find locales/pl/LC_MESSAGES -name '*.po' -type f -print0)
"$RUNNER_TEMP/spellcheck-venv/bin/sphinx-intl" update \
-p build/gettext -d locales -l pl --no-obsolete
- name: Check Polish spelling
id: spelling
env:
DICPATH: ${{ runner.temp }}/hunspell-utf8
run: |
"$RUNNER_TEMP/spellcheck-venv/bin/pospell" --language pl_PL,pl_SJP \
--personal-dict "$RUNNER_TEMP/hunspell-glossary.dic" \
--glob 'locales/pl/LC_MESSAGES/**/*.po' \
--report-root locales/pl/LC_MESSAGES \
--report "$RUNNER_TEMP/spellcheck.json"
- name: Upload spelling report
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: ${{ !cancelled() && (steps.spelling.outcome == 'success' || steps.spelling.outcome == 'failure') }}
with:
name: spellcheck-pl
path: ${{ runner.temp }}/spellcheck.json
if-no-files-found: error
# PO updates exist only in this disposable checkout; nothing is committed.