Skip to content

Commit 1714e03

Browse files
committed
Add lint action
1 parent a1bf59d commit 1714e03

1 file changed

Lines changed: 69 additions & 0 deletions

File tree

.github/workflows/tox-lint.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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+
apt-get update -q
30+
apt-get install -qy git libcap-dev
31+
32+
# Host VM (Python 3): git is pre-installed, just need libcap-dev
33+
- name: Install system dependencies
34+
if: matrix.python-version != '2.7'
35+
run: |
36+
sudo apt-get update -q
37+
sudo apt-get install -qy libcap-dev
38+
39+
- name: Checkout repository
40+
uses: actions/checkout@v4
41+
42+
# ── Python 3 ───────────────────────────────────────────────
43+
- name: Set up Python ${{ matrix.python-version }}
44+
if: matrix.python-version != '2.7'
45+
uses: actions/setup-python@v5
46+
with:
47+
python-version: ${{ matrix.python-version }}
48+
49+
# ── Python 2 ───────────────────────────────────────────────
50+
- name: Override basepython for Python 2
51+
if: matrix.python-version == '2.7'
52+
run: sed -i 's/basepython = python3/basepython = python2.7/' tox.ini
53+
54+
- name: Pin Python 2 compatible linter versions
55+
if: matrix.python-version == '2.7'
56+
run: |
57+
# flake8 >=5 and bandit >=1.7.5 dropped Python 2 support;
58+
# pylint >=3 requires Python 3.8+
59+
sed -i 's/^\( bandit\)$/\1<1.7.5/' tox.ini
60+
sed -i 's/^\( flake8\)$/\1<5.0.0/' tox.ini
61+
sed -i 's/^\( pylint\)$/\1<2.0.0/' tox.ini
62+
63+
# ── Common ─────────────────────────────────────────────────
64+
- name: Install tox
65+
run: |
66+
pip install "tox<4" "virtualenv<20.22.0"
67+
68+
- name: Run tox -e ${{ matrix.tox-env }}
69+
run: tox -e ${{ matrix.tox-env }}

0 commit comments

Comments
 (0)