-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
51 lines (48 loc) · 2.11 KB
/
SpellCheck.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
name: Spell Check
permissions: {}
on: [pull_request]
jobs:
typos-check:
name: (add false positives to typos.toml)
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout the JuliaLang/julia repository
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Check spelling with typos
#uses: crate-ci/typos@master
env:
GH_TOKEN: "${{ github.token }}"
run: |
git fetch --depth=1 origin ${{ github.base_ref }}
set -o pipefail
mkdir -p "${{ runner.temp }}/typos"
RELEASE_ASSET_URL="$(
gh api /repos/crate-ci/typos/releases/latest \
--jq '."assets"[] | select(."name" | test("^typos-.+-x86_64-unknown-linux-musl\\.tar\\.gz$")) | ."browser_download_url"'
)"
wget --secure-protocol=TLSv1_3 --max-redirect=1 --retry-on-host-error --retry-connrefused --tries=3 \
--quiet --output-document=- "${RELEASE_ASSET_URL}" \
| tar -xz -C "${{ runner.temp }}/typos" ./typos
"${{ runner.temp }}/typos/typos" --version
echo z
OLD_FILES=$(git diff-index --name-only --diff-filter=ad FETCH_HEAD)
echo a
NEW_FILES=$(git diff-index --name-only --diff-filter=d FETCH_HEAD)
echo b
do -i {NEW_TYPOS=$(echo -n $NEW_FILES | xargs "${{ runner.temp }}/typos/typos" --format json)}
echo c
git checkout FETCH_HEAD -- $OLD_FILES
echo d
do -i {OLD_TYPOS=$(echo -n $OLD_FILES | xargs "${{ runner.temp }}/typos/typos" --format json)}
echo e
python -c '
import sys, json
existing = set(typo["typo"] for typo in json.loads("["+sys.argv[1].replace("\n", ",")+"]"))
for new in json.loads("["+sys.argv[2].replace("\n", ",")+"]"):
if new["typo"] not in existing:
print("::warning file={},line={},col={}::perhaps \"{}\" should be \"{}\".".format(
new["path"], new["line_num"], new["byte_offset"],
new["typo"], " or ".join(new["corrections"])))' "$OLD_TYPOS" "$NEW_TYPOS"