-
Notifications
You must be signed in to change notification settings - Fork 0
84 lines (67 loc) · 2.05 KB
/
setup-docker-and-run-tests.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: setup-docker-and-run-tests.yml
on: [push]
jobs:
setup-and-start-services:
name: Setup Docker and Start Services
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Fiware Environment
run: |
cd fiware-environment
docker compose pull
docker compose up -d
- name: Create .env File
run: |
cp .env.EXAMPLE .env
- name: Build docker images
run: |
docker compose build
docker compose up -d
- name: Wait for service to be ready
run: |
until curl -s http://localhost:5173; do
echo "Waiting for service to be ready..."
sleep 5
done
- name: Get Docker container IP
id: get-ip
run: |
CONTAINER_ID=$(docker ps -q --filter "name=mqtt_gateway_api")
CONTAINER_IP=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $CONTAINER_ID)
echo "CONTAINER_IP=$CONTAINER_IP" >> $GITHUB_ENV
- name: Save IP address
run: echo $CONTAINER_IP > container_ip.txt
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: container-ip
path: container_ip.txt
run-tests:
name: Run Tests
runs-on: ubuntu-latest
needs: setup-and-start-services
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: container-ip
path: .
- name: Read IP address
id: read-ip
run: |
CONTAINER_IP=$(cat container_ip.txt)
echo "CONTAINER_IP=$CONTAINER_IP" >> $GITHUB_ENV
- name: Create .env File
run: |
cd tests
cp .env.test.example .env
sed -i "s/localhost/$CONTAINER_IP/g" .env
- name: Run tests
run: |
cd tests
pip install -r requirements.txt
python -m unittest test_crud.py