Try a different workflow to run the unit tests #60
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
# SPDX-FileCopyrightText: 2022 Carnegie Mellon University | |
# SPDX-License-Identifier: 0BSD | |
name: python | |
on: | |
pull_request: | |
branches: [main] | |
push: | |
branches: [main] | |
env: | |
PYTHONUNBUFFERED: 1 | |
jobs: | |
pre-commit: | |
name: Rerun pre-commit checks | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
- name: Install Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.8" | |
- name: Run pre-commit checks | |
uses: pre-commit/[email protected] | |
tests: | |
name: Tests | |
needs: pre-commit | |
strategy: | |
matrix: | |
python-version: ["3.7", "3.10"] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
- name: Install Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install poetry | |
uses: abatilo/actions-poetry@v2 | |
- name: Setup local environment for caching | |
run: | | |
poetry config virtualenvs.create true --local | |
poetry config virtualenvs.in-project true --local | |
- name: Define cache for virtual environments | |
uses: actions/cache@v3 | |
with: | |
path: ./.venv | |
key: venv-${{ hashFiles('poetry.lock') }} | |
- name: Install project dependencies | |
run: poetry install --no-interaction | |
- name: Run tests | |
run: poetry run pytest -v tests/ |