forked from ansible-collections/community.mysql
-
Notifications
You must be signed in to change notification settings - Fork 0
357 lines (296 loc) · 10.6 KB
/
ansible-test-plugins.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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
---
name: Plugins CI
on: # yamllint disable-line rule:truthy
push:
paths:
- 'plugins/**'
- 'tests/**'
- '.github/workflows/ansible-test-plugins.yml'
pull_request:
paths:
- 'plugins/**'
- 'tests/**'
- '.github/workflows/ansible-test-plugins.yml'
schedule:
- cron: '0 6 * * *'
jobs:
sanity:
name: "Sanity (Ansible: ${{ matrix.ansible }})"
runs-on: ubuntu-22.04
strategy:
matrix:
ansible:
- stable-2.15
- stable-2.16
- stable-2.17
- devel
steps:
# https://github.com/ansible-community/ansible-test-gh-action
- name: Perform sanity testing
uses: ansible-community/ansible-test-gh-action@release/v1
with:
ansible-core-version: ${{ matrix.ansible }}
testing-type: sanity
pull-request-change-detection: true
integration:
name: "Integration (Python: ${{ matrix.python }}, Ansible: ${{ matrix.ansible }}, DB: ${{ matrix.db_engine_name }} ${{ matrix.db_engine_version }}, connector: ${{ matrix.connector_name }} ${{ matrix.connector_version }})"
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
ansible:
- stable-2.15
- stable-2.16
- stable-2.17
- devel
db_engine_name:
- mysql
- mariadb
db_engine_version:
- 5.7.40
- 8.0.31
- 10.4.27
- 10.5.18
- 10.6.11
python:
- '3.8'
- '3.9'
- '3.10'
connector_name:
- pymysql
- mysqlclient
connector_version:
- 0.7.11
- 0.9.3
- 1.0.2
- 2.0.1
- 2.0.3
- 2.1.1
exclude:
- db_engine_name: mysql
db_engine_version: 10.4.27
- db_engine_name: mysql
db_engine_version: 10.5.18
- db_engine_name: mysql
db_engine_version: 10.6.11
- db_engine_name: mariadb
db_engine_version: 5.7.40
- db_engine_name: mariadb
db_engine_version: 8.0.31
- connector_name: pymysql
connector_version: 2.0.1
- connector_name: pymysql
connector_version: 2.0.3
- connector_name: pymysql
connector_version: 2.1.1
- connector_name: mysqlclient
connector_version: 0.7.11
- connector_name: mysqlclient
connector_version: 0.9.3
- connector_name: mysqlclient
connector_version: 1.0.2
- db_engine_name: mariadb
connector_version: 0.7.11
- db_engine_version: 5.7.40
python: '3.9'
- db_engine_version: 5.7.40
python: '3.10'
- db_engine_version: 5.7.40
ansible: stable-2.15
- db_engine_version: 5.7.40
ansible: stable-2.16
- db_engine_version: 5.7.40
ansible: devel
- db_engine_version: 8.0.31
python: '3.8'
- db_engine_version: 10.4.27
python: '3.10'
- db_engine_version: 10.4.27
ansible: devel
- db_engine_version: 10.6.11
python: '3.8'
- db_engine_version: 10.6.11
python: '3.9'
- python: '3.8'
connector_version: 1.0.2
- python: '3.8'
connector_version: 2.0.3
- python: '3.8'
connector_version: 2.1.1
- python: '3.9'
connector_version: 0.7.11
- python: '3.9'
connector_version: 1.0.2
- python: '3.9'
connector_version: 2.0.1
- python: '3.9'
connector_version: 2.1.1
- python: '3.10'
connector_version: 0.7.11
- python: '3.10'
connector_version: 0.9.3
- python: '3.10'
connector_version: 2.0.1
- python: '3.10'
connector_version: 2.0.3
- python: '3.8'
ansible: stable-2.16
- python: '3.8'
ansible: stable-2.17
- python: '3.8'
ansible: devel
- python: '3.9'
ansible: stable-2.16
- python: '3.9'
ansible: stable-2.17
- python: '3.9'
ansible: devel
services:
db_primary:
image: docker.io/library/${{ matrix.db_engine_name }}:${{ matrix.db_engine_version }}
env:
MARIADB_ROOT_PASSWORD: msandbox
MYSQL_ROOT_PASSWORD: msandbox
ports:
- 3307:3306
# We write our own health-cmd because the mariadb container does not
# provide a healthcheck
options: >-
--health-cmd "mysqladmin ping -P 3306 -pmsandbox |grep alive || exit 1"
--health-start-period 10s
--health-interval 10s
--health-timeout 5s
--health-retries 6
db_replica1:
image: docker.io/library/${{ matrix.db_engine_name }}:${{ matrix.db_engine_version }}
env:
MARIADB_ROOT_PASSWORD: msandbox
MYSQL_ROOT_PASSWORD: msandbox
ports:
- 3308:3306
options: >-
--health-cmd "mysqladmin ping -P 3306 -pmsandbox |grep alive || exit 1"
--health-start-period 10s
--health-interval 10s
--health-timeout 5s
--health-retries 6
db_replica2:
image: docker.io/library/${{ matrix.db_engine_name }}:${{ matrix.db_engine_version }}
env:
MARIADB_ROOT_PASSWORD: msandbox
MYSQL_ROOT_PASSWORD: msandbox
ports:
- 3309:3306
options: >-
--health-cmd "mysqladmin ping -P 3306 -pmsandbox |grep alive || exit 1"
--health-start-period 10s
--health-interval 10s
--health-timeout 5s
--health-retries 6
steps:
# No need to check for service health. GitHub Action took care of it.
- name: Restart MySQL server with settings for replication
run: |
docker exec ${{ job.services.db_primary.id }} bash -c 'echo -e [mysqld]\\nserver-id=1\\nlog-bin=/var/lib/mysql/primary-bin > /etc/mysql/conf.d/replication.cnf'
docker exec ${{ job.services.db_replica1.id }} bash -c 'echo -e [mysqld]\\nserver-id=2\\nlog-bin=/var/lib/mysql/replica1-bin > /etc/mysql/conf.d/replication.cnf'
docker exec ${{ job.services.db_replica2.id }} bash -c 'echo -e [mysqld]\\nserver-id=3\\nlog-bin=/var/lib/mysql/replica2-bin > /etc/mysql/conf.d/replication.cnf'
docker restart -t 30 ${{ job.services.db_primary.id }}
docker restart -t 30 ${{ job.services.db_replica1.id }}
docker restart -t 30 ${{ job.services.db_replica2.id }}
- name: Wait for the primary to be healthy
run: >
while ! /usr/bin/docker inspect
--format="{{if .Config.Healthcheck}}{{print .State.Health.Status}}{{end}}"
${{ job.services.db_primary.id }}
| grep healthy && [[ "$SECONDS" -lt 120 ]]; do sleep 1; done
- name: Compute docker_image - Set python_version_flat
run: >
echo "python_version_flat=$(echo ${{ matrix.python }}
| tr -d '.')" >> $GITHUB_ENV
- name: Compute docker_image - Set connector_version_flat
run: >
echo "connector_version_flat=$(echo ${{ matrix.connector_version }}
|tr -d .)" >> $GITHUB_ENV
- name: Compute docker_image - Set db_engine_version_flat
run: >
echo "db_engine_version_flat=$(echo ${{ matrix.db_engine_version }}
| awk -F '.' '{print $1 $2}')" >> $GITHUB_ENV
- name: Compute docker_image - Set db_client
run: >
if [[ ${{ env.db_engine_version_flat }} == 57 ]]; then
echo "db_client=my57" >> $GITHUB_ENV;
else
echo "db_client=$(echo ${{ matrix.db_engine_name }})" >> $GITHUB_ENV;
fi
- name: Set docker_image
run: |-
echo "docker_image=ghcr.io/ansible-collections/community.mysql\
/test-container-${{ env.db_client }}\
-py${{ env.python_version_flat }}\
-${{ matrix.connector_name }}${{ env.connector_version_flat }}\
:latest" >> $GITHUB_ENV
- name: >-
Perform integration testing against
Ansible version ${{ matrix.ansible }}
under Python ${{ matrix.python }}
uses: ansible-community/ansible-test-gh-action@release/v1
with:
ansible-core-version: ${{ matrix.ansible }}
pre-test-cmd: >-
echo Setting db_engine_name to "${{ matrix.db_engine_name }}"...;
echo -n "${{ matrix.db_engine_name }}"
> tests/integration/db_engine_name;
echo Setting db_engine_version to \
"${{ matrix.db_engine_version }}"...;
echo -n "${{ matrix.db_engine_version }}"
> tests/integration/db_engine_version;
echo Setting Connector name to "${{ matrix.connector_name }}"...;
echo -n "${{ matrix.connector_name }}"
> tests/integration/connector_name;
echo Setting Connector name to "${{ matrix.connector_version }}"...;
echo -n "${{ matrix.connector_version }}"
> tests/integration/connector_version;
echo Setting Python version to "${{ matrix.python }}"...;
echo -n "${{ matrix.python }}"
> tests/integration/python;
echo Setting Ansible version to "${{ matrix.ansible }}"...;
echo -n "${{ matrix.ansible }}"
> tests/integration/ansible
docker-image: ${{ env.docker_image }}
target-python-version: ${{ matrix.python }}
testing-type: integration
units:
runs-on: ubuntu-22.04
name: Units (Ⓐ${{ matrix.ansible }})
strategy:
# As soon as the first unit test fails,
# cancel the others to free up the CI queue
fail-fast: true
matrix:
ansible:
- stable-2.15
- stable-2.16
- stable-2.17
- devel
python:
- 3.8
- 3.9
exclude:
- python: '3.8'
ansible: stable-2.15
- python: '3.8'
ansible: stable-2.16
- python: '3.8'
ansible: stable-2.17
- python: '3.8'
ansible: devel
steps:
- name: >-
Perform unit testing against
Ansible version ${{ matrix.ansible }}
uses: ansible-community/ansible-test-gh-action@release/v1
with:
ansible-core-version: ${{ matrix.ansible }}
target-python-version: ${{ matrix.python }}
testing-type: units
pull-request-change-detection: true