check_enforcer #28125
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: GitHub Event Handler | |
on: | |
status | |
env: | |
head_sha: ${{ github.sha }} | |
jobs: | |
event-handler: | |
name: ${{ github.event_name }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Summarize check status | |
id: summarize_check_status | |
shell: pwsh | |
run: | | |
$env:pending_count = 0 | |
$env:success_count = 0 | |
function check_conclusion { | |
param( | |
[string]$conclusion | |
) | |
if ($conclusion -ieq "success") { | |
$env:success_count = 1 + $env:success_count | |
Write-Host "Success: " $env:success_count | |
} else { | |
$env:pending_count = 1 + $env:pending_count | |
Write-Host "Pending: " $env:pending_count | |
} | |
} | |
$(gh api /repos/${{ github.repository }}/commits/${{ env.head_sha }}/check-runs) | ConvertFrom-Json | Select-Object -ExpandProperty check_runs | ForEach-Object { | |
if ($_.name.Contains('promptflow-executor-unit-test')) { | |
check_conclusion $_.conclusion $_.name | |
} | |
if ($_.name.Contains('promptflow-executor-e2e-test')) { | |
check_conclusion $_.conclusion $_.name | |
} | |
if ($_.name.Contains('promptflow-sdk-cli-test')) { | |
check_conclusion $_.conclusion $_.name | |
} | |
} | |
Write-Host "Total not success test numbers: "$pending_count | |
Write-Host "Total success test numbers: "$success_count | |
if ($pending_count -eq 0) { | |
gh api ` | |
--method POST ` | |
-H "Accept: application/vnd.github+json" ` | |
-H "X-GitHub-Api-Version: 2022-11-28" ` | |
/repos/${{ github.repository }}/statuses/${{ env.head_sha }} ` | |
-f state='success' ` | |
-f target_url='https://github.com/microsoft/promptflow/actions/runs/${{ github.run_id }}' ` | |
-f description='The build succeeded!' ` | |
-f context='https://aka.ms/azsdk/checkenforcer' | |
} else { | |
gh api ` | |
--method POST ` | |
-H "Accept: application/vnd.github+json" ` | |
-H "X-GitHub-Api-Version: 2022-11-28" ` | |
/repos/${{ github.repository }}/statuses/${{ env.head_sha }} ` | |
-f state='pending' ` | |
-f target_url='https://github.com/microsoft/promptflow/actions/runs/${{ github.run_id }}' ` | |
-f description='Waiting for all checks to succeed' ` | |
-f context='https://aka.ms/azsdk/checkenforcer' | |
} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |