[WIP] Clean actions cache workflow#5022
[WIP] Clean actions cache workflow#5022christianvogt wants to merge 2 commits intoopendatahub-io:mainfrom
Conversation
📝 WalkthroughWalkthrough
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Pre-merge checks❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
.github/workflows/pr-cache-cleanup.yml(1 hunks).github/workflows/test.yml(3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: Cypress-Setup
- GitHub Check: Lint
- GitHub Check: Type-Check
🔇 Additional comments (2)
.github/workflows/test.yml (2)
52-52: Centralizing the modules cache key is spot onReferencing
needs.Setup.outputs.modules-cache-keyacross the jobs keeps cache usage consistent and prevents divergent installs. Nicely tightened up.Also applies to: 79-79, 106-106
56-57: Broader Turbo cache coverage looks greatSwitching the Turbo cache
pathto**/.turboensures every workspace gets picked up without extra duplication. Thanks for making the reuse more robust.Also applies to: 83-84, 110-111
| cacheKeysForPR=$(gh cache list --ref $BRANCH --limit 1000 --json id --jq '.[].id') | ||
|
|
||
| ## Setting this to not fail the workflow while deleting cache keys. | ||
| set +e | ||
| echo "Deleting caches..." | ||
| for cacheKey in $cacheKeysForPR | ||
| do | ||
| gh cache delete $cacheKey | ||
| done |
There was a problem hiding this comment.
Prevent gh cache from failing by using the REST API instead
On GitHub-hosted runners the plain gh cache … subcommand is not available unless the actions/gh-actions-cache extension is pre-installed. As written, the very first gh cache list … invocation exits with “unknown command” and the cleanup job fails every time. Switching to the built-in REST API (gh api) avoids that dependency and keeps the job portable.
Please adjust the script along these lines:
- cacheKeysForPR=$(gh cache list --ref $BRANCH --limit 1000 --json id --jq '.[].id')
+ cacheKeysForPR=$(gh api repos/$GH_REPO/actions/caches --paginate -F ref=$BRANCH --jq '.actions_caches[].id')
@@
- gh cache delete $cacheKey
+ gh api --method DELETE repos/$GH_REPO/actions/caches/$cacheKeyThis runs everywhere without requiring extra tooling and keeps the cleanup workflow from breaking.
🤖 Prompt for AI Agents
.github/workflows/pr-cache-cleanup.yml around lines 16 to 24: the workflow uses
the `gh cache` subcommand which may not be available on GitHub-hosted runners
and causes the job to fail; replace the `gh cache list` and `gh cache delete`
calls with `gh api` REST requests that list cache entries for the branch
(querying /repos/:owner/:repo/actions/caches with appropriate params and parsing
returned cache ids) and then delete each cache id via `gh api --method DELETE
/repos/:owner/:repo/actions/caches/:cache_id`; keep the `set +e` behavior or add
per-request error handling so failures don’t break the cleanup, and iterate over
the returned ids to delete them using the REST API instead of the subcommand.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5022 +/- ##
==========================================
- Coverage 67.82% 67.68% -0.14%
==========================================
Files 2235 2230 -5
Lines 51007 50734 -273
Branches 14215 14090 -125
==========================================
- Hits 34595 34339 -256
+ Misses 16412 16395 -17 see 42 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
Description
An actions to clean up github actions cache when a PR closes
How Has This Been Tested?
Test Impact
Request review criteria:
Self checklist (all need to be checked):
If you have UI changes:
After the PR is posted & before it merges:
mainSummary by CodeRabbit