Update CI actions #20
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-2023 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@v5 | |
with: | |
python-version: "3.8" | |
- name: Run pre-commit checks | |
uses: pre-commit/action@v3.0.1 | |
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@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install Poetry | |
run: | | |
pipx install poetry | |
echo "POETRY_CACHE_DIR=$(pip cache dir)" >> $GITHUB_ENV | |
- name: Cache poetry | |
uses: actions/cache@v4 | |
with: | |
path: ${{ env.POETRY_CACHE_DIR }} | |
key: ${{ runner.os }}-poetry-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }} | |
restore-keys: ${{ runner.os }}-poetry-${{ matrix.python-version }} | |
- name: Install project dependencies | |
run: poetry install --sync --no-interaction | |
- name: Run tests | |
run: poetry run pytest -v tests/ |