π check environment variable values #19
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
name: Backend testing | |
on: | |
push: | |
branches: [ "master" ] | |
pull_request: | |
branches: [ "master" ] | |
permissions: | |
contents: read | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./backend | |
# Service containers to run with `container-job` | |
services: | |
# Label used to access the service container | |
postgres: | |
# Docker Hub image | |
image: postgres | |
# Provide the password for postgres | |
env: | |
POSTGRES_PASSWORD: postgres | |
# Set health checks to wait until postgres has started | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
# Maps tcp port 5432 on service container to the host | |
- 5432:5432 | |
env: | |
DB_HOST: localhost | |
DB_PORT: 5432 | |
DB_NAME: postgres | |
DB_USER: postgres | |
DB_PASSWORD: postgres | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Poetry | |
uses: snok/install-poetry@v1 | |
- name: Install dependencies and Python | |
run: | | |
poetry install | |
- name: Set up database | |
run: | | |
poetry run python database/populate_database.py | |
- name: Test with pytest | |
run: | | |
poetry run pytest -s -v --full-trace tests/test_main.py::test_login_administrator |