-
Notifications
You must be signed in to change notification settings - Fork 1
103 lines (91 loc) · 2.49 KB
/
Copy pathci.yml
File metadata and controls
103 lines (91 loc) · 2.49 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
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
frontend-test:
name: Frontend tests
runs-on: ubuntu-latest
defaults:
run:
working-directory: frontend
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v6
with:
node-version: "20"
cache: yarn
cache-dependency-path: frontend/yarn.lock
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Run Jest (CI)
run: yarn test:ci
backend-test:
name: Backend tests
runs-on: ubuntu-latest
services:
mongo:
image: mongo:7
ports:
- 27017:27017
options: >-
--health-cmd "mongosh --eval 'db.adminCommand({ ping: 1 })'"
--health-interval 10s
--health-timeout 5s
--health-retries 5
redis:
image: redis:7-alpine
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
REACT_APP_BACKEND_URL: http://127.0.0.1:8000
defaults:
run:
working-directory: backend
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v6
with:
python-version: "3.12"
cache: pip
cache-dependency-path: backend/requirements.txt
- name: Install dependencies
run: pip install -r requirements.txt
- name: Write CI .env
run: |
cat > .env <<'EOF'
MONGO_URL=mongodb://127.0.0.1:27017/?directConnection=true
DB_NAME=ssc-ci
JWT_SECRET=ci-only-jwt-secret-not-for-production
CONTACT_GRAPH_PEPPER=ci-only-contact-graph-pepper
REDIS_URL=redis://localhost:6379/0
ENV=development
LOG_LEVEL=WARNING
EOF
- name: Run pytest with live API
run: |
uvicorn server:app --host 127.0.0.1 --port 8000 &
for i in $(seq 1 60); do
if curl -sf http://127.0.0.1:8000/api/health >/dev/null; then
echo "API ready"
break
fi
if [ "$i" -eq 60 ]; then
echo "API failed to start"
exit 1
fi
sleep 2
done
python -m pytest tests/ -q --timeout=120