-
Notifications
You must be signed in to change notification settings - Fork 0
165 lines (150 loc) · 4.76 KB
/
Copy pathci.yml
File metadata and controls
165 lines (150 loc) · 4.76 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
name: Backend Test Suite
on:
push:
branches: [develop]
pull_request:
branches: [develop]
workflow_dispatch:
permissions:
contents: read
concurrency:
group: backend-tests-${{ github.ref }}
cancel-in-progress: true
jobs:
backend:
name: Run full backend test suite
runs-on: ubuntu-latest
timeout-minutes: 45
services:
paradedb:
image: paradedb/paradedb:0.18.11
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: opengeometadata_api
ports:
- 2345:5432
options: >-
--health-cmd "pg_isready -U postgres -d opengeometadata_api"
--health-interval 5s
--health-timeout 5s
--health-retries 12
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:9.0.0
env:
discovery.type: single-node
xpack.security.enabled: "false"
ES_JAVA_OPTS: -Xms1g -Xmx1g
ports:
- 9200:9200
options: >-
--ulimit nofile=65536:65536
--health-cmd "curl -fsS http://localhost:9200/_cluster/health?wait_for_status=yellow&timeout=60s || exit 1"
--health-interval 10s
--health-timeout 10s
--health-retries 18
redis:
image: redis:7.4.6-alpine
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping | grep PONG"
--health-interval 5s
--health-timeout 3s
--health-retries 12
env:
APP_ENV: test
POSTGRES_PASSWORD: postgres
DB_PASSWORD: postgres
DB_USER: postgres
DB_HOST: localhost
DB_PORT: "2345"
TEST_DB_NAME: opengeometadata_api_test
DATABASE_URL: postgresql+asyncpg://postgres:postgres@localhost:2345/opengeometadata_api_test
APPLICATION_URL: http://localhost:8000
ELASTICSEARCH_URL: http://localhost:9200
ELASTICSEARCH_INDEX: opengeometadata_api_test
REDIS_HOST: localhost
REDIS_PORT: "6379"
REDIS_DB: "1"
ENDPOINT_CACHE: "false"
TURNSTILE_ENABLED: "false"
DISABLE_API_USAGE_LOG: "true"
DISABLE_RATE_LIMIT_FOR_TESTS: "true"
WALLCLOCK_TIMEOUT_SECONDS: "900"
TIMEOUT_GRACE_SECONDS: "30"
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
gcc \
g++ \
python3-dev \
libjpeg-dev \
zlib1g-dev \
libpng-dev \
libcairo2-dev \
pkg-config \
gdal-bin \
libgdal-dev \
curl \
ca-certificates
- name: Set up Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: "3.11"
cache: pip
cache-dependency-path: |
backend/pyproject.toml
backend/uv.lock
- name: Install backend dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -e "backend[dev]"
- name: Prepare backend test database
working-directory: backend
run: |
python - <<'PY'
import os
import psycopg2
from psycopg2 import sql
from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT
db_name = os.environ["TEST_DB_NAME"]
conn = psycopg2.connect(
dbname="postgres",
user=os.environ["DB_USER"],
password=os.environ["DB_PASSWORD"],
host=os.environ["DB_HOST"],
port=os.environ["DB_PORT"],
)
conn.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT)
try:
with conn.cursor() as cur:
cur.execute("SELECT 1 FROM pg_database WHERE datname = %s", (db_name,))
if cur.fetchone() is None:
cur.execute(
sql.SQL("CREATE DATABASE {}").format(sql.Identifier(db_name))
)
finally:
conn.close()
PY
- name: Run backend tests with coverage
working-directory: backend
run: |
python scripts/run_with_timeout.py \
python -X faulthandler -m pytest \
-n 2 \
-m "not network" \
--cov=app \
--cov-report=term-missing \
--cov-report=xml \
--cov-fail-under=50
- name: Upload backend coverage
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: backend-coverage
path: backend/coverage.xml
if-no-files-found: ignore