-
Notifications
You must be signed in to change notification settings - Fork 216
GitHub Actions Lint: flake8, cpplint, enforce_licence, generic NOLINTs #1817
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
1012f74
836567f
337a4b4
ba7d9e3
bcff274
2fd1d98
de4b59c
9008033
db6d295
47a6dee
1c8eef2
f007ee5
1e94a76
bf337f6
5242ccc
fd60a4b
18e11cf
2a4978c
d090920
a9d0f62
d06f590
6be6c78
573a83e
cbe7dc4
652603f
05ab75a
4b4b6b6
718c89f
4ee032a
b639fef
9ceee09
02252de
f28976a
0ea3b73
c1594fb
5434a7a
91c7988
5428e8f
cee6919
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"problemMatcher": [ | ||
{ | ||
"owner": "lint-check-licences", | ||
"pattern": [ | ||
{ | ||
"regexp": "^(notice|error)(:(file|dir):([^:]+)(:lines? (\\d+)(-(\\d+))?)?)?: (.+)$", | ||
"severity": 1, | ||
"file": 4, | ||
"line": 6, | ||
"message": 9 | ||
} | ||
] | ||
} | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"problemMatcher": [ | ||
{ | ||
"owner": "lint-cpplint", | ||
"severity": "error", | ||
peternewman marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"pattern": [ | ||
{ | ||
"regexp": "^(.+):(\\d+):\\s+((.+)\\s+\\[(.*)\\]\\s\\[(.*)\\])$", | ||
"file": 1, | ||
"line": 2, | ||
"message": 3, | ||
"code": 5 | ||
} | ||
] | ||
} | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"problemMatcher": [ | ||
{ | ||
"owner": "lint-generic-nolints", | ||
"pattern": [ | ||
{ | ||
"regexp": "^(notice|error)(:(file|dir):([^:]+)(:lines? (\\d+)(-(\\d+))?)?)?: (.+)$", | ||
"severity": 1, | ||
peternewman marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"file": 4, | ||
"line": 6, | ||
"message": 9 | ||
} | ||
] | ||
} | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,196 @@ | ||
name: lint | ||
on: [push, pull_request] | ||
jobs: | ||
build: | ||
name: Build for Lint Tasks | ||
runs-on: ubuntu-latest | ||
container: debian:stable | ||
DaAwesomeP marked this conversation as resolved.
Show resolved
Hide resolved
|
||
steps: | ||
- name: Update package database | ||
run: apt-get update -y | ||
# See comments beginning at | ||
# https://github.com/actions/runner/issues/763#issuecomment-1435474884 | ||
# Without Git, actions/checkout@v3 will resort to REST and will not | ||
# create a .git folder or .git.config. The Problem Matcher looks for | ||
# .git/config to find where the root of the repo is, so it must be | ||
# present. | ||
- name: Install Git | ||
run: apt-get -y install git | ||
- uses: actions/checkout@v3 | ||
- name: Install build tools | ||
shell: bash | ||
run: | | ||
apt-get -y install pkg-config libtool autoconf \ | ||
automake g++ bison flex make bash-completion dh-autoreconf \ | ||
debhelper devscripts wget python3-pip | ||
- name: Install Python lint tools | ||
run: python3 -m pip install --no-input cpplint flake8 | ||
- name: Install build dependencies | ||
shell: bash | ||
run: | | ||
apt-get -y install libcppunit-dev uuid-dev libncurses5-dev \ | ||
libmicrohttpd-dev protobuf-compiler python3-protobuf \ | ||
libprotobuf-dev libprotoc-dev zlib1g-dev libftdi-dev \ | ||
libusb-1.0-0-dev liblo-dev libavahi-client-dev python3-numpy | ||
- name: Autoreconf | ||
run: autoreconf -i | ||
- name: Configure | ||
run: ./configure --enable-rdm-tests --enable-ja-rule --enable-e133 | ||
- name: Build builtfiles | ||
run: make builtfiles VERBOSE=1 | ||
- name: Display structure of the built files | ||
if: env.ACTIONS_STEP_DEBUG == 'true' | ||
run: ls -alR | ||
- name: Archive artifacts to speed up slow GH Actions upload/download | ||
shell: bash | ||
# If the file does not exist when tar excludes it, then it will not | ||
# actually exclude it, so it must first be touched | ||
run: | | ||
touch ola-debian-stable-built-source-tree.tar.gz | ||
peternewman marked this conversation as resolved.
Show resolved
Hide resolved
|
||
tar --exclude=ola-debian-stable-built-source-tree.tar.gz -cvzf ola-debian-stable-built-source-tree.tar.gz . | ||
- name: SHA256 artifact archive | ||
run: sha256sum ola-debian-stable-built-source-tree.tar.gz | ||
peternewman marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- uses: actions/upload-artifact@v3 | ||
with: | ||
name: ola-debian-stable-built-source-tree | ||
DaAwesomeP marked this conversation as resolved.
Show resolved
Hide resolved
|
||
path: ola-debian-stable-built-source-tree.tar.gz | ||
check-licences: | ||
name: Check Licences | ||
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 | ||
if: env.ACTIONS_STEP_DEBUG == 'true' | ||
run: ls -alR | ||
- name: Update package database | ||
run: apt-get update -y | ||
- name: Install Python | ||
run: apt-get -y install python3 python-is-python3 | ||
- name: Enable Problem Matcher for GitHub annotations | ||
run: echo "::add-matcher::.github/problem-matcher-lint-check-licences.json" | ||
- name: Check licenses | ||
shell: bash | ||
run: ./scripts/enforce_licence.py | ||
generic-nolints: | ||
name: Count generic NOLINTs | ||
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 | ||
if: env.ACTIONS_STEP_DEBUG == 'true' | ||
run: ls -alR | ||
- name: Enable Problem Matcher for GitHub annotations | ||
run: echo "::add-matcher::.github/problem-matcher-lint-generic-nolints.json" | ||
- name: Count the number of generic NOLINTs | ||
shell: bash | ||
run: ./scripts/count_generic_nolints.sh | ||
cpplint: | ||
name: cpplint | ||
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 | ||
peternewman marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- 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 | ||
if: env.ACTIONS_STEP_DEBUG == 'true' | ||
run: ls -alR | ||
- name: Update package database | ||
run: apt-get update -y | ||
- name: Install build tools | ||
shell: bash | ||
run: | | ||
apt-get -y install pkg-config libtool autoconf \ | ||
automake g++ bison flex make bash-completion dh-autoreconf \ | ||
debhelper devscripts wget python3-pip | ||
- name: Install Python lint tools | ||
run: python3 -m pip install --no-input cpplint flake8 | ||
- name: Install build dependencies | ||
shell: bash | ||
run: | | ||
apt-get -y install libcppunit-dev uuid-dev libncurses5-dev \ | ||
libmicrohttpd-dev protobuf-compiler python3-protobuf \ | ||
libprotobuf-dev libprotoc-dev zlib1g-dev libftdi-dev \ | ||
libusb-1.0-0-dev liblo-dev libavahi-client-dev python3-numpy | ||
DaAwesomeP marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- name: Enable Problem Matcher for GitHub annotations | ||
run: echo "::add-matcher::.github/problem-matcher-lint-cpplint.json" | ||
- name: cpplint | ||
run: make cpplint VERBOSE=1 | ||
DaAwesomeP marked this conversation as resolved.
Show resolved
Hide resolved
|
||
flake8: | ||
name: flake8 | ||
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 | ||
peternewman marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- 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 | ||
if: env.ACTIONS_STEP_DEBUG == 'true' | ||
run: ls -alR | ||
- name: Update package database | ||
run: apt-get update -y | ||
- name: Install build tools | ||
shell: bash | ||
run: | | ||
apt-get -y install pkg-config libtool autoconf \ | ||
automake g++ bison flex make bash-completion dh-autoreconf \ | ||
debhelper devscripts wget python3-pip | ||
- name: Install Python lint tools | ||
run: python3 -m pip install --no-input cpplint flake8 | ||
- name: Setup flake8 annotations | ||
uses: rbialon/flake8-annotations@v1 | ||
DaAwesomeP marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- name: Install build dependencies | ||
shell: bash | ||
run: | | ||
apt-get -y install libcppunit-dev uuid-dev libncurses5-dev \ | ||
libmicrohttpd-dev protobuf-compiler python3-protobuf \ | ||
libprotobuf-dev libprotoc-dev zlib1g-dev libftdi-dev \ | ||
libusb-1.0-0-dev liblo-dev libavahi-client-dev python3-numpy | ||
- name: flake8 | ||
run: make flake8 VERBOSE=1 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -959,7 +959,7 @@ fi | |
# Linters | ||
AC_CHECK_PROG([flake8],[flake8],[yes],[no]) | ||
AM_CONDITIONAL([FOUND_FLAKE8], [test "x$flake8" = xyes]) | ||
AC_CHECK_PROG([cpplint],[cpplint.py],[yes],[no]) | ||
AC_CHECK_PROG([cpplint],[cpplint],[yes],[no]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah this might make my backwards compatible comment a bit less relevant. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we could also completely take this and flake8 out of dependency checking, if you're OK with that. I don't think that someone building OLA should necessarily be required to have cpplint and flake8 (or maybe there is already a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't believe it should block the build if they're not present. Indeed my config.log has:
It just means we can present a more user-friendly message if they try to run the tools. |
||
AM_CONDITIONAL([FOUND_CPPLINT], [test "x$cpplint" = xyes]) | ||
|
||
# Output | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env bash | ||
# 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. | ||
# | ||
# count_generic_nolints.sh | ||
# Copyright (C) 2023 Perry Naseck, Peter Newman | ||
|
||
# This script is based on a Travis CI test by Peter Newman | ||
nolints="$(grep -n --exclude "$(basename $0)" -IR NOLINT * | grep -v "NOLINT(" | sed 's/^\(.*\):\([0-9]\+\):\(.*\)$/error:file:\.\/\1:line \2: Generic NOLINT not permitted/g')" | ||
nolints_count="$(grep --exclude "$(basename $0)" -IR NOLINT * | grep -c -v "NOLINT(")" | ||
if [[ $nolints_count -ne 0 ]]; then | ||
# print the output for info | ||
printf "%s\n" "$nolints" | ||
printf "error: Found $nolints_count generic NOLINTs\n" | ||
exit 1 | ||
else | ||
printf "notice: Found $nolints_count generic NOLINTs\n" | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think GitHub recognises notice as a severity, just error and warning.
https://github.com/actions/toolkit/blob/master/docs/problem-matchers.md#single-line-matchers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does! I found it in the source. It causes nice messages like these: https://github.com/DaAwesomeP/ola/actions/runs/4218995033
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️ 🤦
Perhaps you'd care to open a PR to improve their docs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do!