Repository navigation
Recover Android downloads and desktop coverage checks #649
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,18 +29,28 @@ jobs: | |
| GH_TOKEN: ${{ github.token }} | ||
| REPO: ${{ github.repository }} | ||
| RUN_ID: ${{ github.event.workflow_run.id }} | ||
| RUN_ATTEMPT: ${{ github.event.workflow_run.run_attempt }} | ||
| RUN_URL: ${{ github.event.workflow_run.html_url }} | ||
| SOURCE_SHA: ${{ github.event.workflow_run.head_sha }} | ||
| steps: | ||
| - name: Report unavailable or below-floor coverage | ||
| - name: Report missing coverage and close recovered alerts | ||
| run: | | ||
| set -euo pipefail | ||
| # Ignore CI runs already in progress when this workflow first lands. | ||
| source=$(gh api -H 'Accept: application/vnd.github.raw+json' "repos/$REPO/contents/.github/workflows/ci.yml?ref=$SOURCE_SHA") | ||
| if ! grep -Fxq ' coverage-floor:' <<< "$source"; then | ||
| exit 0 | ||
| fi | ||
| head=$(gh api "repos/$REPO/git/ref/heads/main" --jq .object.sha) | ||
| attempt_status=$(gh api "repos/$REPO/actions/runs/$RUN_ID" --jq '[.run_attempt, .status] | @tsv') | ||
| if [[ "$head" != "$SOURCE_SHA" || "$attempt_status" != "$RUN_ATTEMPT"$'\t'completed ]]; then | ||
| echo "Coverage report superseded by a newer commit or CI attempt." | ||
| exit 0 | ||
| fi | ||
| for platform in linux windows macos; do | ||
| title="CI coverage needs attention on $platform" | ||
| issue=$(gh issue list --repo "$REPO" --state open --label bug --search "$title in:title" --json author,title,number \ | ||
| --jq "map(select(.title == \"$title\" and (.author.login == \"app/github-actions\" or .author.login == \"github-actions[bot]\" or .author.login == \"github-actions\"))) | first | .number // empty") | ||
| dir=$(mktemp -d) | ||
| report="$dir/coverage-summary.json" | ||
| if gh run download "$RUN_ID" --repo "$REPO" --name "coverage-$platform" --dir "$dir" && | ||
|
|
@@ -54,16 +64,17 @@ jobs: | |
| ' "$report"); then | ||
| read -r covered count <<< "$counts" | ||
| if (( covered * 5 >= count * 4 )); then | ||
| if [[ -n "$issue" ]]; then | ||
| resolution=$(printf 'Coverage recovered on main: %s of %s source lines covered.\n\n[CI run %s](%s)' "$covered" "$count" "$RUN_ID" "$RUN_URL") | ||
| gh issue close "$issue" --repo "$REPO" --reason completed --comment "$resolution" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do not close an alert with a report from a replaced coverage job. The producer uses stable artifact names with The attempt check can accept attempt 2, while Before closing, verify that the report belongs to the effective coverage job. Keep reuse valid for successful jobs that were not rerun.
|
||
| fi | ||
| continue | ||
| fi | ||
| evidence="Covered $covered of $count source lines, below the 80% floor." | ||
| else | ||
| evidence="No valid line coverage report was available." | ||
| fi | ||
| title="CI coverage needs attention on $platform" | ||
| body=$(printf '%s\n\nSource commit %s.\n\n[CI run %s](%s)\n' "$evidence" "$SOURCE_SHA" "$RUN_ID" "$RUN_URL") | ||
| issue=$(gh issue list --repo "$REPO" --state open --label bug --search "$title in:title" --json title,number \ | ||
| --jq ".[] | select(.title == \"$title\") | .number" | head -n 1) | ||
| if [[ -n "$issue" ]]; then | ||
| if ! gh issue view "$issue" --repo "$REPO" --json body,comments --jq '.body, .comments[].body' | grep -F "[CI run $RUN_ID]($RUN_URL)" > /dev/null; then | ||
| gh issue comment "$issue" --repo "$REPO" --body "$body" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Superseded backstop runs can close coverage alerts.
The eligibility check runs before the issue lookup and the artifact download. The close step does not check eligibility again. If a push to
mainor a CI rerun happens during the download, the workflow can still close the alert with a report from the superseded commit or attempt. The close comment then states "Coverage recovered onmain" for a commit that is no longer current. The alert stays closed until a later backstop run evaluates the current run.The
concurrencygroup serializes backstop runs. It does not cancel the active run or lock the source CI run.Check the source commit and run attempt again immediately before
gh issue close. Skip the close when either value has changed. This narrows the window to the time between the second check and the close call.