add basic test workflow #100
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
| name: Run Checks | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| pull_request: | |
| branches: [ "main" ] | |
| merge_group: | |
| jobs: | |
| test: | |
| strategy: | |
| matrix: | |
| python: [ "3.8", "3.9", "3.10", "3.11", "3.12", "3.13" ] | |
| os: [ ubuntu-latest, macos-latest, windows-latest ] | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v4.2.2 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5.3.0 | |
| with: | |
| python-version: ${{ matrix.python }} | |
| - name: Get Python Version | |
| id: get_python_version | |
| run: echo "python_version=$(python --version)" >> $GITHUB_OUTPUT | |
| shell: bash | |
| - name: Cache dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: .venv | |
| key: ${{ runner.os }}-${{ steps.get_python_version.outputs.python_version }}-dependencies-${{ hashFiles('**/pdm.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-${{ steps.get_python_version.outputs.python_version }}-dependencies | |
| - name: Install PDM | |
| run: pip install pdm | |
| - name: Install Dependencies | |
| run: pdm install | |
| - name: Check formatting | |
| run: pdm run ruff format . --check | |
| - name: Run mypy | |
| run: pdm mypy --show-error-codes | |
| - name: Lint | |
| run: pdm run ruff check . | |
| - name: Run pytest without coverage | |
| if: matrix.os != 'ubuntu-latest' | |
| run: pdm test | |
| env: | |
| TASKIPY: true | |
| - name: Run pytest with coverage | |
| if: matrix.os == 'ubuntu-latest' | |
| run: pdm test_with_coverage | |
| env: | |
| TASKIPY: true | |
| - run: mv .coverage .coverage.${{ matrix.python }} | |
| if: matrix.os == 'ubuntu-latest' | |
| - name: Store coverage report | |
| uses: actions/upload-artifact@v4.4.3 | |
| if: matrix.os == 'ubuntu-latest' | |
| with: | |
| name: coverage-${{ matrix.python }} | |
| path: .coverage.${{ matrix.python }} | |
| if-no-files-found: error | |
| include-hidden-files: true |