-
Notifications
You must be signed in to change notification settings - Fork 21
153 lines (148 loc) · 4.87 KB
/
integration-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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
name: Integration test
on:
workflow_dispatch:
env:
REDIS_VERSION: 6
PYTHON_VERSION: 3.8
MOSQUITTO_VERSION: 2.0
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true
jobs:
unit_test_backend:
name: Unit testing backend
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Start Redis ${{env.REDIS_VERSION}}
uses: supercharge/[email protected]
with:
redis-version: ${{env.REDIS_VERSION}}
- name: Start MongoDB
uses: supercharge/[email protected]
- name: Start Mosquitto broker ${{env.MOSQUITTO_VERSION}}
uses: Namoshek/mosquitto-github-action@v1
with:
version: ${{env.MOSQUITTO_VERSION}}
ports: '1883:1883'
- name: Set up Python ${{env.PYTHON_VERSION}}
uses: actions/setup-python@v3
with:
python-version: ${{env.PYTHON_VERSION}}
- name: Install dependencies
run: pip install -r requirements.txt
working-directory: ./back
- name: Test
run: python -m unittest discover
working-directory: ./back
build_and_push_backend:
name: Build and push backend
runs-on: ubuntu-latest
needs: unit_test_backend
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.PACKAGES_TOKEN }}
- name: Build and push BE
uses: docker/build-push-action@v4
with:
context: .
file: ./docker/Dockerfile-back
platforms: linux/amd64
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/homewarelan-back:dev
build_push_frontend:
name: Build and push frontend
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 18
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.PACKAGES_TOKEN }}
- name: Build and push FE
uses: docker/build-push-action@v4
with:
context: .
file: ./docker/Dockerfile-nginx
platforms: linux/amd64
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/homewarelan-nginx:dev
create_gcloud_vm:
name: Create VM
runs-on: ubuntu-latest
steps:
- uses: "actions/checkout@v3"
- uses: "google-github-actions/auth@v1"
with:
credentials_json: ${{ secrets.GCLOUD_SERVICE_ACCOUNT }}
- name: Setup Google Cloud SDK
uses: google-github-actions/setup-gcloud@v1
with:
version: ">= 363.0.0"
project_id: ${{ secrets.GCLOUD_PROJECT_ID }}
- name: "Create VM"
run: |
gcloud compute instances create homeware-integration-test --source-instance-template=${{ secrets.GCLOUD_MACHINE_TEMPLATE }} --zone=europe-north1-a
- name: "Wait until Homeware is ready"
uses: cygnetdigital/[email protected]
with:
url: ${{ secrets.HOMEWARE_HOST }}/test
responseCode: '200'
timeout: 240000
interval: 5000
integration_test:
name: Integration test
runs-on: ubuntu-latest
needs: create_gcloud_vm
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{env.PYTHON_VERSION}}
uses: actions/setup-python@v3
with:
python-version: ${{env.PYTHON_VERSION}}
- name: Install dependencies
run: pip install -r requirements.txt
working-directory: ./back
- name: Test
run: pytest -v --host=${{ secrets.HOMEWARE_HOST }} --username=${{ secrets.HOMEWARE_USERNAME }} --password=${{ secrets.HOMEWARE_PASSWORD }}
working-directory: ./back/tests_integration
delete_gcloud_vm:
name: Delete VM
runs-on: ubuntu-latest
needs: integration_test
steps:
- uses: "actions/checkout@v3"
- uses: "google-github-actions/auth@v1"
with:
credentials_json: ${{ secrets.GCLOUD_SERVICE_ACCOUNT }}
- name: Setup Google Cloud SDK
uses: google-github-actions/setup-gcloud@v1
with:
version: ">= 363.0.0"
project_id: ${{ secrets.GCLOUD_PROJECT_ID }}
- name: "Delete VM"
run: |
gcloud compute instances delete homeware-integration-test