-
Notifications
You must be signed in to change notification settings - Fork 12
74 lines (71 loc) · 2.1 KB
/
unit_tests.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: Run Backend Unit Tests
on:
workflow_dispatch:
pull_request:
types:
- opened
- synchronize
- reopened
branches:
- "main"
concurrency:
# Cancel previous jobs
group: unit_tests-${{ github.ref }}
cancel-in-progress: true
jobs:
backend-unit-tests:
runs-on: ubuntu-latest
environment: testing_env
env:
TEST_DATABASE_URL: "postgres://postgres:postgres@localhost:5432/test_metaculus"
services:
db:
image: pgvector/pgvector:pg16
env:
POSTGRES_HOST_AUTH_METHOD: trust
POSTGRES_DB: test_metaculus
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
redis:
image: "bitnami/redis:7.2.5"
env:
ALLOW_EMPTY_PASSWORD: yes
ports:
- 6379:6379
steps:
- name: Check out repository
uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12.3"
- name: Install poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
installer-parallel: true
virtualenvs-in-project: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
- name: Run Flake8 Linter
if: ${{ !cancelled() }}
run: poetry run flake8 . --exclude=front_end,.venv
- name: Check migrations
if: ${{ !cancelled() }}
run: poetry run python manage.py makemigrations --dry-run --check
- name: "Run he backend unit tests"
if: ${{ !cancelled() }}
run: poetry run pytest ./tests/unit