-
Notifications
You must be signed in to change notification settings - Fork 0
97 lines (82 loc) · 2.79 KB
/
tests.yml
File metadata and controls
97 lines (82 loc) · 2.79 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
name: Tests
on:
push:
pull_request:
jobs:
test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16
env:
POSTGRES_DB: app_db
POSTGRES_USER: app_user
POSTGRES_PASSWORD: app_password
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U app_user -d app_db"
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
DB_HOST: 127.0.0.1
DB_PORT: 5432
DB_NAME: app_db
TEST_DB_NAME: test_db
DB_USER: app_user
DB_PASSWORD: app_password
AGENT_CREDENTIAL_HASH_SECRET: local-dev-agent-credential-hash-secret
steps:
- name: Check out repository
uses: actions/checkout@v5
- name: Set up Python 3.13
uses: actions/setup-python@v6
with:
python-version: "3.13"
- name: Install PostgreSQL client
run: |
sudo apt-get update
sudo apt-get install -y postgresql-client
- name: Install project
run: |
python -m pip install --upgrade pip
python -m pip install ".[dev]"
- name: Wait for Postgres
run: |
until pg_isready -h 127.0.0.1 -p 5432 -U app_user -d app_db; do
sleep 1
done
env:
PGPASSWORD: app_password
- name: Create test database if missing
run: |
EXISTS=$(psql -h 127.0.0.1 -p 5432 -U app_user -d postgres -tAc "SELECT 1 FROM pg_database WHERE datname = 'test_db';")
if [ "$EXISTS" != "1" ]; then
psql -h 127.0.0.1 -p 5432 -U app_user -d postgres -c "CREATE DATABASE test_db;"
fi
env:
PGPASSWORD: app_password
- name: Apply app_db schema
run: |
psql -h 127.0.0.1 -p 5432 -U app_user -d app_db -f migrations/001_create_documents_table.sql
psql -h 127.0.0.1 -p 5432 -U app_user -d app_db -f migrations/003_create_pdp_audit_table.sql
psql -h 127.0.0.1 -p 5432 -U app_user -d app_db -f migrations/004_create_registered_agent_credentials.sql
env:
PGPASSWORD: app_password
- name: Apply test_db schema
run: |
psql -h 127.0.0.1 -p 5432 -U app_user -d test_db -f migrations/001_create_documents_table.sql
psql -h 127.0.0.1 -p 5432 -U app_user -d test_db -f migrations/003_create_pdp_audit_table.sql
psql -h 127.0.0.1 -p 5432 -U app_user -d test_db -f migrations/004_create_registered_agent_credentials.sql
env:
PGPASSWORD: app_password
- name: Run Ruff lint
run: |
python -m ruff check .
- name: Run unit tests
run: |
python -m pytest -m unit
- name: Run integration tests
run: |
python -m pytest -m integration