auto integration linuxdeepin/dde-control-center #4038
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |