-
Notifications
You must be signed in to change notification settings - Fork 239
62 lines (58 loc) · 2.11 KB
/
typos.yml
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
name: Spell Check with Typos
on:
push:
branches:
- 'main'
pull_request:
concurrency:
group: ${{ github.actor }}-${{ github.ref }}-typos
cancel-in-progress: true
permissions: write-all
jobs:
typos-check:
name: Check for new typos
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout the Checkout Actions Repository
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Check spelling with typos
env:
GH_TOKEN: "${{ github.token }}"
run: |
mkdir -p "${{ runner.temp }}/typos"
wget --secure-protocol=TLSv1_3 --max-redirect=1 --retry-on-host-error --retry-connrefused --tries=3 \
--quiet --output-document=- "https://github.com/crate-ci/typos/releases/download/v1.19.0/typos-v1.19.0-x86_64-unknown-linux-musl.tar.gz" \
| tar -xz -C "${{ runner.temp }}/typos" ./typos
"${{ runner.temp }}/typos/typos" --version
"${{ runner.temp }}/typos/typos" --config .typos.toml --format json >> ${{ runner.temp }}/typos.jsonl || true
- name: Update repo with fixable typos
uses: crate-ci/[email protected]
with:
write_changes: true
config: ./.typos.toml
files: .
- name: Store typos diff file
run: git diff > changes-typos.diff
- name: archive typos results
uses: actions/upload-artifact@v4
with:
name: changes-typos.diff
path: changes-typos.diff
- name: Report typos as warnings
run: |
python -c '
import sys, json
old = set()
clean = True
with open(sys.argv[1]) as file:
for line in file:
new = json.loads(line)
if new["type"] == "typo":
clean = False
print("::warning file={},line={},col={}::perhaps \"{}\" should be \"{}\".".format(
new["path"], new["line_num"], new["byte_offset"],
new["typo"], " or ".join(new["corrections"])))
sys.exit(1 if not clean else 0)' "${{ runner.temp }}/typos.jsonl"