Skip to content

BUILD-9451 Fix artifact cleanup pagination#210

Merged
julien-carsique-sonarsource merged 1 commit intomasterfrom
fix/jcarsique/BUILD-9451-testCleanup
Feb 12, 2026
Merged

BUILD-9451 Fix artifact cleanup pagination#210
julien-carsique-sonarsource merged 1 commit intomasterfrom
fix/jcarsique/BUILD-9451-testCleanup

Conversation

@julien-carsique-sonarsource
Copy link
Contributor

@julien-carsique-sonarsource julien-carsique-sonarsource commented Feb 12, 2026

BUILD-9451

Summary

Changes

  • Replace --slurp with --paginate alone (gh api doesn't support --slurp with --jq/--template)
  • Update artifact ID collection and display to use pagination
  • Update test mocks to match new command pattern

🤖 Generated with Claude Code

@julien-carsique-sonarsource julien-carsique-sonarsource requested a review from a team as a code owner February 12, 2026 17:40
Copilot AI review requested due to automatic review settings February 12, 2026 17:40
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes artifact cleanup pagination to handle unlimited artifacts across multiple API pages and resolves a test-cleanup failure from a previously merged PR.

Changes:

  • Added pagination support to fetch all artifacts and cache entries across multiple API pages
  • Updated gh api commands to use --paginate flag with appropriate filters
  • Fixed test mock to match the new command pattern with pagination
  • Added CACHE_LIST_LIMIT constant to handle cache pagination limits

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
pr_cleanup/cleanup.sh Added pagination support to artifact and cache API calls, introduced cache list limit constant
spec/pr_cleanup_spec.sh Updated test mock pattern to match new paginated API command structure

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Implement full pagination support to handle unlimited numbers of items:
- Cache operations: Use --limit 100000 with gh cache list (GitHub's practical maximum)
- Artifact operations: Use gh api --paginate to fetch ALL artifacts across all pages

Changes to artifact cleanup:
- Replace ?per_page=100 limit with --paginate for complete pagination
- Line 50: Use --paginate with --jq to collect artifact IDs from all pages
- Lines 47, 60: Use --paginate with --template for display (filtering remains in template)
- Keep branch filtering in artifact_template.tpl (required when using --template)

Technical note:
- Cannot use --slurp with --jq or --template (gh api limitation)
- With --paginate --jq: Filter is applied to each page, results are concatenated
- With --paginate --template: Template is rendered for each page separately

This ensures complete cleanup of PR resources regardless of count:
- Caches: up to 100,000 items (GitHub's limit)
- Artifacts: unlimited (all pages processed)

Previously, artifact cleanup was limited to the first 100 items per API call,
leaving orphaned artifacts when PRs had >100 artifacts.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@julien-carsique-sonarsource julien-carsique-sonarsource force-pushed the fix/jcarsique/BUILD-9451-testCleanup branch from 9aa8f86 to 06bf280 Compare February 12, 2026 17:42
@sonarqubecloud
Copy link

Copy link
Contributor

@bwalsh434 bwalsh434 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, less necessary jq 👍

@julien-carsique-sonarsource julien-carsique-sonarsource merged commit 56acc81 into master Feb 12, 2026
12 checks passed
@julien-carsique-sonarsource julien-carsique-sonarsource deleted the fix/jcarsique/BUILD-9451-testCleanup branch February 12, 2026 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants