-
Notifications
You must be signed in to change notification settings - Fork 14
289 lines (255 loc) · 8.89 KB
/
cicd-push.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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
name: CICD-PUSH
on:
push:
branches:
- '*'
- '*/*'
tags-ignore:
- '*'
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
BASE_BRANCH: origin/main
GO_VERSION: "1.21"
jobs:
trigger-mode:
runs-on: ubuntu-latest
outputs:
trigger-mode: ${{ steps.get_trigger_mode.outputs.trigger_mode }}
base-commitid: ${{ steps.get_trigger_mode.outputs.base_commitid }}
steps:
- name: Cancel Previous Runs
if: github.ref_name != 'main'
uses: styfle/cancel-workflow-action@0.11.0
with:
all_but_latest: true
access_token: ${{ github.token }}
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get trigger mode
id: get_trigger_mode
run: |
TRIGGER_MODE=`bash .github/utils/utils.sh --type 6 \
--branch-name "${{ github.ref_name }}" \
--base-branch "${{ env.BASE_BRANCH }}"`
BASE_COMMITID=`bash .github/utils/utils.sh --type 19 \
--branch-name "${{ github.ref_name }}" \
--base-branch "${{ env.BASE_BRANCH }}"`
echo "TRIGGER_MODE:$TRIGGER_MODE"
echo "BASE_COMMITID:$BASE_COMMITID"
echo trigger_mode=$TRIGGER_MODE >> $GITHUB_OUTPUT
echo base_commitid=$BASE_COMMITID >> $GITHUB_OUTPUT
- name: merge releasing to release
if: ${{ startsWith(github.ref_name, 'releasing-') }}
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
bash .github/utils/merge_releasing_branch.sh
pre-push:
needs: trigger-mode
runs-on: ubuntu-latest
name: Push Pre-Check
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: install pcregrep
run: |
sudo apt-get update
sudo apt-get install pcregrep
- name: gen pcregrep
run: |
pcregrep --exclude-dir=mtr -r -n -I '[^\x00-\x7f]' . > pcregrep.out
- name: pcregrep Chinese
run: |
FILE_PATH=`git diff --name-only HEAD ${{ needs.trigger-mode.outputs.base-commitid }}`
echo "FILE_PATH: $FILE_PATH"
python ${{ github.workspace }}/.github/utils/pcregrep.py \
--source="${{ github.workspace }}/pcregrep.out" \
--filter="$FILE_PATH"
- name: Spell Check with Typos
if: contains(needs.trigger-mode.outputs.trigger-mode, '[docs]')
uses: crate-ci/typos@v1.13.14
with:
files: docs/
config: .github/utils/typos.toml
cli-doc:
needs: trigger-mode
runs-on: ubuntu-latest
if: ${{ contains(needs.trigger-mode.outputs.trigger-mode, '[cli]') }}
steps:
- uses: actions/checkout@v3
- name: install lib
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
libbtrfs-dev \
libdevmapper-dev
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: "${{ env.GO_VERSION }}"
- name: Check cli doc
id: check-cli-doc
run: |
make kbcli-doc
FILE_CHANGES=`git diff --name-only ${{ github.sha }}`
if [[ ! -z "$FILE_CHANGES" ]]; then
echo $FILE_CHANGES
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com"
git commit -a -m "chore: auto update cli doc changes"
fi
echo file_changes=$FILE_CHANGES >> $GITHUB_OUTPUT
- name: Push cli doc changes
uses: ad-m/github-push-action@master
if: ${{ steps.check-cli-doc.outputs.file_changes }}
with:
github_token: ${{ env.GITHUB_TOKEN }}
branch: ${{ github.ref }}
make-test:
needs: trigger-mode
runs-on: [self-hosted, gke-runner-go1.21]
if: contains(needs.trigger-mode.outputs.trigger-mode, '[test]')
outputs:
runner-name: ${{ steps.get_runner_name.outputs.runner_name }}
steps:
- uses: actions/checkout@v3
- name: make manifests check
run: |
make manifests
FILE_CHANGES=`git diff --name-only ${{ github.sha }}`
if [[ ! -z "$FILE_CHANGES" ]]; then
echo $FILE_CHANGES
echo "make manifests causes inconsistent files"
exit 1
fi
- name: make mod-vendor
run: |
make mod-vendor
- name: make lint
run: |
make lint
- name: make test
run: |
make test
- name: ignore cover pkgs
run: |
bash .github/utils/utils.sh --type 14 \
--file cover.out \
--ignore-pkgs "cmd/|internal/cli|internal/controller/consensusset|internal/controller/model|controllers/k8score"
- name: upload coverage report
uses: codecov/codecov-action@v3
continue-on-error: true
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./cover_new.out
flags: unittests
name: codecov-report
verbose: true
- name: kill kube-apiserver and etcd
id: get_runner_name
if: ${{ always() }}
run: |
echo runner_name=${RUNNER_NAME} >> $GITHUB_OUTPUT
bash .github/utils/utils.sh --type 8
remove-runner:
needs: [ trigger-mode, make-test ]
runs-on: ubuntu-latest
if: ${{ contains(needs.trigger-mode.outputs.trigger-mode, '[test]') && always() }}
steps:
- uses: actions/checkout@v3
- name: remove runner
run: |
bash .github/utils/utils.sh --type 9 \
--github-token "${{ env.GITHUB_TOKEN }}" \
--runner-name ${{ needs.make-test.outputs.runner-name }}
check-image:
needs: trigger-mode
if: ${{ contains(needs.trigger-mode.outputs.trigger-mode, '[docker]') }}
uses: apecloud/apecloud-cd/.github/workflows/release-image-check.yml@v0.1.24
with:
MAKE_OPS_PRE: "generate"
IMG: "apecloud/kubeblocks"
GO_VERSION: "1.21"
BUILDX_PLATFORMS: "linux/amd64"
DOCKERFILE_PATH: "./docker/Dockerfile"
secrets: inherit
check-tools-image:
needs: trigger-mode
if: ${{ contains(needs.trigger-mode.outputs.trigger-mode, '[docker]') }}
uses: apecloud/apecloud-cd/.github/workflows/release-image-check.yml@v0.1.24
with:
MAKE_OPS_PRE: "module generate test-go-generate"
IMG: "apecloud/kubeblocks-tools"
GO_VERSION: "1.21"
BUILDX_PLATFORMS: "linux/amd64"
DOCKERFILE_PATH: "./docker/Dockerfile-tools"
secrets: inherit
check-datascript-image:
needs: trigger-mode
if: ${{ contains(needs.trigger-mode.outputs.trigger-mode, '[docker]') }}
uses: apecloud/apecloud-cd/.github/workflows/release-image-check.yml@v0.1.24
with:
IMG: "apecloud/kubeblocks-datascript"
BUILDX_PLATFORMS: "linux/amd64"
DOCKERFILE_PATH: "./docker/Dockerfile-datascript"
secrets: inherit
check-dataprotection-image:
needs: trigger-mode
if: ${{ contains(needs.trigger-mode.outputs.trigger-mode, '[docker]') }}
uses: apecloud/apecloud-cd/.github/workflows/release-image-check.yml@v0.1.24
with:
IMG: "apecloud/kubeblocks-dataprotection"
BUILDX_PLATFORMS: "linux/amd64"
DOCKERFILE_PATH: "./docker/Dockerfile-dataprotection"
secrets: inherit
check-helm:
needs: trigger-mode
if: ${{ contains(needs.trigger-mode.outputs.trigger-mode, '[deploy]') }}
uses: apecloud/apecloud-cd/.github/workflows/release-charts-check.yml@v0.1.24
with:
MAKE_OPS: "bump-chart-ver"
VERSION: "v0.7.0-check"
CHART_NAME: "kubeblocks"
CHART_DIR: "deploy/helm"
APECD_REF: "v0.1.24"
secrets: inherit
deploy-kubeblocks-io:
needs: trigger-mode
if: ${{ contains(needs.trigger-mode.outputs.trigger-mode, '[docs]') && (github.ref_name == 'main' || startsWith(github.ref_name, 'release')) }}
uses: apecloud/apecloud-cd/.github/workflows/trigger-workflow.yml@v0.1.0
with:
GITHUB_REPO: "apecloud/kubeblocks.io"
BRANCH_NAME: "master"
WORKFLOW_ID: "deploy.yml"
APECD_REF: "v0.1.0"
secrets: inherit
build-kbcli:
needs: trigger-mode
runs-on: ubuntu-latest
if: ${{ contains(needs.trigger-mode.outputs.trigger-mode, '[cli]') }}
strategy:
matrix:
os: [linux-amd64, darwin-arm64]
steps:
- uses: actions/checkout@v3
- name: install lib
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
libbtrfs-dev \
libdevmapper-dev \
libgpgme-dev
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: "${{ env.GO_VERSION }}"
- name: make generate
run: make generate
- name: build cli
run: |
CLI_OS_ARCH=`bash .github/utils/utils.sh \
--tag-name ${{ matrix.os }} \
--type 2`
make bin/kbcli.$CLI_OS_ARCH