Skip to content

Commit

Permalink
chore(CI): obs build workflow cancel wait build pending status
Browse files Browse the repository at this point in the history
  • Loading branch information
hudeng-go committed Mar 5, 2024
1 parent d439af6 commit e1ee911
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 83 deletions.
82 changes: 0 additions & 82 deletions .github/workflows/02-build-obs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,85 +161,3 @@ jobs:
fi
echo "needbuild=$needbuild" >> $GITHUB_OUTPUT
log:
needs: build
strategy:
matrix:
arch: [aarch64, x86_64]

runs-on: ubuntu-latest
env:
ARCH: ${{ matrix.arch }}
steps:
- name: Set commit status as pending
if: ${{ needs.build.outputs.needbuild }} == "true"
uses: myrotvorets/set-commit-status-action@master
with:
token: ${{ github.token }}
status: pending
context: "${{ needs.build.outputs.pkgname }}_${{ matrix.arch }}_testing_repository_building"
targetUrl: "${{ needs.build.outputs.targeturl }}${{ matrix.arch }}"
sha: ${{ github.event.pull_request.head.sha }}

- name: Wait for build to succeed
uses: cloudposse/github-action-wait-commit-status@main
id: wait-for-build
with:
repository: ${{ github.repository }}
sha: ${{ github.event.pull_request.head.sha }}
status: "${{ needs.build.outputs.pkgname }}_${{ matrix.arch }}_testing_repository_building"
expected_state: "success"
token: ${{ github.token }}
check-retry-interval: 60
check-retry-count: 60

- name: Do something with a build time out
if: steps.wait-for-build.outputs.conclusion == 'timed_out'
id: wait_time_out
run: |
set -x
sudo apt-get update && sudo apt install -y osc
mkdir -p ~/.config/osc
echo "${{ secrets.OSCRC }}" > ~/.config/osc/oscrc
pkgname="${{ needs.build.outputs.pkgname }}"
if [ "$COMPONENT" = "main" ]; then
osc co deepin:CI:TestingIntegration:${TOPIC}/${pkgname} && cd $_
else
osc co deepin:CI:TestingIntegration:${TOPIC}:${COMPONENT}/${pkgname} && cd $_
fi
timeouturl="${{ needs.build.outputs.targeturl }}${{ matrix.arch }}"
description="wait build complete timeout"
status="pending"
buildresult=$(osc results -a ${ARCH} -r testing |awk '{print $3}')
if [ "$buildresult" = "succeeded" ];then
status="success"
description=""
elif [ "$buildresult" = "excluded" ]; then
status="success"
description="build excluded"
timeouturl=""
elif [ "$buildresult" = "failed" ]; then
status="failure"
description=""
fi
echo "timeouturl=$timeouturl" >> $GITHUB_OUTPUT
echo "description=$description" >> $GITHUB_OUTPUT
echo "status=$status" >> $GITHUB_OUTPUT
- name: Update status build status as timeout
if: steps.wait-for-build.outputs.conclusion == 'timed_out'
uses: myrotvorets/set-commit-status-action@master
with:
token: ${{ github.token }}
status: ${{ steps.wait_time_out.outputs.status }}
context: "${{ needs.build.outputs.pkgname }}_${{ matrix.arch }}_testing_repository_building"
targetUrl: ${{ steps.wait_time_out.outputs.timeouturl }}
sha: ${{ github.event.pull_request.head.sha }}
description: ${{ steps.wait_time_out.outputs.description }}

#- name: report build error at action
# if: steps.wait_time_out.outputs.status != 'success' || steps.wait-for-build.outputs.conclusion == 'failure'
# run: |
# exit -1
54 changes: 53 additions & 1 deletion .github/workflows/auto-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,56 @@ jobs:
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
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')
steps:
- name: wait build pending status
uses: actions/github-script@v6
with:
script: |
let retryCount = 30;
let attemptCount = 0;
if ( context.issue.number != undefined ) {
while (true) {
setInterval(function() {
const { data: statuses } = await github.rest.repos.listCommitStatusesForRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "${{ github.event.pull_request.head.sha }}",
})
const successStatuses = statuses.filter((status) => status.state === "success");
if (successStatuses.length == statuses.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 status to become a success...`);
}
}, 3600000)
}
create_issue_link_project:
name: create issue and link project
needs:
Expand All @@ -93,12 +143,14 @@ jobs:
- build_main
- build_dde
- build_community
- 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_community.result == 'success' || needs.build_community.result == 'skipped') &&
needs.wait_build_pending_status == 'success'
uses: deepin-community/Repository-Integration/.github/workflows/issue-project-manager.yml@master
secrets: inherit
with:
Expand Down

0 comments on commit e1ee911

Please sign in to comment.