Skip to content

Commit

Permalink
feat: use tox on GHA
Browse files Browse the repository at this point in the history
  • Loading branch information
gforcada committed Nov 2, 2023
1 parent 4d8bde1 commit ca5ea29
Showing 1 changed file with 34 additions and 42 deletions.
76 changes: 34 additions & 42 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
name: Testing
on:
push:
branches: [master]
branches: [main]
pull_request:
branches: [master]
branches: [main]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
test:
name: Testing on
runs-on: ubuntu-latest
runs-on: "ubuntu-latest"
strategy:
matrix:
python-version: ["3.12.0-beta.2", "3.11", "3.10", 3.9, 3.8, pypy-3.9]
python-version: ["3.12", "3.11", "3.10", 3.9, 3.8, pypy-3.9]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
Expand All @@ -23,44 +23,36 @@ jobs:
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('requirements.txt') }}
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('tox.ini') }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.python-version }}-
- name: pip version
run: pip --version
- name: Install dependencies
if: matrix.python-version != '3.9'
run: python -m pip install -r requirements.txt
- name: Install dependencies
if: matrix.python-version == '3.9'
run: python -m pip install -r requirements-lint.txt
# formatters
- name: Run pyupgrade
if: matrix.python-version == '3.9'
run: pyupgrade --py37-plus *.py
- name: Run isort
if: matrix.python-version == '3.9'
run: isort --check-only *.py
- name: Run black
if: matrix.python-version == '3.9'
run: black --check --skip-string-normalization *.py
# linters
- name: Lint with bandit
if: matrix.python-version == '3.9'
run: bandit --skip B101 *.py # B101 is assert statements
- name: Lint with codespell
if: matrix.python-version == '3.9'
run: codespell *.rst *.py
- name: Lint with flake8
if: matrix.python-version == '3.9'
run: flake8 *.py --count --max-complexity=18 --max-line-length=88 --show-source --statistics
- name: Lint with mypy
if: matrix.python-version == '3.9'
run: |
mkdir --parents --verbose .mypy_cache
mypy --ignore-missing-imports --install-types --non-interactive *.py || true
# tests and coverage
run: python -m pip install tox
- name: Test
run: pytest run_tests.py --cov --cov-report term-missing
- name: Coverage
run: coveralls --service=github
run: tox -e test

lint:
name: Lint code
runs-on: "ubuntu-latest"
strategy:
matrix:
python-version: [3.8]
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Cache packages
uses: actions/cache@v3
with:
path: |
~/.cache/pre-commit
~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('tox.ini') }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.python-version }}-
- name: Install dependencies
run: python -m pip install tox
- name: Run linting
run: tox -e lint

0 comments on commit ca5ea29

Please sign in to comment.