Add lint action #3
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Tox Linter Tests | |
| on: | |
| push: | |
| branches: [master, main, v0.6] | |
| pull_request: | |
| branches: [master, main, v0.6] | |
| jobs: | |
| lint: | |
| name: "${{ matrix.tox-env }} / python ${{ matrix.python-version }}" | |
| runs-on: ubuntu-latest | |
| container: ${{ matrix.container }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| tox-env: [lint-basic, lint] | |
| python-version: ["2.7", "3.10"] | |
| include: | |
| - python-version: "2.7" | |
| container: "python:2.7-buster" | |
| steps: | |
| # ── System packages ──────────────────────────────────────── | |
| # Container (Python 2): runs as root, needs git for checkout | |
| - name: Install system dependencies (container) | |
| if: matrix.python-version == '2.7' | |
| run: | | |
| sed -i 's|deb.debian.org|archive.debian.org|g' /etc/apt/sources.list | |
| sed -i 's|security.debian.org|archive.debian.org|g' /etc/apt/sources.list | |
| sed -i '/buster-updates/d' /etc/apt/sources.list | |
| apt-get update -q | |
| apt-get install -qy git libcap-dev | |
| # Host VM (Python 3): git is pre-installed, just need libcap-dev | |
| - name: Install system dependencies | |
| if: matrix.python-version != '2.7' | |
| run: | | |
| sudo apt-get update -q | |
| sudo apt-get install -qy libcap-dev | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| # ── Python 3 ─────────────────────────────────────────────── | |
| - name: Set up Python ${{ matrix.python-version }} | |
| if: matrix.python-version != '2.7' | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| # ── Python 2 ─────────────────────────────────────────────── | |
| - name: Override basepython for Python 2 | |
| if: matrix.python-version == '2.7' | |
| run: sed -i 's/basepython = python3/basepython = python2.7/' tox.ini | |
| - name: Pin Python 2 compatible linter versions | |
| if: matrix.python-version == '2.7' | |
| run: | | |
| # flake8 >=5 and bandit >=1.7.5 dropped Python 2 support; | |
| # pylint >=3 requires Python 3.8+ | |
| sed -i 's/^\( bandit\)$/\1<1.7.5/' tox.ini | |
| sed -i 's/^\( flake8\)$/\1<5.0.0/' tox.ini | |
| sed -i 's/^\( pylint\)$/\1<2.0.0/' tox.ini | |
| # ── Common ───────────────────────────────────────────────── | |
| - name: Install tox | |
| run: | | |
| pip install "tox<4" "virtualenv<20.22.0" | |
| - name: Run tox -e ${{ matrix.tox-env }} | |
| run: tox -e ${{ matrix.tox-env }} |