CI: enforce python 3.6+ with vermin (MR 2002)

Make sure that features requiring a higher python version don't sneak in
by accident.

It would be nice to add this to test/static_code_analysis.sh, so it is
easy to run it locally. But vermin is not packaged in Alpine right now,
and given that this should be a rather rarer error, it doesn't seem
worth the effort right now.

Run silently by default and only in verbose mode if there are errors,
because if vermin isn't silent, it will not just point out errors, but
describe required python versions for everything it sees. (Copied that
part from the bpo CI script, where I had used it as pre-commit hook as
it was stuck on 3.5 for some time.)
This commit is contained in:
Oliver Smith 2020-12-07 13:31:14 +01:00 committed by Clayton Craft
parent 196186df24
commit 8e3196a42a
No known key found for this signature in database
GPG Key ID: 23A30DA6D406B355
2 changed files with 29 additions and 0 deletions

View File

@ -42,6 +42,16 @@ static-code-analysis:
# Note: This script uses CI_PROJECT_DIR
- su pmos -c "CI_PROJECT_DIR=$CI_PROJECT_DIR .gitlab/shared-runner_test-pmbootstrap.sh --static-code-analysis"
vermin:
image: alpine:latest
stage: checks
<<: *only-default
before_script:
- "apk -q add py3-pip"
- "pip3 -q --disable-pip-version-check install vermin"
script:
- ".gitlab/vermin.sh"
# MR settings
# (Checks for "Allow commits from members who can merge to the target branch")
mr-settings:

19
.gitlab/vermin.sh Executable file
View File

@ -0,0 +1,19 @@
#!/bin/sh -e
_vermin() {
if ! vermin -q "$@" >/dev/null 2>&1; then
vermin -vv "$@"
fi
}
# shellcheck disable=SC2046
_vermin \
-t=3.6- \
--backport argparse \
--backport configparser \
--backport enum \
--backport typing \
$(find . -name '*.py' \
-a -not -path "./.venv/*" \
-a -not -path "./venv/*")
echo "vermin check passed"