-
Notifications
You must be signed in to change notification settings - Fork 8
200 lines (174 loc) · 7.07 KB
/
CI.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
# vim: ts=2: sw=2: ai: si
# CI workflow
name: CI
on:
workflow_dispatch:
workflow_call:
pull_request:
types: [ opened, synchronize, reopened, ready_for_review ]
paths:
- 'plugins/**/*'
- 'tests/**/*'
- '.github/workflows/CI.yml'
push:
branches: [ master ]
paths:
- 'plugins/**/*'
- 'tests/**/*'
- '.github/workflows/CI.yml'
jobs:
check_runs:
if: github.event.pull_request.draft == false
name: Making sure no other CI is running
env:
# Workflow names that cannot run in parallel with this workflow, separated by spaces
# Example: incompatible_parallel_workflows: 'CI Build Name OtherName Foo Bar FooBar'
incompatible_parallel_workflows: 'CI'
runs-on: ubuntu-latest
outputs:
runs: ${{ steps.get-runs_in_progress.outputs.runs }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Python ${{ env.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ env.python-version }}
- name: Wait for Github API to register this as a running workflow
run: sleep 10s
shell: bash
- name: Checking no other incompatible workflow is running
id: runs_in_progress
run: |
bash .github/scripts/get_in_progress_ci.sh ${{ env.incompatible_parallel_workflows }}
- name: Assert that this is the only running CI
uses: nick-fields/assert-action@v1
with:
expected: false
actual: ${{ steps.runs_in_progress.outputs.is_banned_running }}
cleanup_test_account:
needs: check_runs
name: Cleanup test account
runs-on: ubuntu-latest
env:
IONOS_USERNAME: ${{ secrets.IONOS_USER_V6 }}
IONOS_PASSWORD: ${{ secrets.IONOS_PASSWORD_V6 }}
IONOS_TOKEN: ${{ secrets.IONOS_TOKEN_V6 }}
IONOSCTL_VERSION: 6.7.4
steps:
- name: Checking out module-ansible
uses: actions/checkout@v2
- name: Setup ionosctl
run: |
curl -sL https://github.com/ionos-cloud/ionosctl/releases/download/v${{ env.IONOSCTL_VERSION }}/ionosctl-${{ env.IONOSCTL_VERSION }}-linux-amd64.tar.gz | tar -xzv > /dev/null
mv ionosctl /usr/local/bin
# Temporarily skipped
# - name: Perform cleanup
# working-directory: /home/runner/work/module-ansible/module-ansible/.github/scripts/cleanup
# run: |
# ./delete-all-resources.sh &> output.log || true
# cat output.log
# Upload the output as an artifact
- name: Create an artifact with the output logs file
uses: actions/upload-artifact@v2
if: always()
with:
name: cleanup.log
path: |
/home/runner/work/module-ansible/module-ansible/.github/cleanup/scripts/cleanup/output.log
test:
needs: cleanup_test_account
name: Testing the ${{ matrix.namespace }} modules
strategy:
matrix:
include:
- namespace: applicationloadbalancer
keywords: "application_load_balancer, target_group, application-load-balancer, target-group"
- namespace: user-management
keywords: "user, group, s3key, share"
- namespace: managed-backup
keywords: "backupunit"
- namespace: compute-engine
keywords: "datacenter, server, firewall, volume, image, cube, lan, nic, pcc, snapshot, ipblock"
- namespace: dbaas-postgres
keywords: "postgres"
- namespace: dbaas-mongo
keywords: "mongo"
- namespace: managed-kubernetes
keywords: "k8s, k8s-cluster-nodepool, k8s_nodepool"
- namespace: dbaas-mariadb
keywords: "mariadb"
- namespace: natgateway
keywords: "nat"
- namespace: networkloadbalancer
keywords: "network_load_balancer, network"
- namespace: certificate
keywords: "certificate"
- namespace: container-registry
keywords: "registry"
- namespace: dataplatform
keywords: "data_platform, dataplatform"
- namespace: logging
keywords: "pipeline"
- namespace: dns
keywords: "dns, dns_zone, dns_record"
- namespace: vm-autoscaling
keywords: "autoscaling"
env:
python-version: 3.8.15
ANSIBLE_LIBRARY: /home/runner/work/module-ansible/module-ansible/plugins/modules
IONOS_USERNAME: ${{ secrets.IONOS_USER_V6 }}
IONOS_PASSWORD: ${{ secrets.IONOS_PASSWORD_V6 }}
IONOS_TOKEN: ${{ secrets.IONOS_TOKEN_V6 }}
# The type of runner that the job will run on
runs-on: ubuntu-latest
outputs:
python-version: ${{ env.python-version }}
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Python ${{ env.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ env.python-version }}
- name: Setup pip, virtualenv, ionoscloud
run: |
python3 -m pip install --upgrade pip
python3 -m pip install pydantic
python3 -m pip install ionoscloud
python3 -m pip install ionoscloud-cert-manager
python3 -m pip install ionoscloud-dns
python3 -m pip install ionoscloud-dbaas-postgres
python3 -m pip install ionoscloud-dbaas-mongo
python3 -m pip install ionoscloud-dbaas-mariadb
python3 -m pip install ionoscloud-container-registry
python3 -m pip install ionoscloud-dataplatform
python3 -m pip install ionoscloud-logging
python3 -m pip install ionoscloud-vm-autoscaling
- name: Install Ansible and IONOS module
run: |
python3 -m pip install ansible
ansible-galaxy collection build /home/runner/work/module-ansible/module-ansible/
ansible-galaxy collection install ionoscloudsdk-ionoscloud-$(grep version: galaxy.yml | cut -c10-).tar.gz --force
rm ionoscloudsdk-ionoscloud-$(grep version: galaxy.yml | cut -c10-).tar.gz
- name: Debug pip packages
run: |
python3 -m pip list
- id: files
name: Get changed files
uses: jitterbit/get-changed-files@v1
if: github.event_name == 'pull_request'
- name: Run ${{ matrix.namespace }} tests with files diff check
run: |
if [[ $(bash .github/scripts/check_keywords.sh "${{ matrix.keywords }}" ${{ steps.files.outputs.all }}) == true ]]; then
echo "Changed files in ${{ matrix.namespace }}."
ansible-playbook /home/runner/work/module-ansible/module-ansible/tests/${{ matrix.namespace }}/all-tests.yml -vvv
else
echo "no changed ${{ matrix.namespace }} files!"
fi
if: github.event_name == 'pull_request'
- name: Run ${{ matrix.namespace }} tests
run: |
ansible-playbook /home/runner/work/module-ansible/module-ansible/tests/${{ matrix.namespace }}/all-tests.yml
if: github.event_name == 'workflow_dispatch'