45 lines
1.5 KiB
YAML
45 lines
1.5 KiB
YAML
name: lint
|
|
|
|
on:
|
|
push:
|
|
paths:
|
|
- "**.py"
|
|
- ".pylintrc"
|
|
- ".gitea/workflows/lint.yml"
|
|
|
|
jobs:
|
|
lint:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
# No actions/setup-python: the runner image already ships Python 3.12,
|
|
# and older act_runner engines mishandle setup-python's PATH. Install
|
|
# into the ephemeral job container's system Python — the pylint/pyright
|
|
# console scripts land on /usr/local/bin (on PATH) so the steps below
|
|
# still resolve. --break-system-packages is safe: the container is
|
|
# disposable.
|
|
- name: Install dev dependencies
|
|
run: python3 -m pip install --break-system-packages -r requirements-dev.txt
|
|
|
|
- name: Run pylint
|
|
run: |
|
|
# Pylint's normal exit code is nonzero for any emitted finding,
|
|
# regardless of --fail-under. Preserve the full report but enforce
|
|
# the aggregate score this workflow promises.
|
|
set +e
|
|
find . -name '*.py' -not -path './.venv/*' -not -path './.git/*' \
|
|
| xargs pylint --fail-under=8.0 \
|
|
| tee /tmp/pylint-output.txt
|
|
set -e
|
|
SCORE=$(sed -n \
|
|
's/^Your code has been rated at \([-0-9.]*\)\/10.*/\1/p' \
|
|
/tmp/pylint-output.txt | tail -1)
|
|
test -n "$SCORE"
|
|
awk -v score="$SCORE" 'BEGIN { exit !(score >= 8.0) }'
|
|
|
|
- name: Run pyright
|
|
run: |
|
|
# Run pyright type checking
|
|
pyright .
|