-
Notifications
You must be signed in to change notification settings - Fork 294
[Ex CI] nonpolling dispatch action and summary check #607
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
685bc44
[Ex CI] nonpolling dispatch action and summary check
danielsu-amd 1fcf6bb
revert temp changes
danielsu-amd 8105253
enable reports for all pipelines
danielsu-amd 531cbb3
Add limit to merge commit check
danielsu-amd 372791d
Make wrapper for report summary stages
danielsu-amd ad258db
rm whitespace
danielsu-amd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| stages: | ||
| - stage: report_successful | ||
| condition: succeeded() | ||
| jobs: | ||
| - template: report-summary-check.yml | ||
| parameters: | ||
| checkConclusion: success | ||
| - stage: report_failed | ||
| condition: failed() | ||
| jobs: | ||
| - template: report-summary-check.yml | ||
| parameters: | ||
| checkConclusion: failure | ||
| - stage: report_cancelled | ||
| condition: canceled() # note: only 1 L in canceled() | ||
| jobs: | ||
| - template: report-summary-check.yml | ||
| parameters: | ||
| checkConclusion: cancelled |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| parameters: | ||
| - name: checkConclusion | ||
| type: string | ||
| default: success | ||
| values: | ||
| - success | ||
| - failure | ||
| - cancelled | ||
|
|
||
| jobs: | ||
| - job: report_summary_check | ||
| displayName: 'Report check status: ${{ parameters.checkConclusion }}' | ||
| variables: | ||
| - group: assistant-librarian | ||
| pool: | ||
| vmImage: ubuntu-latest | ||
| steps: | ||
| - checkout: none | ||
| - task: Bash@3 | ||
| displayName: Install GitHub CLI | ||
| condition: always() | ||
| inputs: | ||
| targetType: 'inline' | ||
| script: | | ||
| (type -p wget >/dev/null || (sudo apt update && sudo apt install wget -y)) \ | ||
| && sudo mkdir -p -m 755 /etc/apt/keyrings \ | ||
| && out=$(mktemp) && wget -nv -O$out https://cli.github.com/packages/githubcli-archive-keyring.gpg \ | ||
| && cat $out | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \ | ||
| && sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \ | ||
| && sudo mkdir -p -m 755 /etc/apt/sources.list.d \ | ||
| && echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \ | ||
| && sudo apt update \ | ||
| && sudo apt install gh jq -y | ||
| - task: Bash@3 | ||
| displayName: Report CI status to GitHub PR Summary Check | ||
| condition: always() | ||
| env: | ||
| APP_ID: $(APP_ID) | ||
| APP_INSTALLATION_ID: $(APP_INSTALLATION_ID) | ||
| APP_PRIVATE_KEY: $(APP_PRIVATE_KEY) | ||
| inputs: | ||
| targetType: 'inline' | ||
| script: | | ||
| if [[ ! "$(Build.SourceBranch)" =~ ^refs/pull/ ]]; then | ||
| echo "This is not a PR build. Exiting." | ||
| exit 0 | ||
| fi | ||
|
|
||
| # APP_PRIVATE_KEY is generated with `base64 app_private_key.pem | tr -d '\n'` | ||
| echo "$APP_PRIVATE_KEY" | base64 -d > app_private_key.pem | ||
| chmod 600 app_private_key.pem | ||
| create_jwt() { | ||
| local header=$(echo -n '{"alg":"RS256","typ":"JWT"}' | openssl base64 -e | tr -d '=' | tr '/+' '_-' | tr -d '\n') | ||
| local payload=$(echo -n "{\"iat\":$(date +%s),\"exp\":$(($(date +%s) + 600)),\"iss\":\"$APP_ID\"}" | openssl base64 -e | tr -d '=' | tr '/+' '_-' | tr -d '\n') | ||
| local unsigned_token="${header}.${payload}" | ||
| local signature=$(echo -n "$unsigned_token" | openssl dgst -sha256 -sign "app_private_key.pem" | openssl base64 -e | tr -d '=' | tr '/+' '_-' | tr -d '\n') | ||
| echo "${unsigned_token}.${signature}" | ||
| } | ||
| JWT=$(create_jwt) | ||
| export GH_TOKEN=$(curl -sSX POST \ | ||
| -H "Authorization: Bearer $JWT" \ | ||
| -H "Accept: application/vnd.github+json" \ | ||
| "https://api.github.com/app/installations/$APP_INSTALLATION_ID/access_tokens" | jq -r .token) | ||
|
|
||
| PR_NUMBER=$(echo "$(Build.SourceBranch)" | sed 's|refs/pull/\([0-9]*\)/.*|\1|') | ||
| PR_HEAD_SHA=$(curl -s "https://api.github.com/repos/ROCm/rocm-libraries/pulls/$PR_NUMBER" | jq -r '.head.sha') | ||
| CHECK=$(curl -s "https://api.github.com/repos/ROCm/rocm-libraries/commits/$PR_HEAD_SHA/check-runs" | jq -r '.check_runs[] | select(.name == "Azure CI Summary")') | ||
| CHECK_ID=$(echo "$CHECK" | jq -r '.id') | ||
| CHECK_SUMMARY=$(echo "$CHECK" | jq -r '.output.summary') | ||
| CHECK_TEXT=$(echo "$CHECK" | jq -r '.output.text') | ||
|
|
||
| if [[ -z "$CHECK_ID" ]]; then | ||
| echo "No Azure CI Summary check found for commit $PR_HEAD_SHA" | ||
| exit 0 | ||
| fi | ||
| if [[ "$CHECK_SUMMARY" == *"$(Build.BuildId)"* ]]; then | ||
| CHECK_SUMMARY=$(echo "$CHECK_SUMMARY" | sed "s/buildId=$(Build.BuildId)[^|]*|[^|]*|/buildId=$(Build.BuildId)) | ${{ parameters.checkConclusion }} |/") | ||
| fi | ||
| if [[ "$CHECK_TEXT" == *"$(Build.BuildId)="* ]]; then | ||
| CHECK_TEXT=$(echo "$CHECK_TEXT" | sed "s/$(Build.BuildId)=[^;]*;/$(Build.BuildId)=${{ parameters.checkConclusion }};/") | ||
| fi | ||
|
|
||
| CHECK_STATUS=$(echo "$CHECK_TEXT" | grep -q "pending" && echo "in_progress" || echo "completed") | ||
| CHECK_CONCLUSION=$(echo "$CHECK_TEXT" | grep -q -e "cancelled" -e "failure" && echo "failure" || echo "success") | ||
|
|
||
| if [[ "$CHECK_STATUS" == "completed" ]]; then | ||
| gh_output=$(gh api repos/ROCm/rocm-libraries/check-runs/$CHECK_ID \ | ||
| -X PATCH \ | ||
| -f "name=Azure CI Summary" \ | ||
| -f "head_sha=$PR_HEAD_SHA" \ | ||
| -f "status=$CHECK_STATUS" \ | ||
| -f "conclusion=$CHECK_CONCLUSION" \ | ||
| -f "output[title]=Azure CI Summary" \ | ||
| -f "output[summary]=$CHECK_SUMMARY" \ | ||
| -f "output[text]=$CHECK_TEXT") | ||
| else | ||
| gh_output=$(gh api repos/ROCm/rocm-libraries/check-runs/$CHECK_ID \ | ||
| -X PATCH \ | ||
| -f "name=Azure CI Summary" \ | ||
| -f "head_sha=$PR_HEAD_SHA" \ | ||
| -f "output[title]=Azure CI Summary" \ | ||
| -f "output[summary]=$CHECK_SUMMARY" \ | ||
| -f "output[text]=$CHECK_TEXT") | ||
| fi | ||
|
|
||
| echo "Reported status '${{ parameters.checkConclusion }}' to summary check: $(echo "$gh_output" | jq -r '.id')" | ||
| if [[ "$CHECK_STATUS" == "completed" ]]; then | ||
| echo "All checks completed with overall conclusion: $CHECK_CONCLUSION" | ||
| else | ||
| echo "Some checks are still in progress: $CHECK_STATUS" | ||
| fi | ||
| echo "Summary check URL: $(echo "$gh_output" | jq -r '.html_url')" | ||
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.