Skip to content

Conversation

@sitaowang1998
Copy link
Collaborator

@sitaowang1998 sitaowang1998 commented Nov 17, 2025

Description

#197 added caching of lint:cpp-static-check in GitHub workflow, which does not correctly insert new caches. The cache created are immutable, but we save cache using the same key, and the cache save failed. Thus, the GitHub workflow are using an obsolete cache that are create.

This PR fixes this issue by appending the has of the cache content to the key. When restoring the cache, we use a prefix of that key, and actions/cache/restore will automatically select the newest entry.

Checklist

  • The PR satisfies the contribution guidelines.
  • This is a breaking change and that has been indicated in the PR title, OR this isn't a
    breaking change.
  • Necessary docs have been updated, OR no docs need to be updated.

Validation performed

  • Merged into main in my fork.
  • New cache was created on push.
  • Changed a C++ file and pushed again. The trigger workflow was restored cache successfully. Only the changed file is checked by clang-tidy, and the runtime drops from 54 minutes to 16 minutes.

Summary by CodeRabbit

  • Chores
    • CI caching keys updated to descriptive, hash-derived formats to improve cache consistency.
    • Scheduled lint runs now skip cache restoration so linting evaluates all files on schedule.
    • Restore and save cache behavior aligned to ensure reliable caching across regular runs.

✏️ Tip: You can customize this high-level summary in your review settings.

@sitaowang1998 sitaowang1998 requested a review from a team as a code owner November 17, 2025 18:53
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 17, 2025

Walkthrough

Replaced a fixed cache key with a descriptive prefix and a hash-derived save key for the C++ static lint step in the GitHub Actions workflow; added notes about prefix-based restore, hashFiles() usage, and that scheduled runs do not restore the lint cache so lint runs on all files.

Changes

Cohort / File(s) Summary
CI/CD Workflow Configuration
\.github/workflows/code-linting-checks\.yaml
Replaced static cache key main-branch-ubuntu-latest-lint:cpp-static-check with a prefix lint:check-cpp-static-on-ubuntu-latest for restore; updated save key to lint:check-cpp-static-on-ubuntu-latest-${{hashFiles(...)}}; added notes explaining prefix-based restores, hash derivation, and scheduled-run non-restore behavior.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Areas requiring attention:

  • Ensure hashFiles() covers all inputs that should invalidate the cache
  • Confirm YAML expression syntax and key-prefix consistency between restore and save steps
  • Verify scheduled-run non-restore behavior matches intended lint semantics

Pre-merge checks

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: fixing cache updates and restoration for the lint:cpp-static-check job's generated files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

📜 Recent review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3ec6b51 and 595a61b.

📒 Files selected for processing (1)
  • .github/workflows/code-linting-checks.yaml
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2024-10-23T02:23:12.161Z
Learnt from: kirkrodrigues
Repo: y-scope/spider PR: 1
File: .github/workflows/pr-title.yaml:11-15
Timestamp: 2024-10-23T02:23:12.161Z
Learning: Ensure to carefully check YAML indentation before suggesting fixes, and avoid removing comments unless necessary.

Applied to files:

  • .github/workflows/code-linting-checks.yaml
⏰ 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: lint
  • GitHub Check: non-storage-unit-tests (ubuntu-22.04)
  • GitHub Check: non-storage-unit-tests (ubuntu-24.04)
🔇 Additional comments (3)
.github/workflows/code-linting-checks.yaml (3)

55-59: Clear rationale for skipping cache restoration on scheduled runs.

The comment effectively explains why scheduled runs perform a complete lint check without cache restoration, which helps maintain code quality by catching dependency-related issues periodically.


69-76: Prefix-based cache restoration strategy is well-implemented.

The cache restore step correctly uses a prefix key to match the most recent cache entry, and the comprehensive comments clearly document the synchronization requirement with the save step and the rationale for avoiding explicit keys.


91-99: Cache key implementation correctly enables content-based invalidation.

The save step appends a hash of the cache contents to the prefix, creating unique keys when files change. The key prefix matches the restore step's prefix, and the hashFiles() patterns correctly reference all cached paths: the first two patterns match file paths exactly, and the third pattern uses **/* to hash all files within the build/lint-clang-tidy directory.


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
Member

@LinZhihao-723 LinZhihao-723 left a comment

Choose a reason for hiding this comment

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

  • Adding more comment mirrored from y-scope/clp#1430.
  • Adding a note to explain how the cache key works, as the prefix match isn't obvious.

sitaowang1998 and others added 2 commits January 6, 2026 20:53
Co-authored-by: Lin Zhihao <59785146+LinZhihao-723@users.noreply.github.com>
Co-authored-by: Lin Zhihao <59785146+LinZhihao-723@users.noreply.github.com>
@LinZhihao-723 LinZhihao-723 changed the title fix(ci): Correctly update and restore cache for lint:cpp-static-check's generated files . fix(ci): Correctly update and restore cache for lint:cpp-static-check's generated files . Jan 7, 2026
Copy link
Contributor

@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

🤖 Fix all issues with AI agents
In @.github/workflows/code-linting-checks.yaml:
- Around line 69-76: Fix the typo in the comment above the cache key: change
"prefix.y." to "prefix." in the comment block that documents the cache key (the
block referencing key: "lint:check-cpp-static-on-ubuntu-latest") so the sentence
reads "Use a prefix so the cache action can match and restore the most recent
cache entry that shares that prefix.".
📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 564d09e and 3ec6b51.

📒 Files selected for processing (1)
  • .github/workflows/code-linting-checks.yaml
⏰ 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: non-storage-unit-tests (ubuntu-24.04)
  • GitHub Check: non-storage-unit-tests (ubuntu-22.04)
  • GitHub Check: lint
🔇 Additional comments (2)
.github/workflows/code-linting-checks.yaml (2)

55-59: Clear documentation of scheduled run behavior.

The updated comment effectively explains why scheduled runs skip cache restoration, helping future maintainers understand the periodic full-lint strategy.


91-99: Verify hashFiles behavior with directory glob patterns.

The key construction uses hashFiles('build/lint-clang-tidy/**/*') to include all files under that directory. While GitHub Actions' hashFiles supports glob patterns, verify that:

  1. The directory glob correctly captures all intended files
  2. hashFiles behaves as expected when the directory contains many files or subdirectories
  3. The hash remains stable across runs when cache contents are identical

Consider testing this by:

  1. Checking that new cache entries are created after lint task modifies files
  2. Confirming cache is restored correctly on subsequent runs
  3. Monitoring for any hash collisions or empty hash values

Based on the PR description, initial validation shows this working correctly (cache created on push, restored on subsequent push, runtime reduced from 54 to 16 minutes).

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@LinZhihao-723 LinZhihao-723 merged commit 71f5179 into y-scope:main Jan 7, 2026
6 checks passed
@sitaowang1998 sitaowang1998 deleted the gh-cache branch January 7, 2026 03:00
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.

2 participants