Avoid some unnecessary work in hot code paths #544
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
# SPDX-FileCopyrightText: 2022-2025 tinytag Contributors | |
# SPDX-License-Identifier: MIT | |
name: Tests | |
on: [push, pull_request] | |
permissions: {} | |
env: | |
MIN_COVERAGE_PERCENTAGE: 100 | |
jobs: | |
tests: | |
runs-on: ${{ matrix.os }} | |
timeout-minutes: 15 | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
python: [ | |
'3.8', '3.9', '3.10', '3.11', '3.12', '3.13', '3.14-dev', | |
'pypy-3.8', 'pypy-3.9', 'pypy-3.10', 'pypy-3.11' | |
] | |
include: | |
- os: ubuntu-22.04 | |
python: 3.7 | |
- os: macos-13 | |
python: 3.7 | |
- os: windows-latest | |
python: 3.7 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python }} | |
cache: 'pip' | |
- name: Install dependencies | |
run: python -m pip install build flit .[tests] | |
- name: PEP 8 style checks | |
run: python -m pycodestyle . | |
- name: Linting | |
run: python -m pylint --recursive=y . | |
- name: Typing (mypy) | |
run: python -m mypy -p tinytag | |
- name: Typing (pyright) | |
run: python -m pyright | |
- name: Unit tests | |
run: python -m coverage run --parallel-mode -m unittest | |
env: | |
TINYTAG_DEBUG: true | |
- name: Coverage report | |
run: | | |
coverage combine --keep --quiet | |
coverage report | |
coverage html --quiet | |
- name: Build package | |
run: python -m build | |
- name: Build package without isolation | |
run: python -m build --no-isolation | |
- name: Upload coverage data | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage-${{ matrix.os }}-${{ matrix.python }} | |
include-hidden-files: true | |
path: | | |
.coverage.* | |
htmlcov | |
coverage: | |
needs: tests | |
runs-on: ubuntu-latest | |
timeout-minutes: 15 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Download coverage data | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: coverage-* | |
merge-multiple: true | |
- name: Set up cache | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cache/pip | |
key: coverage | |
- name: Install dependencies | |
run: python -m pip install coverage | |
- name: Generate coverage report | |
run: | | |
coverage combine --quiet | |
coverage html --quiet | |
- name: Upload coverage report | |
uses: actions/upload-artifact@v4 | |
with: | |
name: combined-coverage-report | |
path: htmlcov | |
- name: Show coverage report | |
run: coverage report --fail-under=${MIN_COVERAGE_PERCENTAGE} |