ci(tests): add speed benchmark using CodSpeed #170
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: tests | |
on: | |
push: | |
branches: main | |
pull_request: | |
branches: main | |
jobs: | |
pytest: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest] | |
python: [3.9] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python }} | |
architecture: x64 | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade uv | |
uv pip install --system -e ".[test]" | |
- name: Run unittests | |
run: pytest --cov=torchcam --cov-report xml tests/ | |
- uses: actions/upload-artifact@v2 | |
with: | |
name: coverage-reports | |
path: ./coverage.xml | |
- name: Run benchmarks | |
uses: CodSpeedHQ/action@v2 | |
with: | |
token: ${{ secrets.CODSPEED_TOKEN }} | |
run: pytest --codspeed tests/ | |
codecov-upload: | |
runs-on: ubuntu-latest | |
needs: pytest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- uses: actions/download-artifact@v2 | |
- uses: codecov/codecov-action@v3 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
flags: unittests | |
directory: ./coverage-reports | |
fail_ci_if_error: true | |
headers: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Check the headers | |
uses: frgfm/validate-python-headers@main | |
with: | |
license: 'Apache-2.0' | |
owner: 'François-Guillaume Fernandez' | |
starting-year: 2020 | |
folders: 'torchcam,scripts,demo,docs,.github' | |
ignores: 'version.py,__init__.py' |