Skip to content

Add cache-workspace-crates and cache-directories inputs for rust-cache#12

Merged
Sewer56 merged 4 commits intov1-masterfrom
feat/cache-doc-artifacts-by-default
Apr 6, 2026
Merged

Add cache-workspace-crates and cache-directories inputs for rust-cache#12
Sewer56 merged 4 commits intov1-masterfrom
feat/cache-doc-artifacts-by-default

Conversation

@Sewer56
Copy link
Copy Markdown
Member

@Sewer56 Sewer56 commented Apr 5, 2026

Summary

  • Adds cache-workspace-crates input (default true) to preserve workspace crate artifacts in rust-cache
  • Adds cache-directories input for specifying additional cache paths relative to the project root
  • Caches rustdoc output directory automatically to speed up subsequent cargo doc runs
  • Includes Python helper script with unit tests for resolving cache paths

Changes

  • New inputs in action.yml for cache configuration
  • Python helper scripts/resolve_cache_directories.py handles path resolution
  • Unit tests verify deduplication, normalization, and env file output
  • README updated with rustdoc caching documentation and examples

Testing

Unit tests run automatically in test-workflow.yml on path changes affecting the helper script.

- Add cache-workspace-crates input (default true) for rust-cache
- Add cache-directories input for extra cache paths
- Add Python helper to resolve cache directories
- Add unit tests for the cache directory resolver
- Update README with rustdoc caching documentation
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 5, 2026

Warning

Rate limit exceeded

@Sewer56 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 11 minutes and 4 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 11 minutes and 4 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: faeeb69b-f944-4ea2-bef0-0ac72e6772e9

📥 Commits

Reviewing files that changed from the base of the PR and between ef8f917 and b0bfb23.

📒 Files selected for processing (2)
  • action.yml
  • tests/test_resolve_cache_directories.py

Walkthrough

The PR adds two new action inputs: cache-directories and cache-workspace-crates. It introduces scripts/resolve_cache_directories.py to compute and normalize cache directory lists and a unittest tests/test_resolve_cache_directories.py. action.yml and README were updated to expose the new inputs and document rustdoc cache behavior. GitHub Actions workflows were adjusted to trigger on scripts/** and tests/**/*.py, and a new CI job test-python-helper runs the added tests. .gitignore now excludes Python bytecode.

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 35.71% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the primary changes by highlighting the two new cache-related inputs added to the action.
Description check ✅ Passed The description clearly relates to the changeset by detailing the new inputs, helper script, tests, and documentation updates that match the file modifications.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/cache-doc-artifacts-by-default

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 and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

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

131-138: Gate cache-directory normalization behind cache enablement.

This step still runs when setup-rust-cache is disabled. In no-cache mode, it’s unnecessary work and avoidable failure surface.

♻️ Proposed change
     - name: Normalize rust-cache directories
