Skip to content

Commit 80e946e

Browse files
committed
Add lint action
1 parent a1bf59d commit 80e946e

2 files changed

Lines changed: 141 additions & 0 deletions

File tree

.github/workflows/tox-lint.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Tox Linter Tests
2+
3+
on:
4+
push:
5+
branches: [master, main, v0.6]
6+
pull_request:
7+
branches: [master, main, v0.6]
8+
9+
jobs:
10+
lint:
11+
name: "${{ matrix.tox-env }} / python ${{ matrix.python-version }}"
12+
runs-on: ubuntu-latest
13+
container: ${{ matrix.container }}
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
tox-env: [bandit, flake8, pycodestyle, pylint]
18+
python-version: ["2.7", "3.10"]
19+
include:
20+
- python-version: "2.7"
21+
container: "python:2.7-buster"
22+
tox-suffix: "-py27"
23+
- python-version: "3.10"
24+
tox-suffix: ""
25+
26+
steps:
27+
# ── System packages ────────────────────────────────────────
28+
# Container (Python 2): runs as root, needs git for checkout
29+
- name: Install system dependencies (container)
30+
if: matrix.python-version == '2.7'
31+
run: |
32+
sed -i 's|deb.debian.org|archive.debian.org|g' /etc/apt/sources.list
33+
sed -i 's|security.debian.org|archive.debian.org|g' /etc/apt/sources.list
34+
sed -i '/buster-updates/d' /etc/apt/sources.list
35+
apt-get update -q
36+
apt-get install -qy git libcap-dev
37+
38+
# Host VM (Python 3): git is pre-installed, just need libcap-dev
39+
- name: Install system dependencies
40+
if: matrix.python-version != '2.7'
41+
run: |
42+
sudo apt-get update -q
43+
sudo apt-get install -qy libcap-dev
44+
45+
- name: Checkout repository
46+
uses: actions/checkout@v4
47+
48+
# ── Python 3 ───────────────────────────────────────────────
49+
- name: Set up Python ${{ matrix.python-version }}
50+
if: matrix.python-version != '2.7'
51+
uses: actions/setup-python@v5
52+
with:
53+
python-version: ${{ matrix.python-version }}
54+
55+
# ── Common ─────────────────────────────────────────────────
56+
- name: Install tox
57+
run: |
58+
pip install "tox<4" "virtualenv<20.22.0"
59+
60+
- name: Run tox -e ${{ matrix.tox-env }}${{ matrix.tox-suffix }}
61+
run: tox -e ${{ matrix.tox-env }}${{ matrix.tox-suffix }}

tox.ini

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,74 @@ deps =
3434
pylint
3535
commands = pylint --rcfile=tox.ini --exit-zero pybitmessage
3636

37+
[testenv:bandit]
38+
skip_install = true
39+
basepython = python3
40+
deps =
41+
bandit
42+
commands =
43+
bandit -r -s B101,B411,B413,B608 \
44+
-x checkdeps.*,bitmessagecurses,bitmessageqt,tests pybitmessage
45+
46+
[testenv:flake8]
47+
skip_install = true
48+
basepython = python3
49+
deps =
50+
flake8
51+
commands =
52+
flake8 --config=tox.ini pybitmessage --count --select=E9,F63,F7,F82 \
53+
--show-source --statistics
54+
55+
[testenv:pylint]
56+
skip_install = true
57+
basepython = python3
58+
deps =
59+
-rrequirements.txt
60+
pylint
61+
commands = pylint --rcfile=tox.ini --exit-zero pybitmessage
62+
63+
[testenv:pycodestyle]
64+
skip_install = true
65+
basepython = python3
66+
deps =
67+
pycodestyle
68+
commands =
69+
pycodestyle --config=tox.ini pybitmessage
70+
71+
[testenv:bandit-py27]
72+
skip_install = true
73+
basepython = python2.7
74+
deps =
75+
bandit<1.7.0
76+
commands =
77+
bandit -r -s B101,B411,B413,B603,B608 \
78+
-x checkdeps.*,bitmessagecurses,bitmessageqt,tests pybitmessage
79+
80+
[testenv:flake8-py27]
81+
skip_install = true
82+
basepython = python2.7
83+
deps =
84+
flake8<4.0.0
85+
commands =
86+
flake8 --config=tox.ini pybitmessage --count --select=E9,F63,F7,F82 \
87+
--show-source --statistics
88+
89+
[testenv:pycodestyle-py27]
90+
skip_install = true
91+
basepython = python2.7
92+
deps =
93+
pycodestyle<2.6.0
94+
commands =
95+
pycodestyle --config=tox.ini pybitmessage
96+
97+
[testenv:pylint-py27]
98+
skip_install = true
99+
basepython = python2.7
100+
deps =
101+
-rrequirements.txt
102+
pylint<2.0.0
103+
commands = pylint --rcfile=tox.ini --exit-zero pybitmessage
104+
37105
[testenv:py27]
38106
sitepackages = true
39107

@@ -79,6 +147,18 @@ omit =
79147
[coverage:report]
80148
ignore_errors = true
81149

150+
[pycodestyle]
151+
max-line-length = 119
152+
ignore = E402,E722,W503
153+
154+
[flake8]
155+
max-line-length = 119
156+
exclude = bitmessagecli.py,bitmessagecurses,bitmessageqt,plugins,tests,umsgpack
157+
ignore = E722,F841,W503
158+
# E722: pylint is preferred for bare-except
159+
# F841: pylint is preferred for unused-variable
160+
# W503: deprecated: https://bugs.python.org/issue26763 - https://www.python.org/dev/peps/pep-0008/#should-a-line-break-before-or-after-a-binary-operator
161+
82162
[pylint.main]
83163
disable =
84164
invalid-name,consider-using-f-string,fixme,raise-missing-from,

0 commit comments

Comments
 (0)