Conversation
2c9f189 to
fd6706e
Compare
fd6706e to
a992f86
Compare
…rtifacts Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes PR artifact cleanup timeouts by avoiding full-repo artifact pagination and instead scoping artifact discovery/deletion to workflow runs for the PR’s head branch.
Changes:
- Fetch workflow run IDs for
$GITHUB_HEAD_REF, then list/delete artifacts per run (with pagination). - Update artifact display template to avoid printing table headers for runs with no artifacts.
- Update the ShellSpec test to mock the new
actions/runs?branch=...lookup flow.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| pr_cleanup/cleanup.sh | Replaces repo-wide artifact pagination with branch-scoped workflow run lookup and per-run artifact listing/deletion. |
| pr_cleanup/artifact_template.tpl | Suppresses rendering when the response contains no artifacts to avoid empty headers. |
| spec/pr_cleanup_spec.sh | Adjusts mocks to match the new GitHub API call pattern (branch runs + per-run artifacts). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
artifact_template.tpl contains no shell variable references, so envsubst was a no-op producing an uncleaned temp file. Load it directly like the cache template. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
gh api implicitly switches to POST when -f flags are used without an explicit -X GET, causing a 404 on the runs endpoint. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
SonarQube reviewer guide
|




Summary
pr_cleanup/cleanup.shscript was paginating all repository artifacts (/repos/.../actions/artifacts --paginate) to find ones matching the closed PR's head branch. Insonar-enterprisethis means iterating ~199,000 artifacts across ~2,000 API pages, causing the job to time out on every PR close.$GITHUB_HEAD_REFvia/actions/runs?branch=<branch>— bounded by the number of CI runs for that branch, typically a few dozen API pages at most./actions/runs/<runId>/artifacts --paginate— ensures all artifacts are captured even when a run has more than 30.spec/pr_cleanup_spec.shto mock the new API call pattern.Fixes: https://sonarsource.atlassian.net/browse/BUILD-10625
Related: https://sonarsource.atlassian.net/browse/PREQ-4580
Test plan
shellspec --shell bash spec/pr_cleanup_spec.sh— 1 example, 0 failuresworkflow_dispatchon a test branch insonar-enterpriseagainst multiple PRs:task/mm/backport-qa-fixes-to-2026.1) — completed in 37 seconds, no timeout: https://github.com/SonarSource/sonar-enterprise/actions/runs/22870515338/job/66348740082dm/fix-test) — completed in 1m17s, deleted 30+ artifacts, nothing listed after deletion: https://github.com/SonarSource/sonar-enterprise/actions/runs/22895060312/job/66426961279tz/sca-1542/add-risk-report-to-regulatory-report) — completed in 1m4s, nothing listed after deletion: https://github.com/SonarSource/sonar-enterprise/actions/runs/22905720053/job/66463711676