Skip to content

Commit 74f80b2

Browse files
authored
Merge pull request #1818 from DaAwesomeP/DaAwesomeP-GitHubActionsLint2
GitHub Actions Lint: spellintian, codespell
2 parents 171b4b0 + 115cbbb commit 74f80b2

7 files changed

Lines changed: 190 additions & 2 deletions

File tree

.codespellignorelines

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,3 +191,11 @@ import java.nio.ByteOrder;
191191
string("one\\\"two\\\\three\\/four\\bfive\\fsix\\nseven\\reight\\tnine"),
192192
s1 = "one\"two\\three/four\bfive\fsix\nseven\reight\tnine";
193193
string("one\\\"two\\\\three\\/four\\bfive\\fsix\\nseven\\reight\\tnine"),
194+
self.assertEqual(rtf._EscapeData(u'caf\xe9'), "caf\\xe9")
195+
self.assertEqual('%s' % rtf._EscapeData(u'caf\xe9'), "caf\\xe9")
196+
self.assertEqual('%s' % rtf._EscapeData(['caf\xe9']), "['caf\\\\xe9']")
197+
self.assertEqual('%s' % rtf._EscapeData({"a": "caf\xe9"}),
198+
"{'a': 'caf\\\\xe9'}")
199+
# self.assertEqual('%s' % rtf._EscapeData({"caf\xe9": "bar"}),
200+
# "{'caf\xe9': 'bar'}")
201+
"forin": true,

.codespellignorewords

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ acn
22
ACN
33
inflight
44
thead
5+
wronly
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: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,3 +194,63 @@ jobs:
194194
libusb-1.0-0-dev liblo-dev libavahi-client-dev python3-numpy
195195
- name: flake8
196196
run: make flake8 VERBOSE=1
197+
spellintian:
198+
name: spellintian
199+
runs-on: ubuntu-latest
200+
container: debian:stable
201+
needs: build
202+
steps:
203+
- name: Download built source tree archive
204+
uses: actions/download-artifact@v3
205+
with:
206+
name: ola-debian-stable-built-source-tree
207+
path: .
208+
- name: SHA256 artifact archive
209+
run: sha256sum ola-debian-stable-built-source-tree.tar.gz
210+
- name: Unarchive artifacts and delete archive
211+
shell: bash
212+
run: |
213+
tar -xvzf ola-debian-stable-built-source-tree.tar.gz .
214+
rm ola-debian-stable-built-source-tree.tar.gz
215+
- name: Display structure of extracted files
216+
if: env.ACTIONS_STEP_DEBUG == 'true'
217+
run: ls -alR
218+
- name: Update package database
219+
run: apt-get update -y
220+
- 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
240+
shell: bash
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 git moreutils
251+
- name: Install Python lint tools
252+
run: python3 -m pip install --no-input git+https://github.com/codespell-project/codespell.git
253+
- name: Setup codespell annotations
254+
uses: codespell-project/codespell-problem-matcher@v1
255+
- name: codespell
256+
run: ./scripts/spelling.sh codespell

common/rdm/testdata/test_pids.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2263,7 +2263,7 @@ pid {
22632263
}
22642264
field {
22652265
type: STRING
2266-
name: "modulation_frequence_description"
2266+
name: "modulation_frequency_description"
22672267
max_size: 32
22682268
}
22692269
}

