Add lint action #1
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: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| tox-env: [lint-basic, lint] | |
| python-version: ["2.7", "3.10"] | |
| include: | |
| - python-version: "2.7" | |
| os: ubuntu-20.04 | |
| - python-version: "3.10" | |
| os: ubuntu-latest | |
| steps: | |
| - 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: Install Python 2.7 | |
| if: matrix.python-version == '2.7' | |
| run: | | |
| sudo apt-get update -q | |
| sudo apt-get install -qy python2.7 python2.7-dev | |
| curl -sSL https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py | |
| sudo python2.7 get-pip.py | |
| sudo ln -sf /usr/bin/python2.7 /usr/local/bin/python2 | |
| - 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 }} |