FEAT: Full Code Coverage & Workflow Integration #16
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
name: PR Code Coverage | |
on: | |
pull_request: | |
branches: | |
- main | |
jobs: | |
coverage-report: | |
runs-on: ubuntu-latest | |
permissions: | |
pull-requests: write | |
contents: read | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
- name: Wait for ADO build to succeed | |
run: | | |
PR_NUMBER=${{ github.event.pull_request.number }} | |
API_URL="https://dev.azure.com/sqlclientdrivers/public/_apis/build/builds?definitions=2128&queryOrder=queueTimeDescending&%24top=10&api-version=7.1-preview.7" | |
echo "Waiting for Azure DevOps build for PR #$PR_NUMBER ..." | |
for i in {1..100}; do | |
BUILD_INFO=$(curl -s "$API_URL" | jq -c --arg PR "$PR_NUMBER" '[.value[] | select(.triggerInfo["pr.number"]==$PR)][0] // empty') | |
if [[ -n "$BUILD_INFO" && "$BUILD_INFO" != "null" ]]; then | |
STATUS=$(echo "$BUILD_INFO" | jq -r .status) | |
RESULT=$(echo "$BUILD_INFO" | jq -r .result) | |
BUILD_ID=$(echo "$BUILD_INFO" | jq -r .id) | |
WEB_URL=$(echo "$BUILD_INFO" | jq -r ._links.web.href) | |
if [[ "$STATUS" == "completed" ]]; then | |
if [[ "$RESULT" == "succeeded" ]]; then | |
echo "✅ Build $BUILD_ID succeeded: $WEB_URL" | |
echo "ADO_URL=$WEB_URL" >> $GITHUB_ENV | |
break | |
else | |
echo "❌ Build $BUILD_ID failed" | |
exit 1 | |
fi | |
fi | |
fi | |
echo "⏳ Build not ready yet... retrying in 20s" | |
sleep 20 | |
done | |
- name: Comment ADO coverage link on PR | |
uses: marocchino/sticky-pull-request-comment@v2 | |
with: | |
header: Azure DevOps Coverage Report | |
message: | | |
✅ Azure DevOps build completed successfully. | |
👉 [View Full Coverage Report](${{ env.ADO_URL }}&view=codecoverage-tab) |