-
Notifications
You must be signed in to change notification settings - Fork 3
84 lines (67 loc) · 2.23 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
name: Run tests
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.10", "3.12" ]
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Podman and Buildah
run: |
sudo apt-get update
sudo apt-get install -y podman buildah
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: '${{ matrix.python-version }}'
- name: Install pytest
run: |
python -m pip install pytest hatch-vcs
python -m pip install .
- name: Build the web image
run: |
APP_VERSION=$(hatch version)
buildah bud -t tmt-web:latest --build-arg PYTHON_VERSION=${{ matrix.python-version }} .
- name: Create Podman pod
run: |
podman pod create --name tmt-web-pod -p 8000:8000 -p 6379:6379 || true
# I don't even know, now it threw "docker://k8s.gcr.io/pause:3.5: Requesting bear token: invalid status code from registry 404"
# Exposing redis port as well for test_api.py::TestCelery::test_basic_test_request
- name: Start Redis container
run: |
podman run -d --pod tmt-web-pod --name redis redis:latest
- name: Start Celery container
run: |
podman run -d --pod tmt-web-pod --name celery \
-e REDIS_URL=redis://localhost:6379 \
-e API_HOSTNAME=http://localhost:8000 \
tmt-web:latest celery --app=tmt_web.api.service worker --loglevel=INFO
- name: Start Web container
run: |
podman run -d --pod tmt-web-pod --name web \
-e REDIS_URL=redis://localhost:6379 \
-e API_HOSTNAME=http://localhost:8000 \
tmt-web:latest uvicorn tmt_web.api:app --reload --host 0.0.0.0 --port 8000
- name: Wait for services to be ready
run: |
for i in {1..30}; do
if curl -s http://localhost:8000/health; then
break
fi
sleep 4
done
- name: Run tests
run: |
python -m pytest
- name: Cleanup
if: always()
run: |
podman pod stop tmt-web-pod
podman pod rm tmt-web-pod