scripts/spelling.sh

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
#!/usr/bin/env bash
2+
# This program is free software; you can redistribute it and/or modify
3+
# it under the terms of the GNU General Public License as published by
4+
# the Free Software Foundation; either version 2 of the License, or
5+
# (at your option) any later version.
6+
#
7+
# This program is distributed in the hope that it will be useful,
8+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
9+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10+
# GNU Library General Public License for more details.
11+
#
12+
# You should have received a copy of the GNU General Public License
13+
# along with this program; if not, write to the Free Software
14+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
15+
#
16+
# spellintian.sh
17+
# Copyright (C) 2023 Perry Naseck, Peter Newman
18+
19+
# This script is based on Travis CI tests by Peter Newman
20+
current_test=""
21+
if [ "$1" = "spellintian" ]; then
22+
current_test="spellintian"
23+
elif [ "$1" = "codespell" ]; then
24+
current_test="codespell"
25+
else
26+
echo "Unknown test \"$1\" specified in first argument. Options are spellintian and codespell."
27+
exit 1;
28+
fi;
29+
30+
if ! [ -x "$(command -v zrun)" ]; then
31+
echo "error: Cannot find zrun. Do you need the moreutils package?"
32+
exit 1;
33+
fi;
34+
if [ $current_test = "spellintian" ] && ! [ -x "$(command -v spellintian)" ]; then
35+
echo "error: Cannot find spellintian. Do you need the lintian package?"
36+
exit 1;
37+
fi;
38+
if [ $current_test = "codespell" ] && ! [ -x "$(command -v codespell)" ]; then
39+
echo "error: Cannot find codespell. Install via pip."
40+
exit 1;
41+
fi;
42+
43+
SPELLINGBLACKLIST=$(cat <<-BLACKLIST
44+
-wholename "./.codespellignorelines" -or \
45+
-wholename "./.codespellignorewords" -or \
46+
-wholename "./.git/*" -or \
47+
-wholename "./Makefile" -or \
48+
-wholename "./Makefile.in" -or \
49+
-wholename "./aclocal.m4" -or \
50+
-wholename "./autom4te.cache/*" -or \
51+
-wholename "./common/protocol/Ola.pb.*" -or \
52+
-wholename "./common/rpc/TestService.pb.*" -or \
53+
-wholename "./config.log" -or \
54+
-wholename "./config.status" -or \
55+
-wholename "./config/config.guess" -or \
56+
-wholename "./config/config.sub" -or \
57+
-wholename "./config/depcomp" -or \
58+
-wholename "./config/install-sh" -or \
59+
-wholename "./config/libtool.m4" -or \
60+
-wholename "./config/ltmain.sh" -or \
61+
-wholename "./config/ltoptions.m4" -or \
62+
-wholename "./config/ltsugar.m4" -or \
63+
-wholename "./config/missing" -or \
64+
-wholename "./configure" -or \
65+
-wholename "./java/Makefile" -or \
66+
-wholename "./java/Makefile.in" -or \
67+
-wholename "./libtool" -or \
68+
-wholename "./olad/www/mobile.js" -or \
69+
-wholename "./olad/www/new/js/app.min.js" -or \
70+
-wholename "./olad/www/new/js/app.min.js.map" -or \
71+
-wholename "./olad/www/new/libs/angular/js/angular.min.js" -or \
72+
-wholename "./olad/www/new/libs/marked/js/marked.min.js" -or \
73+
-wholename "./olad/www/ola.js" -or \
74+
-wholename "./plugins/artnet/messages/ArtNetConfigMessages.pb.*" -or \
75+
-wholename "./tools/ola_trigger/config.tab.*" -or \
76+
-wholename "./tools/ola_trigger/lex.yy.cpp"
77+
BLACKLIST
78+
)
79+
80+
spellingfiles=$(eval "find ./ -type f -and ! \( \
81+
$SPELLINGBLACKLIST \
82+
\) | xargs")
83+
84+
if [ $current_test = "spellintian" ]; then
85+
# count the number of spellintian errors, including duplicate words
86+
# spellintian does not change the exit code, so the output must be checked
87+
spellintian_issues="$(zrun spellintian $spellingfiles 2>&1)"
88+
89+
if [[ -n $spellintian_issues ]]; then
90+
printf "%s\n" "$spellintian_issues"
91+
# For now we always exit with success, as these errors are manually checked
92+
# TODO: Actively match and skip printing known false positives, exit with
93+
# errors properly.
94+
# exit 1;
95+
exit 0;
96+
fi;
97+
elif [ $current_test = "codespell" ]; then
98+
if ! zrun codespell --interactive 0 --check-filenames --check-hidden \
99+
--quiet 2 --regex "[a-zA-Z0-9][\\-'a-zA-Z0-9]+[a-zA-Z0-9]" \
100+
--exclude-file .codespellignorelines \
101+
--ignore-words .codespellignorewords $spellingfiles 2>&1; then
102+
exit 1;
103+
fi;
104+
fi;

tools/rdm/TestDefinitions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1520,7 +1520,7 @@ def VerifyResult(self, response, fields):
15201520
language_set.add(language)
15211521
if ContainsUnprintable(language):
15221522
self.AddAdvisory(
1523-
'Language name in languague capabilities contains unprintable '
1523+
'Language name in language capabilities contains unprintable '
15241524
'characters, was %s' % language.encode('string-escape'))
15251525

15261526
self.SetProperty('languages_capabilities', language_set)

0 commit comments

Comments
 (0)