Skip to content

Commit 369d7b4

Browse files
committed
gn actions lint use provided conspell annotations, spellintian as warnings, separate spelling tasks
1 parent fb8a0f5 commit 369d7b4

4 files changed

Lines changed: 80 additions & 51 deletions

File tree

.github/problem-matcher-lint-spelling.json

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"problemMatcher": [
3+
{
4+
"owner": "lint-spellintian",
5+
"severity": "warning",
6+
"pattern": [
7+
{
8+
"regexp": "^([^:]+):(\\s+)(.+)$",
9+
"file": 1,
10+
"message": 3
11+
}
12+
]
13+
}
14+
]
15+
}

.github/workflows/lint.yaml

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,8 @@ jobs:
194194
libusb-1.0-0-dev liblo-dev libavahi-client-dev python3-numpy
195195
- name: flake8
196196
run: make flake8 VERBOSE=1
197-
spelling:
198-
name: spelling
197+
spellintian:
198+
name: spellintian
199199
runs-on: ubuntu-latest
200200
container: debian:stable
201201
needs: build
@@ -213,15 +213,44 @@ jobs:
213213
tar -xvzf ola-debian-stable-built-source-tree.tar.gz .
214214
rm ola-debian-stable-built-source-tree.tar.gz
215215
- name: Display structure of extracted files
216+
if: env.ACTIONS_STEP_DEBUG == 'true'
216217
run: ls -alR
217218
- name: Update package database
218219
run: apt-get update -y
219220
- name: Install lint tools
221+
run: apt-get -y install moreutils lintian
222+
- name: Enable Problem Matcher for GitHub annotations
223+
run: echo "::add-matcher::.github/problem-matcher-lint-spellintian.json"
224+
- name: spellintian
225+
run: ./scripts/spelling.sh spellintian
226+
codespell:
227+
name: codespell
228+
runs-on: ubuntu-latest
229+
container: debian:stable
230+
needs: build
231+
steps:
232+
- name: Download built source tree archive
233+
uses: actions/download-artifact@v3
234+
with:
235+
name: ola-debian-stable-built-source-tree
236+
path: .
237+
- name: SHA256 artifact archive
238+
run: sha256sum ola-debian-stable-built-source-tree.tar.gz
239+
- name: Unarchive artifacts and delete archive
220240
shell: bash
221-
run: apt-get -y install python3-pip moreutils lintian
241+
run: |
242+
tar -xvzf ola-debian-stable-built-source-tree.tar.gz .
243+
rm ola-debian-stable-built-source-tree.tar.gz
244+
- name: Display structure of extracted files
245+
if: env.ACTIONS_STEP_DEBUG == 'true'
246+
run: ls -alR
247+
- name: Update package database
248+
run: apt-get update -y
249+
- name: Install lint tools
250+
run: apt-get -y install python3-pip moreutils
222251
- name: Install Python lint tools
223-
run: python3 -m pip install --no-input codespell==2.2.1
224-
- name: Enable Problem Matcher for GitHub annotations
225-
run: echo "::add-matcher::.github/problem-matcher-lint-spelling.json"
226-
- name: spelling
227-
run: ./scripts/spelling.sh VERBOSE=1
252+
run: python3 -m pip install --no-input codespell
253+
- name: Setup codespell annotations
254+
uses: codespell-project/codespell-problem-matcher@v1
255+
- name: codespell
256+
run: ./scripts/spelling.sh codespell

scripts/spelling.sh

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,27 @@
1717
# Copyright (C) 2023 Perry Naseck, Peter Newman
1818

