-
Notifications
You must be signed in to change notification settings - Fork 0
136 lines (114 loc) · 3.32 KB
/
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
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
name: Tests
on:
pull_request:
branches:
- main
push:
branches:
- main
jobs:
build:
name: Build Docker image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker image
uses: docker/build-push-action@v5
with:
context: .
file: server/services/manager/Dockerfile
target: builder
outputs: type=docker,dest=/tmp/app-image.tar
tags: tacoq-manager:latest
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Upload Docker image
uses: actions/upload-artifact@v4
with:
name: app-image
path: /tmp/app-image.tar
test:
name: Run tests
needs: build
runs-on: ubuntu-latest
env:
DATABASE_URL: postgres://postgres:postgres@localhost:5432/test_db
services:
postgres:
image: postgres:latest
env:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
POSTGRES_DB: test_db
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
- name: Download Docker image
uses: actions/download-artifact@v4
with:
name: app-image
path: /tmp
- name: Load Docker image
run: docker load --input /tmp/app-image.tar
- name: Set up database and run migrations
run: |
docker run --network host \
-e DATABASE_URL=${DATABASE_URL} \
tacoq-manager /bin/bash -c "
cargo install sqlx-cli --no-default-features --features postgres &&
cargo sqlx database create &&
cargo sqlx migrate run --source ./server/libs/db-common/migrations
"
- name: Run tests in container
run: |
docker run --network host \
-e DATABASE_URL=${DATABASE_URL} \
tacoq-manager cargo test --all-features
e2e-test:
name: End-to-end tests
runs-on: ubuntu-latest
needs: [build, test]
steps:
- uses: actions/checkout@v4
- name: Download Docker image
uses: actions/download-artifact@v4
with:
name: app-image
path: /tmp
- name: Load Docker image
run: docker load --input /tmp/app-image.tar
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.12"
- name: Install uv
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Install Python dependencies
run: |
cd client_sdks/python
uv sync --dev
- name: Start test environment
run: |
cd client_sdks
docker compose -f docker-compose.test.yml up -d --wait
- name: Run end-to-end tests
env:
MANAGER_TEST_URL: http://localhost:3000
BROKER_TEST_URL: amqp://user:password@localhost:5672
run: |
cd client_sdks/python
uv run pytest
- name: Cleanup test environment
if: always()
run: |
cd client_sdks
docker compose -f docker-compose.test.yml down