Skip to content

Commit 8bfa8b5

Browse files
committed
feat: overhaul testing
1 parent 1c7dbc5 commit 8bfa8b5

File tree

1 file changed

+54
-29
lines changed

1 file changed

+54
-29
lines changed

.github/workflows/tests.yml

Lines changed: 54 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,73 @@
1-
name: Tests
2-
1+
name: Testing
32
on:
43
push:
54
branches: [master]
65
pull_request:
76
branches: [master]
8-
paths:
9-
- "flake8_isort.py"
10-
- "test_flake8_isort.py"
11-
- "setup.py"
12-
- ".github/workflows/tests.yml"
13-
7+
env:
8+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
149
jobs:
15-
tests:
16-
runs-on: ubuntu-latest
10+
test:
1711
name: Python ${{ matrix.python-version }} x isort ${{ matrix.isort }} x flake8 ${{ matrix.flake8 }}
18-
12+
runs-on: ubuntu-latest
1913
strategy:
2014
matrix:
21-
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10', 'pypy3']
15+
python-version: ["3.10", 3.9, 3.8, 3.7, pypy-3.9]
2216
isort: [4.3.21, 5.10.1]
2317
flake8: [3.9.2, 4.0.1, 5.0.4]
24-
2518
steps:
26-
- uses: actions/checkout@v2
27-
- uses: actions/setup-python@v2
19+
- uses: actions/checkout@v3
20+
- name: Set up Python
21+
uses: actions/setup-python@v4
2822
with:
2923
python-version: ${{ matrix.python-version }}
30-
architecture: x64
31-
- name: Install matrix dependencies
32-
run: pip install 'isort==${{ matrix.isort }}' 'flake8==${{ matrix.flake8 }}'
24+
- name: Cache packages
25+
uses: actions/cache@v3
26+
with:
27+
path: ~/.cache/pip
28+
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('requirements.txt') }}
29+
restore-keys: |
30+
${{ runner.os }}-pip-${{ matrix.python-version }}-
31+
- name: pip version
32+
run: pip --version
33+
- name: Install dependencies
34+
run: |
35+
python -m pip install -r requirements.txt
36+
pip install 'isort==${{ matrix.isort }}' 'flake8==${{ matrix.flake8 }}'
3337
# isort 4.x requires `toml` to be able to read pyproject.toml, so install it...
3438
- name: Install toml if required
3539
run: pip install toml
3640
if: matrix.isort == '4.3.21'
37-
- name: Install dependencies
38-
run: pip install .[test]
39-
- name: flake8
40-
run: flake8 *.py
41-
- name: pytest
42-
run: pytest -v --cov flake8_isort --cov-report term-missing
43-
- name: Upload coverage
41+
# formatters
42+
- name: Run pyupgrade
43+
if: matrix.python-version == '3.9'
44+
run: pyupgrade --py37-plus *.py
45+
- name: Run isort
46+
if: matrix.python-version == '3.9'
47+
run: isort --check-only *.py
48+
- name: Run black
49+
if: matrix.python-version == '3.9'
50+
run: black --check --skip-string-normalization *.py
51+
# linters
52+
- name: Lint with bandit
53+
if: matrix.python-version == '3.9'
54+
run: bandit --skip B101 *.py # B101 is assert statements
55+
- name: Lint with codespell
56+
if: matrix.python-version == '3.9'
57+
run: codespell *.rst *.py
58+
- name: Lint with flake8
59+
if: matrix.python-version == '3.9'
60+
run: flake8 *.py --count --max-complexity=18 --max-line-length=88 --show-source --statistics
61+
- name: Lint with mypy
62+
if: matrix.python-version == '3.9'
4463
run: |
45-
python -m pip install coveralls
46-
coveralls --service=github
47-
env:
48-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64+
mkdir --parents --verbose .mypy_cache
65+
mypy --ignore-missing-imports --install-types --non-interactive *.py || true
66+
- name: Lint with safety
67+
if: matrix.python-version == '3.9'
68+
run: safety check || true
69+
# tests and coverage
70+
- name: Test
71+
run: pytest run_tests.py --cov --cov-report term-missing
72+
- name: Coverage
73+
run: coveralls --service=github

0 commit comments

Comments
 (0)