1919
# This script is based on Travis CI tests by Peter Newman
20+
current_test=""
21+
# run_single_only=false
22+
if [ "$1" = "spellintian" ]; then
23+
current_test="spellintian"
24+
# run_single_only=true
25+
elif [ "$1" = "codespell" ]; then
26+
current_test="codespell"
27+
else
28+
echo "Unknown test specified in first argument. Options are spellintian and codespell."
29+
exit 1;
30+
fi;
31+
2032
if ! [ -x "$(command -v zrun)" ]; then
2133
echo "error: Cannot find zrun. Do you need the moreutils package?"
2234
exit 1;
2335
fi;
24-
if ! [ -x "$(command -v spellintian)" ]; then
36+
if [ $current_test = "spellintian" ] && ! [ -x "$(command -v spellintian)" ]; then
2537
echo "error: Cannot find spellintian. Do you need the lintian package?"
2638
exit 1;
2739
fi;
28-
if ! [ -x "$(command -v codespell)" ]; then
40+
if [ $current_test = "codespell" ] && ! [ -x "$(command -v codespell)" ]; then
2941
echo "error: Cannot find codespell. Install via pip."
3042
exit 1;
3143
fi;
@@ -70,32 +82,21 @@ spellingfiles=$(eval "find ./ -type f -and ! \( \
7082
$SPELLINGBLACKLIST \
7183
\) | xargs")
7284

73-
# count the number of codespell errors
74-
codespell_errors="$(zrun codespell --interactive 0 --disable-colors --check-filenames --check-hidden --quiet 2 --regex "[a-zA-Z0-9][\\-'a-zA-Z0-9]+[a-zA-Z0-9]" --exclude-file .codespellignorelines --ignore-words .codespellignorewords $spellingfiles 2>&1)"
75-
codespell_errors_count="$([ "$codespell_errors" == "" ] && printf "0" || (printf "%s\n" "$codespell_errors" | wc -l))"
76-
codespell_severity="$([ "$codespell_errors_count" == "0" ] && printf "notice" || printf "error" )"
77-
78-
# count the number of spellintian errors, including duplicate words
79-
spellintian_errors="$(zrun spellintian $spellingfiles 2>&1)"
80-
spellintian_errors_count=$([ "$spellintian_errors" == "" ] && printf "0" || (printf "%s\n" "$spellintian_errors" | wc -l))
81-
spellintian_severity="$([ "$spellintian_errors_count" == "0" ] && printf "notice" || printf "error" )"
85+
if [ $current_test = "spellintian" ]; then
86+
# count the number of spellintian errors, including duplicate words
87+
# spellintian does not change the exit code, so the output must be checked
88+
spellintian_issues="$(zrun spellintian $spellingfiles 2>&1)"
8289

83-
total_errors_count="$(($spellintian_errors_count + $codespell_errors_count))"
84-
total_severity="$([ "$total_errors_count" == "0" ] && printf "notice" || printf "error" )"
85-
86-
if [[ $spellintian_errors_count -ne 0 ]]; then
87-
# print the output for info
88-
printf "%s\n" "$spellintian_errors" | sed 's/^\(.*\): \(.*\)$/error:file:\1: spellintian: \2/g'
89-
fi;
90-
91-
if [[ $codespell_errors_count -ne 0 ]]; then
92-
# print the output for info
93-
printf "%s\n" "$codespell_errors" | sed 's/^\(.*\):\([0-9]\+\): \(.*\)$/error:file:\1:line \2: codespell: \3/g'
90+
if [[ -n $spellintian_issues ]]; then
91+
printf "%s\n" "$spellintian_issues"
92+
# For now we always exit with success, as these errors are manually checked
93+
# exit 1;
94+
exit 0;
95+
fi;
9496
fi;
9597

96-
echo "$spellintian_severity: Found $spellintian_errors_count spelling errors via spellintian"
97-
echo "$codespell_severity: Found $codespell_errors_count spelling errors via codespell"
98-
echo "$total_severity: Found $total_errors_count total spelling errors"
99-
if [[ $total_errors_count -ne 0 ]]; then
100-
exit 1;
98+
if [ $current_test = "codespell" ]; then
99+
if ! zrun codespell --interactive 0 --check-filenames --check-hidden --quiet 2 --regex "[a-zA-Z0-9][\\-'a-zA-Z0-9]+[a-zA-Z0-9]" --exclude-file .codespellignorelines --ignore-words .codespellignorewords $spellingfiles 2>&1; then
100+
exit 1;
101+
fi;
101102
fi;

0 commit comments

Comments
 (0)