Skip to content

Test

Test #48

Workflow file for this run

name: test
on:
pull_request:
branches: [main]
jobs:
test:
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.12"]
poetry-version: ["1.8.3"]
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install poetry
uses: abatilo/actions-poetry@v2
with:
poetry-version: ${{ matrix.poetry-version }}
- name: Setup a local virtual environment
run: |
poetry config virtualenvs.create true --local
poetry config virtualenvs.in-project true --local
- uses: actions/cache@v3
name: Define a cache for the virtual environment based on the dependencies lock file
with:
path: ./.venv
key: venv-${{ hashFiles('poetry.lock') }}
- name: Install project dependencies
run: poetry install
env:
# Don't give up too soon
POETRY_REQUESTS_TIMEOUT: '120'
- name: Run tests
run: poetry run pytest
# Calculate the test coverage and upload results
- name: Get and upload test coverage
if: matrix.python-version == '3.12' && matrix.os == 'ubuntu-latest'
run: |
# Replace `linux` below with the appropriate OS (Options are `alpine`, `linux`, `macos`, `windows`)
poetry run pytest --cov pooltool --cov-report=xml
curl -Os https://cli.codecov.io/latest/linux/codecov
chmod +x codecov
./codecov --verbose upload-process --fail-on-error -t ${{ secrets.CODECOV_TOKEN }} -n 'service'-${{ github.run_id }} -F service -f coverage.xml