forked from oracle-quickstart/oci-openshift
-
Notifications
You must be signed in to change notification settings - Fork 1
239 lines (213 loc) · 11.6 KB
/
smoke-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
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
name: Infrastructure Smoke Test
on:
schedule:
- cron: "20 5 */2 * *"
jobs:
smoke-test-vm:
runs-on: ubuntu-latest
name: Create VM cluster infrastructure
env:
OCI_CLI_USER: ${{ secrets.OCI_CLI_USER }}
OCI_CLI_TENANCY: ${{ secrets.OCI_CLI_TENANCY }}
OCI_CLI_FINGERPRINT: ${{ secrets.OCI_CLI_FINGERPRINT }}
OCI_CLI_KEY_CONTENT: ${{ secrets.OCI_CLI_KEY_CONTENT }}
OCI_CLI_REGION: ${{ secrets.OCI_CLI_REGION }}
OPENSHIFT_IMAGE_SOURCE_URI: ${{ secrets.OPENSHIFT_IMAGE_SOURCE_URI }}
COMPARTMENT_OCID: ${{ secrets.COMPARTMENT_OCID }}
ZONE_DNS_SUFFIX: ${{ secrets.ZONE_DNS_SUFFIX }}
CLUSTER_NAME: smoke-test-vm
outputs:
stack_id: ${{ steps.output-stack-id.outputs.stack_id }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set NOW env variable
run: echo "NOW=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_ENV
- name: Create Terraform ZIP
run: |
if [ -f infrastructure.tf ]; then
zip infrastructure.zip infrastructure.tf
elif [ -d infrastructure ]; then
zip -j infrastructure.zip infrastructure/data.tf infrastructure/locals.tf infrastructure/main.tf infrastructure/output.tf infrastructure/schema.yaml infrastructure/variables.tf
else
echo "Could not find infrastructure.tf or infrastructure directory"
exit 1
fi
- name: Create RMS Stack
uses: oracle-actions/[email protected]
id: create-stack
with:
command: 'resource-manager stack create --compartment-id ${{ env.COMPARTMENT_OCID }} --display-name ${{ github.job }}-${{ env.NOW }} --config-source infrastructure.zip --variables "{\"compartment_ocid\": \"${{ env.COMPARTMENT_OCID }}\", \"cluster_name\": \"${{ env.CLUSTER_NAME }}-${{ env.NOW }}\", \"openshift_image_source_uri\": \"${{ env.OPENSHIFT_IMAGE_SOURCE_URI }}\", \"region\": \"${{ env.OCI_CLI_REGION }}\", \"tenancy_ocid\": \"${{ env.OCI_CLI_TENANCY }}\", \"zone_dns\": \"${{ env.CLUSTER_NAME }}-${{ env.NOW }}${{ env.ZONE_DNS_SUFFIX }}\"}"'
query: 'data.id'
- name: Output Stack ID
id: output-stack-id
env:
stack_id: ${{ steps.create-stack.outputs.raw_output }}
run: |
echo "stack_id=$(echo $stack_id | tr -d '"')" >> $GITHUB_OUTPUT
- name: RMS Stack Plan Job
uses: oracle-actions/[email protected]
id: stack-plan-job
with:
command: 'resource-manager job create-plan-job --wait-for-state SUCCEEDED --stack-id ${{ steps.create-stack.outputs.raw_output }}'
- name: RMS Stack Apply Job
uses: oracle-actions/[email protected]
id: stack-apply-job
with:
command: 'resource-manager job create-apply-job --wait-for-state SUCCEEDED --max-wait-seconds 1800 --execution-plan-strategy AUTO_APPROVED --stack-id ${{ steps.create-stack.outputs.raw_output }}'
smoke-test-bm:
runs-on: ubuntu-latest
name: Create BM cluster infrastructure
env:
OCI_CLI_USER: ${{ secrets.OCI_CLI_USER }}
OCI_CLI_TENANCY: ${{ secrets.OCI_CLI_TENANCY }}
OCI_CLI_FINGERPRINT: ${{ secrets.OCI_CLI_FINGERPRINT }}
OCI_CLI_KEY_CONTENT: ${{ secrets.OCI_CLI_KEY_CONTENT }}
OCI_CLI_REGION: ${{ secrets.OCI_CLI_REGION }}
OPENSHIFT_IMAGE_SOURCE_URI: ${{ secrets.OPENSHIFT_IMAGE_SOURCE_URI }}
COMPARTMENT_OCID: ${{ secrets.COMPARTMENT_OCID }}
ZONE_DNS_SUFFIX: ${{ secrets.ZONE_DNS_SUFFIX }}
CLUSTER_NAME: smoke-test-bm
outputs:
stack_id: ${{ steps.output-stack-id.outputs.stack_id }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set NOW env variable
run: echo "NOW=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_ENV
- name: Create Terraform ZIP
run: |
if [ -f infrastructure.tf ]; then
zip infrastructure.zip infrastructure.tf
elif [ -d infrastructure ]; then
zip -j infrastructure.zip infrastructure/data.tf infrastructure/locals.tf infrastructure/main.tf infrastructure/output.tf infrastructure/schema.yaml infrastructure/variables.tf
else
echo "Could not find infrastructure.tf or infrastructure directory"
exit 1
fi
- name: Create RMS Stack
uses: oracle-actions/[email protected]
id: create-stack
with:
command: 'resource-manager stack create --compartment-id ${{ env.COMPARTMENT_OCID }} --display-name ${{ github.job }}-${{ env.NOW }} --config-source infrastructure.zip --variables "{\"compartment_ocid\": \"${{ env.COMPARTMENT_OCID }}\", \"cluster_name\": \"${{ env.CLUSTER_NAME }}-${{ env.NOW }}\", \"control_plane_shape\": \"BM.Standard3.64\", \"control_plane_ocpu\": \"64\", \"control_plane_memory\": \"1024\", \"compute_shape\": \"BM.Standard3.64\", \"compute_ocpu\": \"64\", \"compute_memory\": \"1024\", \"openshift_image_source_uri\": \"${{ env.OPENSHIFT_IMAGE_SOURCE_URI }}\", \"region\": \"${{ env.OCI_CLI_REGION }}\", \"tenancy_ocid\": \"${{ env.OCI_CLI_TENANCY }}\", \"zone_dns\": \"${{ env.CLUSTER_NAME }}-${{ env.NOW }}${{ env.ZONE_DNS_SUFFIX }}\"}"'
query: 'data.id'
- name: Output Stack ID
id: output-stack-id
env:
stack_id: ${{ steps.create-stack.outputs.raw_output }}
run: |
echo "stack_id=$(echo $stack_id | tr -d '"')" >> $GITHUB_OUTPUT
- name: RMS Stack Plan Job
uses: oracle-actions/[email protected]
id: stack-plan-job
with:
command: 'resource-manager job create-plan-job --wait-for-state SUCCEEDED --stack-id ${{ steps.create-stack.outputs.raw_output }}'
- name: RMS Stack Apply Job
uses: oracle-actions/[email protected]
id: stack-apply-job
with:
command: 'resource-manager job create-apply-job --wait-for-state SUCCEEDED --max-wait-seconds 1800 --execution-plan-strategy AUTO_APPROVED --stack-id ${{ steps.create-stack.outputs.raw_output }}'
smoke-test-vm-multi-ad:
runs-on: ubuntu-latest
name: Create VM cluster infrastructure in multi-ad region
env:
OCI_CLI_USER: ${{ secrets.OCI_CLI_USER }}
OCI_CLI_TENANCY: ${{ secrets.OCI_CLI_TENANCY }}
OCI_CLI_FINGERPRINT: ${{ secrets.OCI_CLI_FINGERPRINT }}
OCI_CLI_KEY_CONTENT: ${{ secrets.OCI_CLI_KEY_CONTENT }}
OCI_CLI_REGION: ${{ secrets.OCI_CLI_REGION }}
OPENSHIFT_IMAGE_SOURCE_URI: ${{ secrets.OPENSHIFT_IMAGE_SOURCE_URI }}
COMPARTMENT_OCID: ${{ secrets.COMPARTMENT_OCID }}
ZONE_DNS_SUFFIX: ${{ secrets.ZONE_DNS_SUFFIX }}
CLUSTER_NAME: smoke-test-vm-multi-ad
MUTLI_AD_REGION: eu-frankfurt-1
outputs:
stack_id: ${{ steps.output-stack-id.outputs.stack_id }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set NOW env variable
run: echo "NOW=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_ENV
- name: Create Terraform ZIP
run: |
if [ -f infrastructure.tf ]; then
zip infrastructure.zip infrastructure.tf
elif [ -d infrastructure ]; then
zip -j infrastructure.zip infrastructure/data.tf infrastructure/locals.tf infrastructure/main.tf infrastructure/output.tf infrastructure/schema.yaml infrastructure/variables.tf
else
echo "Could not find infrastructure.tf or infrastructure directory"
exit 1
fi
- name: Create RMS Stack
uses: oracle-actions/[email protected]
id: create-stack
with:
command: 'resource-manager stack create --compartment-id ${{ env.COMPARTMENT_OCID }} --display-name ${{ github.job }}-${{ env.NOW }} --config-source infrastructure.zip --variables "{\"compartment_ocid\": \"${{ env.COMPARTMENT_OCID }}\", \"cluster_name\": \"${{ env.CLUSTER_NAME }}-${{ env.NOW }}\", \"openshift_image_source_uri\": \"${{ env.OPENSHIFT_IMAGE_SOURCE_URI }}\", \"region\": \"${{ env.MUTLI_AD_REGION }}\", \"tenancy_ocid\": \"${{ env.OCI_CLI_TENANCY }}\", \"zone_dns\": \"${{ env.CLUSTER_NAME }}-${{ env.NOW }}${{ env.ZONE_DNS_SUFFIX }}\"}"'
query: 'data.id'
- name: Output Stack ID
id: output-stack-id
env:
stack_id: ${{ steps.create-stack.outputs.raw_output }}
run: |
echo "stack_id=$(echo $stack_id | tr -d '"')" >> $GITHUB_OUTPUT
- name: RMS Stack Plan Job
uses: oracle-actions/[email protected]
id: stack-plan-job
with:
command: 'resource-manager job create-plan-job --wait-for-state SUCCEEDED --stack-id ${{ steps.create-stack.outputs.raw_output }}'
- name: RMS Stack Apply Job
uses: oracle-actions/[email protected]
id: stack-apply-job
with:
command: 'resource-manager job create-apply-job --wait-for-state SUCCEEDED --max-wait-seconds 1800 --execution-plan-strategy AUTO_APPROVED --stack-id ${{ steps.create-stack.outputs.raw_output }}'
teardown-stacks:
if: ${{ !cancelled() }}
needs: [smoke-test-vm, smoke-test-bm, smoke-test-vm-multi-ad]
runs-on: ubuntu-latest
name: Teardown cluster infrastructure
env:
OCI_CLI_USER: ${{ secrets.OCI_CLI_USER }}
OCI_CLI_TENANCY: ${{ secrets.OCI_CLI_TENANCY }}
OCI_CLI_FINGERPRINT: ${{ secrets.OCI_CLI_FINGERPRINT }}
OCI_CLI_KEY_CONTENT: ${{ secrets.OCI_CLI_KEY_CONTENT }}
OCI_CLI_REGION: ${{ secrets.OCI_CLI_REGION }}
steps:
- name: Teardown VM Infrastructure
if: ${{ needs.smoke-test-vm.result == 'success' }}
uses: oracle-actions/[email protected]
id: teardown-vm-infra
with:
command: 'resource-manager job create-destroy-job --wait-for-state SUCCEEDED --max-wait-seconds 1800 --execution-plan-strategy AUTO_APPROVED --stack-id ${{ needs.smoke-test-vm.outputs.stack_id }}'
- name: Teardown BM Infrastructure
if: ${{ needs.smoke-test-bm.result == 'success' }}
uses: oracle-actions/[email protected]
id: teardown-bm-infra
with:
command: 'resource-manager job create-destroy-job --wait-for-state SUCCEEDED --max-wait-seconds 1800 --execution-plan-strategy AUTO_APPROVED --stack-id ${{ needs.smoke-test-bm.outputs.stack_id }}'
- name: Teardown VM multi-ad Infrastructure
if: ${{ needs.smoke-test-vm-multi-ad.result == 'success' }}
uses: oracle-actions/[email protected]
id: teardown-vm-multi-ad-infra
with:
command: 'resource-manager job create-destroy-job --wait-for-state SUCCEEDED --max-wait-seconds 1800 --execution-plan-strategy AUTO_APPROVED --stack-id ${{ needs.smoke-test-vm-multi-ad.outputs.stack_id }}'
- name: Destroy VM RMS Stack
if: ${{ steps.teardown-vm-infra.outcome == 'success' }}
uses: oracle-actions/[email protected]
id: destroy-vm-stack
continue-on-error: true
with:
command: 'resource-manager stack delete --force --stack-id ${{ needs.smoke-test-vm.outputs.stack_id }}'
- name: Destroy BM RMS Stack
if: ${{ steps.teardown-bm-infra.outcome == 'success' }}
uses: oracle-actions/[email protected]
id: destroy-bm-stack
continue-on-error: true
with:
command: 'resource-manager stack delete --force --stack-id ${{ needs.smoke-test-bm.outputs.stack_id }}'
- name: Destroy VM multi-ad RMS Stack
if: ${{ steps.teardown-vm-multi-ad-infra.outcome == 'success' }}
uses: oracle-actions/[email protected]
id: destroy-vm-multi-ad-stack
continue-on-error: true
with:
command: 'resource-manager stack delete --force --stack-id ${{ needs.smoke-test-vm-multi-ad.outputs.stack_id }}'