|
| 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: ${{ matrix.os }} |
| 13 | + strategy: |
| 14 | + fail-fast: false |
| 15 | + matrix: |
| 16 | + tox-env: [lint-basic, lint] |
| 17 | + python-version: ["2.7", "3.10"] |
| 18 | + include: |
| 19 | + - python-version: "2.7" |
| 20 | + os: ubuntu-20.04 |
| 21 | + - python-version: "3.10" |
| 22 | + os: ubuntu-latest |
| 23 | + |
| 24 | + steps: |
| 25 | + - name: Checkout repository |
| 26 | + uses: actions/checkout@v4 |
| 27 | + |
| 28 | + # ── Python 3 ─────────────────────────────────────────────── |
| 29 | + - name: Set up Python ${{ matrix.python-version }} |
| 30 | + if: matrix.python-version != '2.7' |
| 31 | + uses: actions/setup-python@v5 |
| 32 | + with: |
| 33 | + python-version: ${{ matrix.python-version }} |
| 34 | + |
| 35 | + # ── Python 2 ─────────────────────────────────────────────── |
| 36 | + - name: Install Python 2.7 |
| 37 | + if: matrix.python-version == '2.7' |
| 38 | + run: | |
| 39 | + sudo apt-get update -q |
| 40 | + sudo apt-get install -qy python2.7 python2.7-dev |
| 41 | + curl -sSL https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py |
| 42 | + sudo python2.7 get-pip.py |
| 43 | + sudo ln -sf /usr/bin/python2.7 /usr/local/bin/python2 |
| 44 | +
|
| 45 | + - name: Override basepython for Python 2 |
| 46 | + if: matrix.python-version == '2.7' |
| 47 | + run: sed -i 's/basepython = python3/basepython = python2.7/' tox.ini |
| 48 | + |
| 49 | + - name: Pin Python 2 compatible linter versions |
| 50 | + if: matrix.python-version == '2.7' |
| 51 | + run: | |
| 52 | + # flake8 >=5 and bandit >=1.7.5 dropped Python 2 support; |
| 53 | + # pylint >=3 requires Python 3.8+ |
| 54 | + sed -i 's/^\( bandit\)$/\1<1.7.5/' tox.ini |
| 55 | + sed -i 's/^\( flake8\)$/\1<5.0.0/' tox.ini |
| 56 | + sed -i 's/^\( pylint\)$/\1<2.0.0/' tox.ini |
| 57 | +
|
| 58 | + # ── Common ───────────────────────────────────────────────── |
| 59 | + - name: Install tox |
| 60 | + run: | |
| 61 | + pip install "tox<4" "virtualenv<20.22.0" |
| 62 | +
|
| 63 | + - name: Run tox -e ${{ matrix.tox-env }} |
| 64 | + run: tox -e ${{ matrix.tox-env }} |
0 commit comments