Skip to content

Build & Test

Build & Test #22

Workflow file for this run

# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: build-and-test
run-name: Build & Test
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
permissions:
contents: read
jobs:
ci:
runs-on: ubuntu-latest
services:
postgres:
image: 'postgres:11'
ports:
- 5432:5432
env:
POSTGRES_USER: test
POSTGRES_PASSWORD: postgres
POSTGRES_DB: test
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v3
- name: Install poetry
run: pipx install poetry
- uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'poetry'
- run: poetry install --without vscode
- run: poetry run black --check ./api/
- run: poetry run isort --check ./api/
- run: poetry run pytest --cov=api --cov-config=.coveragerc --cov-report=xml
env:
# Configuration details for connecting to Dockerized postgres
POSTGRES_HOST: localhost
POSTGRES_PORT: 5432
POSTGRES_USER: test
POSTGRES_PASSWORD: postgres
POSTGRES_DB: test
SECRET_KEY: testsecret
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
fail_ci_if_error: true
flags: unittests