Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/problem-matcher-lint-spelling.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"problemMatcher": [
{
"owner": "lint-generic-spelling",
"pattern": [
{
"regexp": "^(notice|error)(:(file|dir):([^:]+)(:lines? (\\d+)(-(\\d+))?)?)?: (.+)$",
"severity": 1,
"file": 4,
"line": 6,
"message": 9
}
]
}
]
}
31 changes: 31 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,34 @@ jobs:
libusb-1.0-0-dev liblo-dev libavahi-client-dev python3-numpy
- name: flake8
run: make flake8 VERBOSE=1
spelling:
name: spelling
runs-on: ubuntu-latest
container: debian:stable
needs: build
steps:
- name: Download built source tree archive
uses: actions/download-artifact@v3
with:
name: ola-debian-stable-built-source-tree
path: .
- name: SHA256 artifact archive
run: sha256sum ola-debian-stable-built-source-tree.tar.gz
- name: Unarchive artifacts and delete archive
shell: bash
run: |
tar -xvzf ola-debian-stable-built-source-tree.tar.gz .
rm ola-debian-stable-built-source-tree.tar.gz
- name: Display structure of extracted files
run: ls -alR
- name: Update package database
run: apt-get update -y
- name: Install lint tools
shell: bash
run: apt-get -y install python3-pip moreutils lintian
- name: Install Python lint tools
run: python3 -m pip install --no-input codespell==2.2.1
- name: Enable Problem Matcher for GitHub annotations
run: echo "::add-matcher::.github/problem-matcher-lint-spelling.json"
- name: spelling
run: ./scripts/spelling.sh VERBOSE=1
101 changes: 101 additions & 0 deletions scripts/spelling.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
#!/usr/bin/env bash
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As sort of mentioned before, I'm beginning to wonder more if this should all become ci.sh or part of the Makefile or something, I'm not really sure. Probably makes sense to leave it until everything is migrated so we can easily re-assess what it all looks like compared to .travis-ci.sh .

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I have some ideas for wrapping things but I just want to get everything working initially first. I'm significantly changing things such that I would write a new ci.sh from scratch probably. The current one is very Travis-centric.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's cool, lets leave this for the future then.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Library General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# spellintian.sh
# Copyright (C) 2023 Perry Naseck, Peter Newman

# This script is based on Travis CI tests by Peter Newman
if ! [ -x "$(command -v zrun)" ]; then
echo "error: Cannot find zrun. Do you need the moreutils package?"
exit 1;
fi;
if ! [ -x "$(command -v spellintian)" ]; then
echo "error: Cannot find spellintian. Do you need the lintian package?"
exit 1;
fi;
if ! [ -x "$(command -v codespell)" ]; then
echo "error: Cannot find codespell. Install via pip."
exit 1;
fi;

SPELLINGBLACKLIST=$(cat <<-BLACKLIST
-wholename "./.codespellignorewords" -or \
-wholename "./.codespellignorelines" -or \
-wholename "./.git/*" -or \
-wholename "./aclocal.m4" -or \
-wholename "./config/config.guess" -or \
-wholename "./config/config.sub" -or \
-wholename "./config/depcomp" -or \
-wholename "./config/install-sh" -or \
-wholename "./config/libtool.m4" -or \
-wholename "./config/ltmain.sh" -or \
-wholename "./config/ltoptions.m4" -or \
-wholename "./config/ltsugar.m4" -or \
-wholename "./config/missing" -or \
-wholename "./libtool" -or \
-wholename "./config.log" -or \
-wholename "./config.status" -or \
-wholename "./Makefile" -or \
-wholename "./Makefile.in" -or \
-wholename "./autom4te.cache/*" -or \
-wholename "./java/Makefile" -or \
-wholename "./java/Makefile.in" -or \
-wholename "./olad/www/new/js/app.min.js" -or \
-wholename "./olad/www/new/js/app.min.js.map" -or \
-wholename "./olad/www/new/libs/angular/js/angular.min.js" -or \
-wholename "./olad/www/new/libs/marked/js/marked.min.js" -or \
-wholename "./olad/www/mobile.js" -or \
-wholename "./olad/www/ola.js" -or \
-wholename "./configure" -or \
-wholename "./common/protocol/Ola.pb.*" -or \
-wholename "./plugins/artnet/messages/ArtNetConfigMessages.pb.*" -or \
-wholename "./tools/ola_trigger/config.tab.*" -or \
-wholename "./tools/ola_trigger/lex.yy.cpp"
BLACKLIST
)

spellingfiles=$(eval "find ./ -type f -and ! \( \
$SPELLINGBLACKLIST \
\) | xargs")

# count the number of codespell errors
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)"
codespell_errors_count="$([ "$codespell_errors" == "" ] && printf "0" || (printf "%s\n" "$codespell_errors" | wc -l))"
codespell_severity="$([ "$codespell_errors_count" == "0" ] && printf "notice" || printf "error" )"

# count the number of spellintian errors, including duplicate words
spellintian_errors="$(zrun spellintian $spellingfiles 2>&1)"
spellintian_errors_count=$([ "$spellintian_errors" == "" ] && printf "0" || (printf "%s\n" "$spellintian_errors" | wc -l))
spellintian_severity="$([ "$spellintian_errors_count" == "0" ] && printf "notice" || printf "error" )"

total_errors_count="$(($spellintian_errors_count + $codespell_errors_count))"
total_severity="$([ "$total_errors_count" == "0" ] && printf "notice" || printf "error" )"

if [[ $spellintian_errors_count -ne 0 ]]; then
# print the output for info
printf "%s\n" "$spellintian_errors" | sed 's/^\(.*\): \(.*\)$/error:file:\1: spellintian: \2/g'
fi;

if [[ $codespell_errors_count -ne 0 ]]; then
# print the output for info
printf "%s\n" "$codespell_errors" | sed 's/^\(.*\):\([0-9]\+\): \(.*\)$/error:file:\1:line \2: codespell: \3/g'
fi;

echo "$spellintian_severity: Found $spellintian_errors_count spelling errors via spellintian"
echo "$codespell_severity: Found $codespell_errors_count spelling errors via codespell"
echo "$total_severity: Found $total_errors_count total spelling errors"
if [[ $total_errors_count -ne 0 ]]; then
exit 1;
fi;