Skip to content

Harden action cache key#3545

Merged
koxudaxi merged 2 commits into
mainfrom
action/content-address-cache
Jul 2, 2026
Merged

Harden action cache key#3545
koxudaxi merged 2 commits into
mainfrom
action/content-address-cache

Conversation

@koxudaxi

@koxudaxi koxudaxi commented Jul 2, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • Chores
    • Improved package installation handling for the action, with clearer version validation and more consistent installation behavior.
    • Updated caching so it better matches the selected package, which can improve cache accuracy and install performance.

@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The 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.

Changes

Composite action package resolution

Layer / File(s) Summary
Resolve package and wire cache/install
action.yml
Adds a "Resolve install package" step validating inputs.version has no newlines and normalizing inputs.extras into PACKAGE; computes a SHA-256-hashed cache key from PACKAGE, exports it plus package via outputs, updates actions/cache to use the hashed key, and rewires the install step to use steps.install-package.outputs.package.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: koxudaxi

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: strengthening the action’s cache key calculation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch action/content-address-cache

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codspeed-hq

codspeed-hq Bot commented Jul 2, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

✅ 11 untouched benchmarks
⏩ 98 skipped benchmarks1


Comparing action/content-address-cache (70be029) with main (33476e6)

Open in CodSpeed

Footnotes

  1. 98 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

📚 Docs Preview: https://pr-3545.datamodel-code-generator.pages.dev

@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (33476e6) to head (70be029).
⚠️ Report is 3 commits behind head on main.

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           
Flag Coverage Δ
unittests 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@koxudaxi koxudaxi marked this pull request as ready for review July 2, 2026 16:32
@koxudaxi koxudaxi enabled auto-merge (squash) July 2, 2026 16:36

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
action.yml (1)

111-114: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low value

Consider adding restore-keys for partial cache reuse.

Since the key is now a hash of the full resolved PACKAGE string (version + extras), any version bump or extras change produces a completely different, non-matching key. Adding a restore-keys prefix 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.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3d48482e-9457-4a60-81ae-988df16ddf13

📥 Commits

Reviewing files that changed from the base of the PR and between a437c7d and 1e11942.

📒 Files selected for processing (1)
  • action.yml

@koxudaxi koxudaxi merged commit f433c2a into main Jul 2, 2026
60 checks passed
@koxudaxi koxudaxi deleted the action/content-address-cache branch July 2, 2026 17:02
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

🎉 Released in 0.67.0

This PR is now available in the latest release. See the release notes for details.

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.

1 participant