Harden action cache key#3545
Conversation
📝 WalkthroughWalkthroughThe composite GitHub Action workflow adds a "Resolve install package" step that validates the version input and normalizes extras into a PACKAGE value, then updates the pip cache key to a SHA-256 hash of PACKAGE and rewires the install step to consume this resolved output. ChangesComposite action package resolution
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: koxudaxi 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
Merging this PR will not alter performance
|
|
📚 Docs Preview: https://pr-3545.datamodel-code-generator.pages.dev |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3545 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 161 161
Lines 34363 34363
Branches 4011 4011
=========================================
Hits 34363 34363
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
action.yml (1)
111-114: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low valueConsider adding
restore-keysfor partial cache reuse.Since the key is now a hash of the full resolved
PACKAGEstring (version + extras), any version bump or extras change produces a completely different, non-matching key. Adding arestore-keysprefix would let pip still restore a prior cache directory as a starting point (partial hit) instead of a full cache miss on every version change.♻️ Suggested addition
- uses: actions/cache@2c8a9bd7457de244a408f35966fab2fb45fda9c8 # v6.0.0 with: path: ~/.cache/pip key: datamodel-codegen-${{ runner.os }}-python-3.14-${{ steps.install-package.outputs.cache-key }} + restore-keys: | + datamodel-codegen-${{ runner.os }}-python-3.14-🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@action.yml` around lines 111 - 114, The cache setup in the workflow currently uses only a strict key in the actions/cache step, so any PACKAGE version or extras change causes a full miss. Update the cache configuration for the step that uses actions/cache@2c8a9bd7457de244a408f35966fab2fb45fda9c8 to add a restore-keys prefix based on the existing datamodel-codegen cache key format, so pip can fall back to the closest prior cache when the exact key changes.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@action.yml`:
- Around line 111-114: The cache setup in the workflow currently uses only a
strict key in the actions/cache step, so any PACKAGE version or extras change
causes a full miss. Update the cache configuration for the step that uses
actions/cache@2c8a9bd7457de244a408f35966fab2fb45fda9c8 to add a restore-keys
prefix based on the existing datamodel-codegen cache key format, so pip can fall
back to the closest prior cache when the exact key changes.
|
🎉 Released in 0.67.0 This PR is now available in the latest release. See the release notes for details. |
Summary by CodeRabbit