Run tests in CI, add code coverage #1
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
# Builds the `hfppl` poetry environment and runs all tests | |
# Adapted from: https://github.com/marketplace/actions/install-poetry-action | |
name: Codebase tests | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
permissions: | |
contents: read | |
jobs: | |
build: | |
runs-on: ParallelHoss | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
- name: Set up python | |
id: setup-python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' | |
- name: Install Poetry | |
uses: snok/install-poetry@v1 | |
- name: Load cached venv | |
id: cached-poetry-dependencies | |
uses: actions/cache@v3 | |
with: | |
path: .venv | |
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }} | |
- name: Install project | |
run: poetry install --no-interaction | |
- name: Run tests | |
run: | | |
eval $(poetry env activate) | |
pytest -v --cov=hfppl --cov-report=json | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v5 | |
with: | |
fail_ci_if_error: false | |
disable_search: true | |
token: ${{ secrets.CODECOV_TOKEN }} | |
files: ./coverage.json | |
slug: probcomp/hfppl |