-
Notifications
You must be signed in to change notification settings - Fork 44
304 lines (277 loc) · 12 KB
/
auto-integration.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
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
name: integration-request
on: #[push]
pull_request_target:
paths:
- "integration.yml"
types: [ opened, synchronize ]
concurrency:
group: ${{ github.workflow }}-pull/${{ github.event.number }}
cancel-in-progress: true
env:
TOPIC: test-integration-pr-${{ github.event.number }}
OSCPASS: ${{ secrets.OSCPASS }}
jobs:
parsec_integration:
uses: deepin-community/Repository-Integration/.github/workflows/01-parsec-integration.yml@master
ouput_message:
name: output integration
needs: parsec_integration
if: ${{ github.event.pull_request.head.sha }}
uses: deepin-community/Repository-Integration/.github/workflows/02-integration-output.yml@master
build_project_prepare:
name: build project prepare
runs-on: ubuntu-latest
outputs:
issueid: ${{ steps.find-comments.outputs.issueid }}
projectItemID: ${{ steps.find-comments.outputs.projectItemID }}
steps:
- name: obs integration topic project prepare
run: |
set +e
set -x
result=$(curl -u golf66:$OSCPASS "https://build.deepin.com/source/deepin:CI:TestingIntegration:$TOPIC/_meta"|grep "unknown_project")
if [ "$result" != "" ];then
curl -o meta.xml https://raw.githubusercontent.com/deepin-community/Repository-Integration/master/.github/workflows/obs-proj-meta.tpl
sed -i "s#TOPIC#${TOPIC}#g" meta.xml
curl -X PUT -u golf66:$OSCPASS -H "Content-type: text/xml" -d @meta.xml "https://build.deepin.com/source/deepin:CI:TestingIntegration:$TOPIC/_meta"
fi
- name: find comments
id: find-comments
uses: actions/github-script@v6
with:
script: |
let issueid = 'undefined'
let projectItemID = 'undefined'
const BOT_NAME = "IntegrationProjector Bot"
const COMMENT_HEAD = "**" + BOT_NAME + "**\n"
if ( context.issue.number != undefined ) {
const response = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number
})
const reg = new RegExp("\\*+" + BOT_NAME + "\\*+")
botComment = response.data.find(comment => comment.body.match(reg))
if (botComment) {
// get issue id
comments = botComment.body.split("\n")
core.debug(botComment)
// console.log(comments.length)
if (comments.length > 3) {
id = comments[2].replace("IssueID: ", "")
const res = await github.rest.issues.get({
owner: "linuxdeepin",
repo: "developer-center",
issue_number: id
})
if (res.data.state != "closed") {
issueid = id
projectItemID = comments[3].replace("ProjectItemID: ", "")
}
}
}
}
console.log('issueid: ', issueid, 'projectItemID: ', projectItemID)
core.setOutput('issueid', issueid)
core.setOutput('projectItemID', projectItemID)
wait_build_pending_status:
name: wait build pending status
runs-on: ubuntu-latest
needs:
- parsec_integration
- ouput_message
- build_project_prepare
- build_main
- build_dde
- build_community
- build_commercial
if: |
always() && !cancelled() &&
(needs.parsec_integration.result == 'success') && (needs.ouput_message.result != 'failure' ) &&
(needs.build_main.result == 'success' || needs.build_main.result == 'skipped') &&
(needs.build_dde.result == 'success' || needs.build_dde.result == 'skipped') &&
(needs.build_community.result == 'success' || needs.build_community.result == 'skipped') &&
(needs.build_commercial.result == 'success' || needs.build_commercial.result == 'skipped')
steps:
- name: wait build pending status
uses: actions/github-script@v6
with:
script: |
let retryCount = 30;
let attemptCount = 0;
function sleep(time){
return new Promise((resolve) => setTimeout(resolve, time));
}
if ( context.issue.number != undefined ) {
while (true) {
// Get the latest information about the Pull Request
const pullRequest = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number,
});
// Check if the Pull Request has the '/integrate-testing' label
const hasLabel = pullRequest.data.labels.some(label => label.name === 'integrate-testing')
if (hasLabel) {
console.log(`All build commit statuses is now a success by manual`)
break
}
const { data: statuses } = await github.rest.repos.getCombinedStatusForRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "${{ github.event.pull_request.head.sha }}",
})
console.log("ref statuses:", statuses)
buildStatuses = [];
buildStatuses = statuses.statuses.filter((status) => status.context.includes("testing_repository_building"));
console.log("ref build statuses:", buildStatuses)
const successStatuses = buildStatuses.filter((status) => status.state === "success");
console.log("ref success statuses:", successStatuses)
if (buildStatuses.length == 0) {
core.setFailed(`Can't find obs build statuses, Exiting...`);
break;
}
if (successStatuses.length == buildStatuses.length) {
console.log(`All build commit statuses is now a success.`);
break;
}
if (attemptCount >= retryCount) {
core.setFailed(`Exceeded maximum retry count. Exiting...`);
break;
}
attemptCount++;
console.log(`Waiting for commit statuses to become a success...`);
await sleep(60000)
}
}
create_issue_link_project:
name: create issue and link project
needs:
- parsec_integration
- ouput_message
- build_project_prepare
- build_main
- build_dde
- build_community
- build_commercial
- wait_build_pending_status
if: |
always() && !cancelled() &&
(needs.parsec_integration.result == 'success') && (needs.ouput_message.result != 'failure' ) &&
(needs.build_main.result == 'success' || needs.build_main.result == 'skipped') &&
(needs.build_dde.result == 'success' || needs.build_dde.result == 'skipped') &&
(needs.build_community.result == 'success' || needs.build_community.result == 'skipped') &&
(needs.build_commercial.result == 'success' || needs.build_commercial.result == 'skipped') &&
needs.wait_build_pending_status.result == 'success'
uses: deepin-community/Repository-Integration/.github/workflows/issue-project-manager.yml@master
secrets: inherit
with:
repo: linuxdeepin/developer-center
issueid: ${{ needs.build_project_prepare.outputs.issueid }} #for test 3961
project: 21 # https://github.com/orgs/linuxdeepin/projects/21/views/1
assignees: "Zeno-sole, hudeng-go"
title: "[Deepin Integration]~[${{ needs.parsec_integration.outputs.milestone }}] ${{ needs.parsec_integration.outputs.integration_message }}"
status: "In progress"
milestone: ${{ needs.parsec_integration.outputs.milestone }}
labels: ${{ needs.parsec_integration.outputs.labels }}
integrationinfo: ${{ needs.parsec_integration.outputs.integrationinfo }}
changelog: ${{ needs.parsec_integration.outputs.changelog }}
influence: ${{ needs.parsec_integration.outputs.influence }}
testrepoaddr: ${{ needs.parsec_integration.outputs.testrepoaddr }}
pass_integration:
name: pass integration
needs:
- parsec_integration
- ouput_message
- build_project_prepare
- create_issue_link_project
uses: deepin-community/Repository-Integration/.github/workflows/04-auto-test.yml@master
if: |
always() && !cancelled() &&
(needs.create_issue_link_project.result == 'success')
with:
topic: test-integration-pr-${{ github.event.number }}
packages: ${{ needs.parsec_integration.outputs.all_build_task }}
deploy: ${{ needs.parsec_integration.outputs.deploy }}
# merge finished and success, closing this pr
close-pull-request:
name: close this pull request
needs:
- parsec_integration
- pass_integration
if: |
always() && !cancelled() &&
(needs.pass_integration.result == 'success')
uses: deepin-community/Repository-Integration/.github/workflows/06-deployed.yml@master
secrets: inherit
with:
integrations: ${{ needs.parsec_integration.outputs.all_build_task }}
# build task
build_main:
name: build_main
if: always() && !cancelled() && (needs.parsec_integration.outputs.build_matrix_main != '') && (needs.parsec_integration.result == 'success')
needs:
- parsec_integration
- build_project_prepare
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.parsec_integration.outputs.build_matrix_main) }}
uses: deepin-community/Repository-Integration/.github/workflows/02-build-obs.yml@master
secrets: inherit
with:
repo: ${{ matrix.payload.repo }}
tag: ${{ matrix.payload.tag }}
tagsha: ${{ matrix.payload.tagsha }}
topic: test-integration-pr-${{ github.event.number }}
build_dde:
name: build_dde
if: always() && !cancelled() && (needs.parsec_integration.outputs.build_matrix_dde != '') && (needs.parsec_integration.result == 'success')
needs:
- parsec_integration
- build_project_prepare
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.parsec_integration.outputs.build_matrix_dde) }}
uses: deepin-community/Repository-Integration/.github/workflows/02-build-obs.yml@master
secrets: inherit
with:
repo: ${{ matrix.payload.repo }}
tag: ${{ matrix.payload.tag }}
tagsha: ${{ matrix.payload.tagsha }}
topic: test-integration-pr-${{ github.event.number }}
component: "dde"
build_community:
name: build_community
if: always() && !cancelled() && (needs.parsec_integration.outputs.build_matrix_community != '') && (needs.parsec_integration.result == 'success')
needs:
- parsec_integration
- build_project_prepare
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.parsec_integration.outputs.build_matrix_community) }}
uses: deepin-community/Repository-Integration/.github/workflows/02-build-obs.yml@master
secrets: inherit
with:
repo: ${{ matrix.payload.repo }}
tag: ${{ matrix.payload.tag }}
tagsha: ${{ matrix.payload.tagsha }}
topic: test-integration-pr-${{ github.event.number }}
component: "community"
build_commercial:
name: build_commercial
if: always() && !cancelled() && (needs.parsec_integration.outputs.build_matrix_commercial != '') && (needs.parsec_integration.result == 'success')
needs:
- parsec_integration
- build_project_prepare
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.parsec_integration.outputs.build_matrix_commercial) }}
uses: deepin-community/Repository-Integration/.github/workflows/02-build-obs.yml@master
secrets: inherit
with:
repo: ${{ matrix.payload.repo }}
tag: ${{ matrix.payload.tag }}
tagsha: ${{ matrix.payload.tagsha }}
topic: test-integration-pr-${{ github.event.number }}
component: "commercial"
gitaddr: ${{ matrix.payload.gitaddr }}