Skip to content

Commit 7a017a6

Browse files
committed
Add lint action
1 parent a1bf59d commit 7a017a6

1 file changed

Lines changed: 75 additions & 0 deletions

File tree

.github/workflows/tox-lint.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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: [lint-basic, lint]
18+
python-version: ["2.7", "3.10"]
19+
include:
20+
- python-version: "2.7"
21+
container: "python:2.7-buster"
22+
23+
steps:
24+
# ── System packages ────────────────────────────────────────
25+
# Container (Python 2): runs as root, needs git for checkout
26+
- name: Install system dependencies (container)
27+
if: matrix.python-version == '2.7'
28+
run: |
29+
sed -i 's|deb.debian.org|archive.debian.org|g' /etc/apt/sources.list
30+
sed -i 's|security.debian.org|archive.debian.org|g' /etc/apt/sources.list
31+
sed -i '/buster-updates/d' /etc/apt/sources.list
32+
apt-get update -q
33+
apt-get install -qy git libcap-dev
34+
35+
# Host VM (Python 3): git is pre-installed, just need libcap-dev
36+
- name: Install system dependencies
37+
if: matrix.python-version != '2.7'
38+
run: |
39+
sudo apt-get update -q
40+
sudo apt-get install -qy libcap-dev
41+
42+
- name: Checkout repository
43+
uses: actions/checkout@v4
44+
45+
# ── Python 3 ───────────────────────────────────────────────
46+
- name: Set up Python ${{ matrix.python-version }}
47+
if: matrix.python-version != '2.7'
48+
uses: actions/setup-python@v5
49+
with:
50+
python-version: ${{ matrix.python-version }}
51+
52+
# ── Python 2 ───────────────────────────────────────────────
53+
- name: Override basepython for Python 2
54+
if: matrix.python-version == '2.7'
55+
run: sed -i 's/basepython = python3/basepython = python2.7/' tox.ini
56+
57+
- name: Pin Python 2 compatible linter versions
58+
if: matrix.python-version == '2.7'
59+
run: |
60+
# bandit >=1.7 dropped Python 2; flake8 >=4 dropped Python 2;
61+
# pylint >=2 dropped Python 2
62+
sed -i 's/^\( bandit\)$/\1<1.7.0/' tox.ini
63+
sed -i 's/^\( flake8\)$/\1<4.0.0/' tox.ini
64+
sed -i 's/^\( pylint\)$/\1<2.0.0/' tox.ini
65+
# bandit <1.7 doesn't support "# nosec B603" (specific IDs);
66+
# skip B603 globally for Python 2 instead
67+
sed -i 's/-s B101,B411,B413,B608/-s B101,B411,B413,B603,B608/' tox.ini
68+
69+
# ── Common ─────────────────────────────────────────────────
70+
- name: Install tox
71+
run: |
72+
pip install "tox<4" "virtualenv<20.22.0"
73+
74+
- name: Run tox -e ${{ matrix.tox-env }}
75+
run: tox -e ${{ matrix.tox-env }}

0 commit comments

Comments
 (0)