Skip to content

Add test github workflow #1

Add test github workflow

Add test github workflow #1

Workflow file for this run

#.github/workflows/tests.yaml
name: Unit Tests
on:
pull_request:
branches:
- main
- develop
push:
branches:
- '**' # Every branch
jobs:
tests:
if: github.repository_owner == 'paulovcmedeiros'
strategy:
fail-fast: true
matrix:
os: [ "ubuntu-latest" ]
env: [ "pytest" ]
python-version: [ "3.9" ]
name: "${{ matrix.os }}, python=${{ matrix.python-version }}"
runs-on: ${{ matrix.os }}
container:
image: python:${{ matrix.python-version }}-bullseye
env:
COVERAGE_FILE: ".coverage.${{ matrix.env }}.${{ matrix.python-version }}"
steps:
#----------------------------------------------
# check-out repo
#----------------------------------------------
- name: Check out repository
uses: actions/checkout@v3
#----------------------------------------------
# --- configure poetry & install project ----
#----------------------------------------------
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
- name: Load cached venv (if cache exists)
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: ${{ github.job }}-venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/pyproject.toml', '**/poetry.toml') }}
- name: Install dependencies (if venv cache is not found)
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root --only main,test
- name: Install the project itself
run: poetry install --no-interaction --only-root
#----------------------------------------------
# run test suite and report coverage
#----------------------------------------------
- name: Run tests
run: |
poetry run pytest
- name: Upload test coverage report to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./.coverage.xml