Skip to content

ci(lint): Cache necessary files for lint:cpp-static-check to skip unnecessary re-runs. - #197

Merged
LinZhihao-723 merged 3 commits into
y-scope:mainfrom
LinZhihao-723:clang-tidy-cache
Aug 15, 2025
Merged

ci(lint): Cache necessary files for lint:cpp-static-check to skip unnecessary re-runs.#197
LinZhihao-723 merged 3 commits into
y-scope:mainfrom
LinZhihao-723:clang-tidy-cache

Conversation

@LinZhihao-723

@LinZhihao-723 LinZhihao-723 commented Aug 14, 2025

Copy link
Copy Markdown
Member

Description

A full-run of clang-tidy takes more than half an hour to complete for the current code base. This PR is a solution to reduce the total execution time for clang-tidy checks by adapting this PR from CLP core. It has made the following changes to make it work in Spider:

  • We don't have linting workflows running on multiple OS, so the cache key is hardcoded to ubuntu-latest.
  • In Spider, the clang-tidy task is called cpp-static-check instead of check-cpp-static-full.

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

  • Ensure all workflows passed.
  • Ensure the cache files work as expected locally.

Didn't try on the local branches for the actual CI execution, as the functionality has been tested in CLP core.

Summary by CodeRabbit

  • New Features

    • None.
  • Bug Fixes

    • None.
  • Chores

    • Improved CI performance by adding caching for C++ static analysis to reduce repeated run times.
    • Ensured scheduled runs bypass cache to keep full-file analysis.
    • Limit cache updates to the main branch for consistent results.
    • Centralized clang-tidy outputs via a new build-level output directory variable.
  • Documentation

    • Added clarifying comments about caching behaviour and run conditions.

@LinZhihao-723
LinZhihao-723 requested review from a team and sitaowang1998 as code owners August 14, 2025 22:58
@coderabbitai

coderabbitai Bot commented Aug 14, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Adds cache restore/save steps to the code-linting-checks GitHub Actions workflow for cpp static checks with event/branch conditions, and introduces G_LINT_CLANG_TIDY_DIR in lint-tasks.yaml used as OUTPUT_DIR for clang-tidy outputs across source, tests, and examples.

Changes

Cohort / File(s) Summary
CI workflow caching for cpp static lint
.github/workflows/code-linting-checks.yaml
Adds cache restore (for non-scheduled events) and cache save (for non-PR runs on main) around lint:cpp-static-check; restores/saves checksums and build/lint-clang-tidy; keeps lint:check command unchanged and documents scheduling/cache semantics.
clang-tidy output dir consolidation
lint-tasks.yaml
Adds vars.G_LINT_CLANG_TIDY_DIR = {{.G_BUILD_DIR}}/lint-clang-tidy and updates cpp-static-check clang-tidy-find tasks to use this directory as OUTPUT_DIR for source, tests, and examples.

Sequence Diagram(s)

sequenceDiagram
  participant Dev as Developer
  participant GH as GitHub Actions
  participant Cache as Actions Cache
  participant Lint as lint:cpp-static-check
  Dev->>GH: Push / PR / Schedule
  GH->>Cache: Restore cache (if event != schedule)
  Cache-->>GH: Returns cached artefacts/checksums (or miss)
  GH->>Lint: Run lint tasks (uses G_LINT_CLANG_TIDY_DIR for outputs)
  Lint-->>GH: Lint results and generated outputs
  GH->>Cache: Save cache (if event != pull_request && ref == refs/heads/main)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Suggested reviewers

  • davidlion

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 4cea0a4 and b866100.

📒 Files selected for processing (1)
  • lint-tasks.yaml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • lint-tasks.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)
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

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

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🔭 Outside diff range comments (1)
.github/workflows/code-linting-checks.yaml (1)

