Add test suite #15
Workflow file for this run
This file contains 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: Code Quality | |
on: | |
push: | |
paths: | |
- '**.py' | |
branches: | |
- main | |
pull_request: | |
paths: | |
- '**.py' | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
env: | |
RUFF_OUTPUT_FORMAT: github | |
steps: | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12.3' | |
check-latest: true | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install package and dependencies | |
run: pip install -e .'[all]' | |
- name: Install linters | |
run: pip install mypy ruff | |
- name: Register matchers | |
run: for matcher in .github/workflows/matchers/*.json; do echo ::add-matcher::"${matcher}"; done | |
- name: Check types | |
run: mypy --install-types --non-interactive --show-column-numbers . | |
- name: Check code style | |
run: ruff check . | |
- name: Check code formatting | |
run: ruff format --check . | |
test: | |
name: Tests | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: | |
- '3.9' | |
- '3.10' | |
- '3.11' | |
- '3.12' | |
- 'pypy3.9' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install tox | |
run: pip install tox-gh | |
- name: Run tests | |
run: tox -q run | |
- name: Store code coverage data | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage-${{ matrix.python-version }} | |
path: .coverage.* | |
coverage: | |
name: Coverage | |
needs: test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12.3' | |
check-latest: true | |
- name: Install tox | |
run: pip install tox | |
- name: Get code coverage data | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: coverage-* | |
merge-multiple: true | |
- name: Create combined code coverage file | |
run: tox -q run -e coverage | |
- name: Store code coverage report | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage-report | |
path: htmlcov/ | |
- name: Report coverage | |
run: | | |
export TOTAL="$(python -c "import json; print(json.load(open('coverage.json'))['totals']['percent_covered_display'])) | |
echo "Total code coverage: ${TOTAL}%" >> ${GITHUB_STEP_SUMMARY} |