forked from apecloud/apecloud-cd
-
Notifications
You must be signed in to change notification settings - Fork 0
238 lines (216 loc) · 8.42 KB
/
cloud-test-k8s.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
name: Cloud E2E Test on K8S
on:
workflow_call:
inputs:
CLOUD_VERSION:
description: 'KubeBlocks Cloud release version'
type: string
required: false
default: 'v0.19.0'
CLOUD_PROVIDER:
description: 'cloud k8s cluster provider (e.g. aks/aks-cn)'
type: string
required: false
default: 'aks-cn'
REGION:
description: 'k8s region name'
type: string
required: false
default: 'eastus'
CLUSTER_VERSION:
description: 'k8s cluster version (e.g. 1.27)'
type: string
required: false
default: '1.27'
E2ETEST_BRANCH:
description: 'e2etest branch name'
type: string
required: false
default: 'main'
APECD_REF:
description: "The branch name of apecloud-cd"
type: string
required: false
default: 'main'
ARGS:
description: "Test args"
type: string
required: false
default: ''
workflow_dispatch:
inputs:
CLOUD_VERSION:
description: 'Cloud release version'
type: string
required: false
default: 'v0.19.0'
CLOUD_PROVIDER:
description: 'cloud k8s cluster provider'
required: true
default: 'aks'
type: choice
options:
- aks
REGION:
description: 'k8s region name'
required: false
default: 'eastus'
type: choice
options:
- eastus
CLUSTER_VERSION:
description: 'k8s cluster version (e.g. 1.27)'
type: string
required: false
default: '1.27'
E2ETEST_BRANCH:
description: 'e2etest branch name'
type: string
required: false
default: 'main'
APECD_REF:
description: "The branch name of apecloud-cd"
type: string
required: false
default: 'main'
ARGS:
description: "Test args"
type: string
required: false
default: ''
TEST_TYPE:
description: 'test type (e.g. apecloud-mysql|postgresql|redis|mongodb)'
type: string
required: false
default: ''
run-name: Cloud:${{ inputs.CLOUD_VERSION }} Test On K8S:${{ inputs.CLOUD_PROVIDER }} ${{ inputs.CLUSTER_VERSION }}
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
permissions:
id-token: write
contents: read
jobs:
terraform-init-k8s:
uses: ./.github/workflows/terraform-init.yml
with:
cloud-provider: ${{ inputs.CLOUD_PROVIDER }}
cluster-version: ${{ inputs.CLUSTER_VERSION }}
artifact-name: cicd-${{ inputs.CLOUD_PROVIDER }}-${{ github.sha }}
region: ${{ inputs.REGION }}
test-mode: "cloude2etest"
test-type: ${{ inputs.TEST_TYPE }}
secrets: inherit
creat-cloud-env:
needs: [ terraform-init-k8s ]
uses: ./.github/workflows/test-cloud-k8s.yml
with:
cloud-provider: ${{ inputs.CLOUD_PROVIDER }}
k8s-cluster-name: ${{ needs.terraform-init-k8s.outputs.k8s-cluster-name }}
test-type-name: ${{ inputs.TEST_TYPE }}
test-args: ${{ inputs.ARGS }}
e2etest-branch: ${{ inputs.E2ETEST_BRANCH }}
env-init: true
secrets: inherit
test-apecloud-mysql:
if: ${{ needs.terraform-init-k8s.result == 'success' && always() && (inputs.TEST_TYPE == '' || contains(inputs.TEST_TYPE, 'apecloud-mysql|') || endsWith(inputs.TEST_TYPE, 'apecloud-mysql')) && ! contains(inputs.TEST_TYPE, '-apecloud-mysql') }}
needs: [ terraform-init-k8s, creat-cloud-env ]
uses: ./.github/workflows/test-cloud-k8s.yml
with:
cloud-provider: ${{ inputs.CLOUD_PROVIDER }}
k8s-cluster-name: ${{ needs.terraform-init-k8s.outputs.k8s-cluster-name }}
test-type-name: "apecloud-mysql"
test-args: ${{ inputs.ARGS }}
e2etest-branch: ${{ inputs.E2ETEST_BRANCH }}
secrets: inherit
test-postgresql:
if: ${{ needs.terraform-init-k8s.result == 'success' && always() && (inputs.TEST_TYPE == '' || contains(inputs.TEST_TYPE, 'postgresql|') || endsWith(inputs.TEST_TYPE, 'postgresql')) && ! contains(inputs.TEST_TYPE, '-postgresql') }}
needs: [ terraform-init-k8s, creat-cloud-env ]
uses: ./.github/workflows/test-cloud-k8s.yml
with:
cloud-provider: ${{ inputs.CLOUD_PROVIDER }}
k8s-cluster-name: ${{ needs.terraform-init-k8s.outputs.k8s-cluster-name }}
test-type-name: "postgresql"
test-args: ${{ inputs.ARGS }}
e2etest-branch: ${{ inputs.E2ETEST_BRANCH }}
secrets: inherit
test-redis:
if: ${{ needs.terraform-init-k8s.result == 'success' && always() && (inputs.TEST_TYPE == '' || contains(inputs.TEST_TYPE, 'redis|') || endsWith(inputs.TEST_TYPE, 'redis')) }}
needs: [ terraform-init-k8s, creat-cloud-env ]
uses: ./.github/workflows/test-cloud-k8s.yml
with:
cloud-provider: ${{ inputs.CLOUD_PROVIDER }}
k8s-cluster-name: ${{ needs.terraform-init-k8s.outputs.k8s-cluster-name }}
test-type-name: "redis"
test-args: ${{ inputs.ARGS }}
e2etest-branch: ${{ inputs.E2ETEST_BRANCH }}
secrets: inherit
test-mongodb:
if: ${{ needs.terraform-init-k8s.result == 'success' && always() && (inputs.TEST_TYPE == '' || contains(inputs.TEST_TYPE, 'mongodb')) }}
needs: [ terraform-init-k8s, creat-cloud-env ]
uses: ./.github/workflows/test-cloud-k8s.yml
with:
cloud-provider: ${{ inputs.CLOUD_PROVIDER }}
k8s-cluster-name: ${{ needs.terraform-init-k8s.outputs.k8s-cluster-name }}
test-type-name: "mongodb"
test-args: ${{ inputs.ARGS }}
e2etest-branch: ${{ inputs.E2ETEST_BRANCH }}
secrets: inherit
send-message:
if: ${{ always() }}
runs-on: ubuntu-latest
needs: [ test-apecloud-mysql, test-postgresql, test-redis, test-mongodb ]
steps:
- uses: actions/checkout@v4
with:
repository: apecloud/apecloud-cd
path: ./
ref: ${{ inputs.APECD_REF }}
- name: send message
id: get_trigger_mode
run: |
TEST_RESULT=""
if [[ "${{ inputs.TEST_TYPE }}" == '' || "${{ inputs.TEST_TYPE }}" == *"apecloud-mysql"* ]]; then
TEST_RESULT="${TEST_RESULT}##apecloud-mysql|${{ needs.test-apecloud-mysql.outputs.test-result }}"
fi
if [[ "${{ inputs.TEST_TYPE }}" == '' || (("${{ inputs.TEST_TYPE }}" == *"postgresql|"* || "${{ inputs.TEST_TYPE }}" == *"postgresql") && "${{ inputs.TEST_TYPE }}" != *"-postgresql"* ) ]]; then
TEST_RESULT="${TEST_RESULT}##postgresql|${{ needs.test-postgresql.outputs.test-result }}"
fi
if [[ "${{ inputs.TEST_TYPE }}" == '' || "${{ inputs.TEST_TYPE }}" == *"redis|"* || "${{ inputs.TEST_TYPE }}" == *"redis" ]]; then
TEST_RESULT="${TEST_RESULT}##redis|${{ needs.test-redis.outputs.test-result }}"
fi
if [[ "${{ inputs.TEST_TYPE }}" == '' || "${{ inputs.TEST_TYPE }}" == *"mongodb"* ]]; then
TEST_RESULT="${TEST_RESULT}##mongodb|${{ needs.test-mongodb.outputs.test-result }}"
fi
TEST_RESULT=$( bash .github/utils/utils.sh --type 12 \
--github-repo "${{ github.repository }}" \
--github-token "${{ env.GITHUB_TOKEN }}" \
--test-result "${TEST_RESULT}" \
--run-id "$GITHUB_RUN_ID" )
echo "$TEST_RESULT"
date_ret=$(date +%Y-%m-%d-%T)
test_title="[${{ inputs.CLOUD_VERSION }}] Test Cloud on K8S:${{ inputs.CLOUD_PROVIDER }} ${{ inputs.CLUSTER_VERSION }} [${date_ret}]"
python3 .github/utils/send_mesage.py \
--url ${{ vars.TEST_BOT_WEBHOOK }} \
--title "$test_title" \
--result "$TEST_RESULT"
delete-cloud-env:
if: ${{ always() }}
needs: [ terraform-init-k8s, send-message ]
uses: ./.github/workflows/test-cloud-k8s.yml
with:
cloud-provider: ${{ inputs.CLOUD_PROVIDER }}
k8s-cluster-name: ${{ needs.terraform-init-k8s.outputs.k8s-cluster-name }}
test-type-name: ${{ inputs.TEST_TYPE }}
test-args: ${{ inputs.ARGS }}
e2etest-branch: ${{ inputs.E2ETEST_BRANCH }}
env-clean: true
secrets: inherit
terraform-destroy-k8s:
if: ${{ always() }}
needs: [ terraform-init-k8s, send-message ]
uses: ./.github/workflows/terraform-destroy.yml
with:
cloud-provider: ${{ inputs.CLOUD_PROVIDER }}
artifact-name: cicd-${{ inputs.CLOUD_PROVIDER }}-${{ github.sha }}
region: ${{ inputs.REGION }}
secrets: inherit