69-81: Fix: save step can fail on scheduled runs (empty key) and on cache hits (“already exists”).

  • On schedule, the restore step is skipped, so steps.cache-restore-lint-cpp-static-check.outputs.cache-primary-key is empty; save will error (“Input required and not supplied: key”).
  • With a constant key, save will also fail when the cache already exists (“Cache already exists”). Only save on cache misses and also skip on schedule.

Apply this diff to harden the save conditions and avoid empty key usage:

-      - if: "'pull_request' != github.event_name && 'refs/heads/main' == github.ref"
+      - if: >
+          'pull_request' != github.event_name
+          && 'schedule' != github.event_name
+          && 'refs/heads/main' == github.ref
+          && steps.cache-restore-lint-cpp-static-check.outputs.cache-hit != 'true'
         name: "Update lint:cpp-static-check cache"
         uses: "actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684"
         with:
           path: |
             .task/checksum/lint-cpp-static-check
             .task/checksum/utils-cpp-lint-clang-tidy-*
             build/lint-clang-tidy
-          key: "${{steps.cache-restore-lint-cpp-static-check.outputs.cache-primary-key}}"
+          key: "${{ steps.cache-restore-lint-cpp-static-check.outputs.cache-primary-key }}"

This ensures:

  • Save doesn’t run on schedule (no restore → no key).
  • Save is skipped when the cache already exists (cache-hit == 'true'), avoiding “already exists” failures.
🧹 Nitpick comments (1)
.github/workflows/code-linting-checks.yaml (1)

54-66: Restore step is fine; consider optional restore-keys for forward-compatibility.

Current restore logic and constant key meet the PR’s objective. If you later want smoother rotations, you could add restore-keys with a prefix (e.g., main-branch-ubuntu-latest-), but that’s optional given your fixed-key strategy.

Example (optional):

       uses: "actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684"
       with:
         path: |
           .task/checksum/lint-cpp-static-check
           .task/checksum/utils-cpp-lint-clang-tidy-*
           build/lint-clang-tidy
         key: "main-branch-ubuntu-latest-lint:cpp-static-check"
+        restore-keys: |
+          main-branch-ubuntu-latest-
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 90595e5 and 4cea0a4.

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

6-6: Good addition: centralised clang-tidy output directory.

Introducing G_LINT_CLANG_TIDY_DIR keeps clang-tidy artefacts predictable and aligns with the cache path in the workflow.


92-103: OUTPUT_DIR wiring matches the new cache directory; verify multi-run merge behaviour.

Pointing clang-tidy-find to a shared OUTPUT_DIR is fine for caching. Please confirm the utils task appends/merges outputs rather than overwriting when invoked multiple times for different ROOT_PATHS, to avoid losing the first run’s results.

If overwriting is possible, consider namespacing per invocation (e.g., subdirs per compile DB) or adjusting the utils task to aggregate.


104-113: Consistent OUTPUT_DIR across both clang-tidy-find calls looks correct.

This keeps all artefacts under build/lint-clang-tidy, matching the workflow cache configuration.

sitaowang1998
sitaowang1998 previously approved these changes Aug 14, 2025
@LinZhihao-723

Copy link
Copy Markdown
Member Author

Just found out a bug in the clang-tidy lint task. G_LINT_CLANG_TIDY_DIR is never set but used as input to clant-tidy-find task, so the clang-tidy-find task just uses the default value $ROOT/lint-clang-tidy. @LinZhihao-723 Could you kindly fix this bug in this PR by defining it in lint-tasks.yaml to set it to {{.G_BUILD_DIR}}/lint-clang-tidy to match the path in GitHub workflow?

I think I already did, unless u're suggesting another issue.

Comment thread lint-tasks.yaml Outdated
Co-authored-by: kirkrodrigues <2454684+kirkrodrigues@users.noreply.github.com>
@LinZhihao-723
LinZhihao-723 merged commit 759c276 into y-scope:main Aug 15, 2025
5 checks passed
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.

3 participants