forked from spidernet-io/spiderpool
-
Notifications
You must be signed in to change notification settings - Fork 0
162 lines (149 loc) · 5.33 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
name: Nightly K8s Matrix
permissions: write-all
env:
CLUSTER_NAME: spider
E2E_TIME_OUT: 60m
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@v3
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
call_k8s_matrix:
# k8s versions
strategy:
fail-fast: false
matrix:
# Synchronise with the latest releases of each version
version: [v1.22.7, v1.23.5, v1.24.4, v1.25.3, v1.26.2, v1.27.1]
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/[email protected]
with:
token: ${{ secrets.WELAN_PAT }}
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: "Icarus9913,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