-
Notifications
You must be signed in to change notification settings - Fork 74
224 lines (206 loc) · 7.76 KB
/
auto-diff-k8s-ci.yaml
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
name: Nightly K8s Matrix
permissions: write-all
env:
CLUSTER_NAME: spider
E2E_TIME_OUT: 60m
PR_LABEL: pr/dependabot/github-actions, release/none
PR_REVIWER: weizhoublue, ty-dc
# The range of K8s versions that matrix tests expect to run. All distributions larger than it will be picked to run.
MINIMUM_K8S_VERSION: v1.21
K8S_MATRIX_FILE_PATH: .github/workflows/auto-diff-k8s-ci.yaml
on:
schedule:
- cron: "0 20 * * *"
workflow_dispatch:
inputs:
ref:
description: 'sha, tag, branch'
required: true
default: main
k8s_version:
description: 'It should be the released version, for example: v1.25.2; if not set, the default version set will be run.'
required: false
type: string
e2e_enabled:
description: 'run e2e test'
required: false
type: choice
default: "false"
options:
- "true"
- "false"
e2e_labels:
description: 'e2e labels(if not set, ginkgo will run all test, multi labels separated by commas)'
required: false
type: string
jobs:
get_ref:
runs-on: ubuntu-latest
outputs:
ref: ${{ env.RUN_REF }}
run_push: ${{ env.RUN_PUSH }}
e2e_enabled: ${{ env.RUN_E2E_ENABLED }}
inputs_k8s_version: ${{ env.INPUTS_K8S_VERSION }}
default_k8s_version: ${{ env.DEFAULT_K8S_VERSION }}
steps:
- name: Get Ref
id: get_ref
run: |
if ${{ github.event_name == 'workflow_dispatch' }} ; then
echo "call by self workflow_dispatch"
echo "RUN_TAG=${{ github.event.inputs.ref }}" >> $GITHUB_ENV
if ${{ github.event.inputs.k8s_version == '' }}; then
echo "INPUTS_K8S_VERSION=false" >> $GITHUB_ENV
echo "DEFAULT_K8S_VERSION=true" >> $GITHUB_ENV
else
echo "A custom version of k8s will be run: ${{ github.event.inputs.k8s_version }} "
echo "INPUTS_K8S_VERSION=true" >> $GITHUB_ENV
echo "DEFAULT_K8S_VERSION=false" >> $GITHUB_ENV
fi
if ${{ github.event.inputs.e2e_enabled == 'true' }}; then
echo "RUN_E2E_ENABLED=true" >> $GITHUB_ENV
else
echo "RUN_E2E_ENABLED=false" >> $GITHUB_ENV
fi
else
# schedule event
# use main sha for ci image tag
echo "trigger by schedule"
echo "RUN_TAG=main" >> $GITHUB_ENV
echo "RUN_PUSH=false" >> $GITHUB_ENV
echo "RUN_E2E_ENABLED=true" >> $GITHUB_ENV
echo "INPUTS_K8S_VERSION=false" >> $GITHUB_ENV
echo "DEFAULT_K8S_VERSION=true" >> $GITHUB_ENV
fi
# some event, the tag is not sha, so checkout it and get sha
- name: Checkout code
uses: actions/checkout@v4
with:
persist-credentials: false
ref: ${{ env.RUN_TAG }}
- name: Result Ref
id: result
run: |
ref=$( git show -s --format='format:%H')
echo "RUN_REF=${ref}" >> $GITHUB_ENV
call_build_ci_image:
needs: [get_ref]
uses: ./.github/workflows/build-image-ci.yaml
with:
ref: ${{ needs.get_ref.outputs.ref }}
push: false
secrets: inherit
lint_chart_against_release_image:
needs: get_ref
uses: ./.github/workflows/call-lint-chart.yaml
with:
ref: ${{ needs.get_ref.outputs.ref }}
secrets: inherit
call_release_chart:
needs: [get_ref]
uses: ./.github/workflows/call-release-chart.yaml
with:
ref: ${{ needs.get_ref.outputs.ref }}
submit: false
secrets: inherit
# update k8s matrix in step "call_k8s_matrix"
update_k8s_matrix:
needs: [get_ref]
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ needs.get_ref.outputs.ref }}
- name: get latest kind node version
run: |
bash ./test/scripts/update-kindnode-version.sh ${{ env.MINIMUM_K8S_VERSION }} ${{ env.K8S_MATRIX_FILE_PATH }}
if [ $? -ne 0 ]; then
echo "./test/scripts/update-kindnode-version.sh script failed"
echo "SKIP_CREATE_PR=true" >> $GITHUB_ENV
exit 0
fi
git_status=$(git status --porcelain)
echo "git status: ${git_status}"
if [[ -n "$git_status" ]]; then
echo "SKIP_CREATE_PR=false" >> $GITHUB_ENV
echo "The .github/workflows/auto-diff-k8s-ci.yaml of Spiderpool has changed."
else
echo "The .github/workflows/auto-diff-k8s-ci.yaml of Spiderpool has not changed."
echo "SKIP_CREATE_PR=true" >> $GITHUB_ENV
fi
- uses: crazy-max/ghaction-import-gpg@v6
if: ${{ env.SKIP_CREATE_PR != 'true' }}
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
git_user_signingkey: true
git_commit_gpgsign: true
# Allow auto-merge on general
- name: Create Pull Request
if: ${{ env.SKIP_CREATE_PR != 'true' }}
id: create_pr
uses: peter-evans/create-pull-request@v6.1.0
with:
title: "robot updates kind node version in k8s matrix test"
commit-message: "robot updates kind node version in k8s matrix test"
branch-suffix: timestamp
committer: ty-dc <tao.yang@daocloud.io>
branch: robot/update_doc
delete-branch: true
signoff: true
base: main
token: ${{ secrets.WELAN_PAT }}
labels: ${{ env.PR_LABEL }}
reviewers: ${{ env.PR_REVIWER }}
call_k8s_matrix:
# k8s versions
strategy:
fail-fast: false
matrix:
# Synchronise with the latest releases of each version
# If a new version of kind/node is released, it will be updated automatically.
version: [v1.28.13, v1.29.8, v1.30.4, v1.27.16, v1.26.15, v1.25.16, v1.31.0, v1.23.17, v1.24.17, v1.22.17]
needs: [call_build_ci_image, get_ref, call_release_chart]
uses: ./.github/workflows/e2e-init.yaml
with:
ip_family: dual
image_tag: ${{ needs.call_build_ci_image.outputs.imageTag }}
ref: ${{ needs.get_ref.outputs.ref }}
k8s_version: ${{ matrix.version }}
run_e2e: ${{ needs.get_ref.outputs.e2e_enabled }}
e2e_labels: ${{ inputs.e2e_labels }}
secrets: inherit
creat_issue:
runs-on: ubuntu-latest
needs: [call_k8s_matrix, lint_chart_against_release_image]
if: ${{ always() && needs.call_k8s_matrix.result == 'failure' || needs.lint_chart_against_release_image.result == 'failure' }}
steps:
- name: echo
run: |
echo ${{ github.repository }}
echo ${{ github.repository_owner }}
echo "TIMESTAMP=`date +%Y-%m-%d`" >> $GITHUB_ENV
- name: create an issue
uses: dacbd/create-issue-action@v2.0.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
title: "Nightly K8s Matrix CI ${{ ENV.TIMESTAMP }}: Failed"
body: |
action url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
labels: "kind/ci-bug"
assignees: "ty-dc"
call_inputs_k8s:
# workflow_dispatch event flow triggered by running the input k8s version
needs: [call_build_ci_image, get_ref, call_release_chart]
if: ${{ needs.get_ref.outputs.default_k8s_version == 'false' && needs.get_ref.outputs.inputs_k8s_version == 'true' }}
uses: ./.github/workflows/e2e-init.yaml
with:
ip_family: dual
image_tag: ${{ needs.call_build_ci_image.outputs.imageTag }}
ref: ${{ needs.get_ref.outputs.ref }}
k8s_version: ${{ inputs.k8s_version }}
run_e2e: ${{ needs.get_ref.outputs.e2e_enabled }}
e2e_labels: ${{ inputs.e2e_labels }}
secrets: inherit