-
Notifications
You must be signed in to change notification settings - Fork 19
74 lines (67 loc) · 2.13 KB
/
backend-test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
name: Backend tests
on:
push:
branches:
- main
pull_request:
paths:
- "backend/**/*"
- "backend/*"
- ".github/workflows/backend-test.yml"
jobs:
unit-tests:
runs-on: ubuntu-latest
defaults:
run:
working-directory: backend
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
redis:
image: redis:7.2.3
options: --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5
ports:
- 6379:6379
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11.6"
- run: pip install pdm==2.10.4 codecov
- name: Cache PDM
uses: actions/cache@v4
id: cache-deps
with:
path: backend/.venv
key: pdm-${{ hashFiles('**/pdm.lock') }}-1
- name: Install python dependencies
if: steps.cache-deps.outputs.cache-hit != 'true'
run: pdm install
- name: pytest
run: |
set +e
CPUS=$(nproc --all)
OUTPUT=$(pdm run pytest --cov-report xml --cov=. --cov-fail-under 80 --durations 10 -n $CPUS)
STATUS=$?
echo "$OUTPUT"
cd ..
codecov
exit $STATUS
env:
DATABASE_URL: postgresql://postgres:postgres@localhost:${{ job.services.postgres.ports['5432'] }}/postgres
CACHE_URL: redis://localhost:6379/0
CELERY_BROKER_URL: redis://redis:6379/1
CELERY_RESULT_BACKEND: redis://redis:6379/2
STRIPE_SECRET_API_KEY: fake-key
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
MEDIA_FILES_STORAGE_BACKEND: django.core.files.storage.FileSystemStorage
STRIPE_SUBSCRIPTION_PRICE_ID: ""
STRIPE_WEBHOOK_SIGNATURE_SECRET: ""