+      if: inputs.setup-rust-cache == 'true'
       shell: bash
       run: python3 "${{ github.action_path }}/scripts/resolve_cache_directories.py"
       env:
         INPUT_RUST_PROJECT_PATH: ${{ inputs.rust-project-path }}
         INPUT_TARGET: ${{ inputs.target }}
         INPUT_CACHE_DIRECTORIES: ${{ inputs.cache-directories }}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@action.yml` around lines 131 - 138, The "Normalize rust-cache directories"
step is running unconditionally; gate it by the cache enablement input so it
only runs when caching is enabled. Update the step named "Normalize rust-cache
directories" to include a conditional (if:) that checks the workflow input
(e.g., inputs.setup-rust-cache == 'true') before executing the python script
that uses INPUT_RUST_PROJECT_PATH, INPUT_TARGET and INPUT_CACHE_DIRECTORIES, so
the step is skipped in no-cache mode.
tests/test_resolve_cache_directories.py (1)

44-48: Add a Windows absolute-path test case.

Current absolute-path coverage only checks POSIX-style paths. A Windows-style absolute path case would prevent regressions in cross-platform path handling.

🧪 Suggested test addition
     def test_preserves_absolute_paths(self) -> None:
         self.assertEqual(
             resolve_cache_directories("src", "", "/tmp/cache-dir\n"),
             ["src/target/doc", "/tmp/cache-dir"],
         )
+
+    def test_preserves_windows_absolute_paths(self) -> None:
+        self.assertEqual(
+            resolve_cache_directories("src", "", "C:\\cache-dir\n"),
+            ["src/target/doc", "C:/cache-dir"],
+        )
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/test_resolve_cache_directories.py` around lines 44 - 48, Extend the
absolute-path test for resolve_cache_directories to include a Windows-style
absolute path case (e.g., "C:\\\\cache-dir" or "C:/cache-dir") so the
test_preserves_absolute_paths assertion also checks that Windows absolute paths
are returned unchanged; update the call to resolve_cache_directories in
tests/test_resolve_cache_directories.py to include a Windows absolute path in
the expected list alongside "src/target/doc" and "/tmp/cache-dir" and add any
necessary escaping for backslashes in the test string.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@scripts/resolve_cache_directories.py`:
- Around line 115-121: The current absolute-path check uses only
posixpath.isabs(path) and misclassifies Windows absolute paths like
"C:\cache-dir"; update the branching in the function containing
posixpath.isabs(path) to treat Windows-style absolute paths as absolute by also
checking ntpath.isabs(path) (and/or posixpath.isabs on a normalized input);
ensure you compute the normalized input used for posix checks, then call
_normalize_path(path) for absolute cases (whether posix or nt) and only join
project_path for truly relative paths (keep references to posixpath.isabs,
ntpath.isabs, _normalize_path, project_path).

---

Nitpick comments:
In `@action.yml`:
- Around line 131-138: The "Normalize rust-cache directories" step is running
unconditionally; gate it by the cache enablement input so it only runs when
caching is enabled. Update the step named "Normalize rust-cache directories" to
include a conditional (if:) that checks the workflow input (e.g.,
inputs.setup-rust-cache == 'true') before executing the python script that uses
INPUT_RUST_PROJECT_PATH, INPUT_TARGET and INPUT_CACHE_DIRECTORIES, so the step
is skipped in no-cache mode.

In `@tests/test_resolve_cache_directories.py`:
- Around line 44-48: Extend the absolute-path test for resolve_cache_directories
to include a Windows-style absolute path case (e.g., "C:\\\\cache-dir" or
"C:/cache-dir") so the test_preserves_absolute_paths assertion also checks that
Windows absolute paths are returned unchanged; update the call to
resolve_cache_directories in tests/test_resolve_cache_directories.py to include
a Windows absolute path in the expected list alongside "src/target/doc" and
"/tmp/cache-dir" and add any necessary escaping for backslashes in the test
string.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9537e563-6f82-4d8d-a125-adbe0f9fce34

📥 Commits

Reviewing files that changed from the base of the PR and between c1aece4 and c9804a3.

📒 Files selected for processing (7)
  • .github/workflows/test-packages-input.yml
  • .github/workflows/test-workflow.yml
  • .gitignore
  • README.MD
  • action.yml
  • scripts/resolve_cache_directories.py
  • tests/test_resolve_cache_directories.py

Sewer56 added 3 commits April 6, 2026 00:39
Windows-style paths like `C:\cache-dir` were misclassified as relative
by the POSIX-only `isabs` check, causing them to be incorrectly joined
with `project_path`. Added `ntpath.isabs` as a fallback check.
EOF'
The "Normalize rust-cache directories" step was running unconditionally
regardless of the setup-rust-cache input setting. Added conditional check
so it only executes when caching is enabled (inputs.setup-rust-cache == 'true'),
matching the behavior of the dependent "Setup Rust Caching" step.
Replace four separate test methods with a single comprehensive test:
- test_preserves_absolute_paths
- test_preserves_windows_absolute_paths
- test_windows_absolute_path_not_joined_with_project_path
- test_mixed_posix_and_windows_absolute_paths

Now covered by test_preserves_posix_and_windows_absolute_paths which tests:
- POSIX absolute paths (/tmp/cache-dir)
- Windows absolute paths (C:\cache-dir)
- Backslash normalization to forward slashes
- Relative paths still joined to project root
@Sewer56 Sewer56 merged commit 5ccf48b into v1-master Apr 6, 2026
24 checks passed
@Sewer56 Sewer56 deleted the feat/cache-doc-artifacts-by-default branch April 6, 2026 00:00
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (4280cf3) to head (b0bfb23).
⚠️ Report is 6 commits behind head on v1-master.

Additional details and impacted files
@@       Coverage Diff       @@
##   v1-master   #12   +/-   ##
===============================
===============================

☔ View full report in Codecov by Sentry.
📢 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.

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