-
Notifications
You must be signed in to change notification settings - Fork 1
49 lines (38 loc) · 1.23 KB
/
test-api.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
name: Test API Predict
on:
push:
branches: ["master", "mike0.9"]
pull_request:
branches: ["master"]
jobs:
test-api:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: "3.12"
- name: Install test dependencies
run: |
python -m pip install --upgrade pip
pip install pytest requests
- name: Create Docker network
run: docker network create backend
- name: Build and start API container
run: |
docker compose -f app/docker-compose.yml up -d api-predict --build
- name: Wait for API to be ready
run: |
timeout 60s bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:8002/model_info)" != "200" ]]; do sleep 1; done' || false
- name: Run API tests
run: |
pytest tests/test_api_predict.py -v
- name: Docker logs on failure
if: failure()
run: docker compose -f app/docker-compose.yml logs api-predict
- name: Stop containers
if: always()
run: |
docker compose -f app/docker-compose.yml down
docker network rm backend