-
Notifications
You must be signed in to change notification settings - Fork 9
169 lines (135 loc) · 5.38 KB
/
backend_integration_tests_pr.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
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
166
167
168
name: CI
on:
pull_request:
types:
- opened
- labeled
- synchronize
pull_request_review:
types:
- submitted
- edited
concurrency:
group: backend-e2e-${{ github.event.number || github.event.pull_request.number}}
cancel-in-progress: true
jobs:
triggers:
name: Get Triggers
runs-on: ubuntu-latest
outputs:
is_pull_request_opened: ${{ github.event_name == 'pull_request' && github.event.action == 'opened'}}
is_pull_request_review_approved: ${{ github.event_name == 'pull_request_review' && github.event.review.state == 'APPROVED'}}
is_pull_request_labeled_with_run_tests: ${{ github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'run-tests')}}
steps:
- run: true
test:
needs: triggers
if: ${{ needs.triggers.outputs.is_pull_request_opened == 'true' || needs.triggers.outputs.is_pull_request_review_approved == 'true' || needs.triggers.outputs.is_pull_request_labeled_with_run_tests == 'true' }}
runs-on: ubuntu-latest
env:
PYTHONPATH: ${{ github.workspace }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Copy .env file
run: cp .env.example .env
# TODO: we should also add also heuristai and anthropic keys to the e2e tests and test all providers
- name: Set OPENAIKEY in the .env file so it can be loaded from the environment
env:
OPENAIKEY: ${{ secrets.OPENAIKEY }}
run: |
sed -i "s/<add_your_openai_api_key_here>/${OPENAIKEY}/g" .env
sed -i "s/FINALITY_WINDOW =.*/FINALITY_WINDOW = 10/" .env
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Build Docker images
run: docker compose build
- name: Run Docker Compose
run: docker compose up -d
- name: Wait for services to be up
timeout-minutes: 5
run: |
timeout=60
counter=0
while [[ "$counter" -lt "$timeout" ]]; do
if curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"ping","params":[],"id":1}' http://0.0.0.0:4000/api | grep -q "OK"; then
echo "RPC server is up!"
break
else
echo "Waiting for RPC server... ($counter/$timeout)"
sleep 5
counter=$((counter+1))
fi
done
# Fail if the service didn't start within the timeout
if [[ "$counter" -ge "$timeout" ]]; then
echo "Error: Timeout while waiting for RPC server"
exit 1
fi
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.12.4
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements.test.txt
- name: Run tests
run: pytest tests/integration/ -svv
- name: Dump Docker Compose logs
run: docker compose logs
if: failure()
- name: Shutdown Docker Compose
if: always()
run: docker compose down
db-integration-test:
needs: triggers
if: ${{ needs.triggers.outputs.is_pull_request_opened == 'true' || needs.triggers.outputs.is_pull_request_review_approved == 'true' || needs.triggers.outputs.is_pull_request_labeled_with_run_tests == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Run Docker Compose
run: docker compose -f tests/db-sqlalchemy/docker-compose.yml --project-directory . up tests --build --force-recreate --always-recreate-deps
load-test:
name: Load Tests
needs: triggers
if: ${{ needs.triggers.outputs.is_pull_request_opened == 'true' || needs.triggers.outputs.is_pull_request_review_approved == 'true' || needs.triggers.outputs.is_pull_request_labeled_with_run_tests == 'true' }}
uses: ./.github/workflows/load-test-oha.yml
with:
oha-version: "v1.4.5"
hardhat-test:
needs: triggers
if: ${{ needs.triggers.outputs.is_pull_request_opened == 'true' || needs.triggers.outputs.is_pull_request_review_approved == 'true' || needs.triggers.outputs.is_pull_request_labeled_with_run_tests == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Run Docker Compose
run: docker compose -f tests/hardhat/docker-compose.yml --project-directory . up tests --build --force-recreate --always-recreate-deps