Skip to content

PyCon Backend Temporal Worker #2209

PyCon Backend Temporal Worker

PyCon Backend Temporal Worker #2209

name: Backend tests
on:
pull_request:
paths:
- "backend/**/*"
- "backend/*"
- ".github/workflows/backend-test.yml"
jobs:
unit-tests:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:14.5
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- 5432/tcp
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: "3.9.15"
- run: pip install poetry==1.4.2
- name: Cache Poetry
uses: actions/cache@v1
id: cache
with:
path: ~/.virtualenvs
key: poetry-${{ hashFiles('**/poetry.lock') }}-v2
restore-keys: |
poetry-${{ hashFiles('**/poetry.lock') }}-v2
- name: Set Poetry config
run: |
poetry config virtualenvs.create false
poetry config virtualenvs.path ~/.virtualenvs
- name: Install python dependencies
working-directory: backend
run: poetry install
if: steps.cache.outputs.cache-hit != 'true'
- name: Install codecov
working-directory: backend
run: pip install codecov
- name: pytest
working-directory: backend
run: |
set +e
OUTPUT=$(poetry run pytest --cov-report xml --cov=. --cov-fail-under 88)
STATUS=$?
echo "$OUTPUT"
cd ..
codecov
exit $STATUS
env:
DATABASE_URL: postgresql://postgres:postgres@localhost:${{ job.services.postgres.ports['5432'] }}/postgres
STRIPE_SECRET_KEY: fake-key
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
MEDIA_FILES_STORAGE_BACKEND: django.core.files.storage.FileSystemStorage