forked from apache/doris
-
Notifications
You must be signed in to change notification settings - Fork 0
268 lines (246 loc) · 12.8 KB
/
comment-to-trigger-teamcity.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
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
name: Comment to trigger teamcity
on:
issue_comment:
types: [created, edited]
jobs:
check-comment-if-need-to-trigger-teamcity:
# This job only runs for pull request comments, and comment body contains 'run'
if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, 'run') }}
runs-on: ubuntu-latest
env:
COMMENT_BODY: ${{ github.event.comment.body }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: "Parse PR comment"
id: parse
run: |
COMMENT_BODY=$(echo "${COMMENT_BODY}" | xargs)
if [[ "${COMMENT_BODY}" == *'run buildall'* ||
"${COMMENT_BODY}" == *'run compile'* ||
"${COMMENT_BODY}" == *'run beut'* ||
"${COMMENT_BODY}" == *'run feut'* ||
"${COMMENT_BODY}" == *'run p0'* ||
"${COMMENT_BODY}" == *'run p1'* ||
"${COMMENT_BODY}" == *'run external'* ||
"${COMMENT_BODY}" == *'run pipelinex_p0'* ||
"${COMMENT_BODY}" == *'run clickbench'* ||
"${COMMENT_BODY}" == *'run arm'* ||
"${COMMENT_BODY}" == *'run tpch'* ]]; then
echo "comment_trigger=true" | tee -a "$GITHUB_OUTPUT"
else
echo "comment_trigger=false" | tee -a "$GITHUB_OUTPUT"
echo "find no keyword in comment body, skip this action."
exit
fi
PULL_REQUEST_NUM="$(echo "${{ github.event.issue.pull_request.url }}" | awk -F/ '{print $NF}')"
COMMIT_ID_FROM_TRIGGER="$(curl -s -H "Authorization:Bearer ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/pulls/${PULL_REQUEST_NUM}" | jq -r '.head.sha')"
TARGET_BRANCH="$(curl -s -H "Authorization:Bearer ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/pulls/${PULL_REQUEST_NUM}" | jq -r '.base.ref')"
echo "PULL_REQUEST_NUM=${PULL_REQUEST_NUM}" | tee -a "$GITHUB_OUTPUT"
echo "COMMIT_ID_FROM_TRIGGER=${COMMIT_ID_FROM_TRIGGER}" | tee -a "$GITHUB_OUTPUT"
echo "TARGET_BRANCH='${TARGET_BRANCH}'" | tee -a "$GITHUB_OUTPUT"
echo "COMMENT_BODY='${COMMENT_BODY}'" | tee -a "$GITHUB_OUTPUT"
reg="run (buildall|compile|p0|p1|feut|beut|external|clickbench|pipelinex_p0|arm|tpch)( [1-9]*[0-9]+)*"
COMMENT_TRIGGER_TYPE="$(echo -e "${COMMENT_BODY}" | xargs | grep -E "${reg}" | awk -F' ' '{print $2}' | sed -n 1p | sed 's/\r//g')"
COMMENT_REPEAT_TIMES="$(echo -e "${COMMENT_BODY}" | xargs | grep -E "${reg}" | awk -F' ' '{print $3}' | sed -n 1p | sed 's/\r//g')"
echo "COMMENT_TRIGGER_TYPE=${COMMENT_TRIGGER_TYPE}" | tee -a "$GITHUB_OUTPUT"
echo "COMMENT_REPEAT_TIMES=${COMMENT_REPEAT_TIMES}" | tee -a "$GITHUB_OUTPUT"
- name: "Checkout master"
if: ${{ fromJSON(steps.parse.outputs.comment_trigger) }}
uses: actions/checkout@v4
- name: "Check if pr need run build"
if: ${{ fromJSON(steps.parse.outputs.comment_trigger) }}
id: changes
run: |
source regression-test/pipeline/common/github-utils.sh
set -x
if _get_pr_changed_files "${{ steps.parse.outputs.PULL_REQUEST_NUM }}"; then
if file_changed_fe_ut; then
echo "changed_fe_ut=true" | tee -a "$GITHUB_OUTPUT"
else
echo "changed_fe_ut=false" | tee -a "$GITHUB_OUTPUT"
fi
if file_changed_be_ut; then
echo "changed_be_ut=true" | tee -a "$GITHUB_OUTPUT"
else
echo "changed_be_ut=false" | tee -a "$GITHUB_OUTPUT"
fi
if file_changed_ckb; then
echo "changed_ckb=true" | tee -a "$GITHUB_OUTPUT"
echo "changed_tpch=true" | tee -a "$GITHUB_OUTPUT"
else
echo "changed_ckb=false" | tee -a "$GITHUB_OUTPUT"
echo "changed_tpch=false" | tee -a "$GITHUB_OUTPUT"
fi
if file_changed_regression_p0; then
echo "changed_p0=true" | tee -a "$GITHUB_OUTPUT"
echo "changed_external=true" | tee -a "$GITHUB_OUTPUT"
echo "changed_pipelinex_p0=true" | tee -a "$GITHUB_OUTPUT"
echo "changed_arm=true" | tee -a "$GITHUB_OUTPUT"
else
echo "changed_p0=false" | tee -a "$GITHUB_OUTPUT"
echo "changed_external=false" | tee -a "$GITHUB_OUTPUT"
echo "changed_pipelinex_p0=false" | tee -a "$GITHUB_OUTPUT"
echo "changed_arm=false" | tee -a "$GITHUB_OUTPUT"
fi
if file_changed_regression_p1; then
echo "changed_p1=true" | tee -a "$GITHUB_OUTPUT"
else
echo "changed_p1=false" | tee -a "$GITHUB_OUTPUT"
fi
else
echo "INFO: failed to _get_pr_changed_files, default trigger all"
echo "changed_fe_ut=true" | tee -a "$GITHUB_OUTPUT"
echo "changed_be_ut=true" | tee -a "$GITHUB_OUTPUT"
echo "changed_ckb=true" | tee -a "$GITHUB_OUTPUT"
echo "changed_tpch=true" | tee -a "$GITHUB_OUTPUT"
echo "changed_p0=true" | tee -a "$GITHUB_OUTPUT"
echo "changed_external=true" | tee -a "$GITHUB_OUTPUT"
echo "changed_pipelinex_p0=true" | tee -a "$GITHUB_OUTPUT"
echo "changed_arm=true" | tee -a "$GITHUB_OUTPUT"
echo "changed_p1=true" | tee -a "$GITHUB_OUTPUT"
fi
# - name: "Setup tmate session"
# if: ${{ failure() }}
# uses: mxschmitt/action-tmate@v3
- name: "Trigger or Skip feut"
if: ${{ fromJSON(steps.parse.outputs.comment_trigger) && contains(fromJSON('["feut", "buildall"]'), steps.parse.outputs.COMMENT_TRIGGER_TYPE) }}
run: |
source ./regression-test/pipeline/common/teamcity-utils.sh
set -x
trigger_or_skip_build \
"${{ steps.changes.outputs.changed_fe_ut }}" \
"${{ steps.parse.outputs.PULL_REQUEST_NUM }}" \
"${{ steps.parse.outputs.COMMIT_ID_FROM_TRIGGER }}" \
"feut" \
"${{ steps.parse.outputs.COMMENT_REPEAT_TIMES }}"
- name: "Trigger or Skip beut"
if: ${{ fromJSON(steps.parse.outputs.comment_trigger) && contains(fromJSON('["beut", "buildall"]'), steps.parse.outputs.COMMENT_TRIGGER_TYPE) }}
run: |
source ./regression-test/pipeline/common/teamcity-utils.sh
set -x
trigger_or_skip_build \
"${{ steps.changes.outputs.changed_be_ut }}" \
"${{ steps.parse.outputs.PULL_REQUEST_NUM }}" \
"${{ steps.parse.outputs.COMMIT_ID_FROM_TRIGGER }}" \
"beut" \
"${{ steps.parse.outputs.COMMENT_REPEAT_TIMES }}"
- name: "Trigger or Skip compile"
if: ${{ fromJSON(steps.parse.outputs.comment_trigger) && contains(fromJSON('["compile", "buildall"]'), steps.parse.outputs.COMMENT_TRIGGER_TYPE) }}
run: |
source ./regression-test/pipeline/common/teamcity-utils.sh
set -x
trigger_or_skip_build \
"${{ steps.changes.outputs.changed_p0 }}" \
"${{ steps.parse.outputs.PULL_REQUEST_NUM }}" \
"${{ steps.parse.outputs.COMMIT_ID_FROM_TRIGGER }}" \
"compile" \
"${{ steps.parse.outputs.COMMENT_REPEAT_TIMES }}"
- name: "Trigger or Skip p0"
if: ${{ fromJSON(steps.parse.outputs.comment_trigger) && contains(fromJSON('["p0", "buildall"]'), steps.parse.outputs.COMMENT_TRIGGER_TYPE) }}
run: |
source ./regression-test/pipeline/common/teamcity-utils.sh
if [[ ${{ steps.parse.outputs.COMMENT_TRIGGER_TYPE }} == "buildall" ]]; then
echo "COMMENT_TRIGGER_TYPE is buildall, trigger compile is enough, compile will trigger p0" && exit
fi
set -x
trigger_or_skip_build \
"${{ steps.changes.outputs.changed_p0 }}" \
"${{ steps.parse.outputs.PULL_REQUEST_NUM }}" \
"${{ steps.parse.outputs.COMMIT_ID_FROM_TRIGGER }}" \
"p0" \
"${{ steps.parse.outputs.COMMENT_REPEAT_TIMES }}"
- name: "Trigger or Skip p1"
if: ${{ fromJSON(steps.parse.outputs.comment_trigger) && contains(fromJSON('["p1", "buildall"]'), steps.parse.outputs.COMMENT_TRIGGER_TYPE) }}
run: |
source ./regression-test/pipeline/common/teamcity-utils.sh
COMMIT_ID_FROM_TRIGGER=${{ steps.parse.outputs.COMMIT_ID_FROM_TRIGGER }}
if [[ ${{ steps.parse.outputs.COMMENT_TRIGGER_TYPE }} == "buildall" ]]; then
echo "COMMENT_TRIGGER_TYPE is buildall, trigger compile is enough, compile will trigger p1" && exit
fi
set -x
trigger_or_skip_build \
"${{ steps.changes.outputs.changed_p1 }}" \
"${{ steps.parse.outputs.PULL_REQUEST_NUM }}" \
"${{ steps.parse.outputs.COMMIT_ID_FROM_TRIGGER }}" \
"p1" \
"${{ steps.parse.outputs.COMMENT_REPEAT_TIMES }}"
- name: "Trigger or Skip external"
if: ${{ fromJSON(steps.parse.outputs.comment_trigger) && contains(fromJSON('["external", "buildall"]'), steps.parse.outputs.COMMENT_TRIGGER_TYPE) }}
run: |
source ./regression-test/pipeline/common/teamcity-utils.sh
if [[ ${{ steps.parse.outputs.COMMENT_TRIGGER_TYPE }} == "buildall" ]]; then
echo "COMMENT_TRIGGER_TYPE is buildall, trigger compile is enough, compile will trigger external" && exit
fi
set -x
trigger_or_skip_build \
"${{ steps.changes.outputs.changed_external }}" \
"${{ steps.parse.outputs.PULL_REQUEST_NUM }}" \
"${{ steps.parse.outputs.COMMIT_ID_FROM_TRIGGER }}" \
"external" \
"${{ steps.parse.outputs.COMMENT_REPEAT_TIMES }}"
- name: "Trigger or Skip pipelinex_p0"
if: ${{ fromJSON(steps.parse.outputs.comment_trigger) && contains(fromJSON('["pipelinex_p0", "buildall"]'), steps.parse.outputs.COMMENT_TRIGGER_TYPE) }}
run: |
source ./regression-test/pipeline/common/teamcity-utils.sh
if [[ ${{ steps.parse.outputs.COMMENT_TRIGGER_TYPE }} == "buildall" ]]; then
echo "COMMENT_TRIGGER_TYPE is buildall, trigger compile is enough, compile will trigger pipelinex_p0" && exit
fi
set -x
trigger_or_skip_build \
"${{ steps.changes.outputs.changed_pipelinex_p0 }}" \
"${{ steps.parse.outputs.PULL_REQUEST_NUM }}" \
"${{ steps.parse.outputs.COMMIT_ID_FROM_TRIGGER }}" \
"pipelinex_p0" \
"${{ steps.parse.outputs.COMMENT_REPEAT_TIMES }}"
- name: "Trigger or Skip arm"
if: ${{ fromJSON(steps.parse.outputs.comment_trigger) && contains(fromJSON('["arm", "buildall"]'), steps.parse.outputs.COMMENT_TRIGGER_TYPE) }}
run: |
source ./regression-test/pipeline/common/teamcity-utils.sh
set -x
trigger_or_skip_build \
"${{ steps.changes.outputs.changed_arm }}" \
"${{ steps.parse.outputs.PULL_REQUEST_NUM }}" \
"${{ steps.parse.outputs.COMMIT_ID_FROM_TRIGGER }}" \
"arm" \
"${{ steps.parse.outputs.COMMENT_REPEAT_TIMES }}"
- name: "Trigger or Skip clickbench"
if: ${{ fromJSON(steps.parse.outputs.comment_trigger) && contains(fromJSON('["clickbench", "buildall"]'), steps.parse.outputs.COMMENT_TRIGGER_TYPE) }}
run: |
source ./regression-test/pipeline/common/teamcity-utils.sh
set -x
trigger_or_skip_build \
"${{ steps.changes.outputs.changed_ckb }}" \
"${{ steps.parse.outputs.PULL_REQUEST_NUM }}" \
"${{ steps.parse.outputs.COMMIT_ID_FROM_TRIGGER }}" \
"clickbench" \
"${{ steps.parse.outputs.COMMENT_REPEAT_TIMES }}"
- name: "Trigger or Skip tpch"
if: ${{ fromJSON(steps.parse.outputs.comment_trigger) && contains(fromJSON('["tpch", "buildall"]'), steps.parse.outputs.COMMENT_TRIGGER_TYPE) }}
run: |
source ./regression-test/pipeline/common/teamcity-utils.sh
if [[ ${{ steps.parse.outputs.COMMENT_TRIGGER_TYPE }} == "buildall" ]]; then
echo "COMMENT_TRIGGER_TYPE is buildall, trigger clickbench is enough, clickbench will trigger tpch" && exit
fi
set -x
trigger_or_skip_build \
"${{ steps.changes.outputs.changed_tpch }}" \
"${{ steps.parse.outputs.PULL_REQUEST_NUM }}" \
"${{ steps.parse.outputs.COMMIT_ID_FROM_TRIGGER }}" \
"tpch" \
"${{ steps.parse.outputs.COMMENT_REPEAT_TIMES }}"