Skip to content

Conversation

@cmraible
Copy link
Collaborator

@cmraible cmraible commented May 9, 2025

no refs

TL;DR: we run some of our test suites against multiple versions of Node, but they are currently sharing the same caches. Dependencies that are built for one version may not work for the other version, causing flaky behavior in CI. This commit adds the NodeJS version to the cache keys that we use in CI, so that each version will maintain its own cache. This should hopefully reduce flakiness in our CI workflows.

Here's a recent error from comments-ui unit tests that failed this morning:

#
  # Fatal error in , line 0
  # unreachable code
  #
  #
  #
  #FailureMessage Object: 0x7ffef9597580

It's followed by a huge unintelligible (to me) native stack trace, but I'm told that "This is almost certainly caused by loading precompiled code (e.g. cached .node modules or bytecode caches) that were compiled with a different version of Node.js or V8."

This seems to track, as clearing the caches is our go-to for fixing these flaky issues we've been seeing..

@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 9, 2025

Walkthrough

The CI workflow configuration is updated to change how dependency cache keys are generated and used. The cache key is now split into a base key and a full key that includes the Node.js version. All jobs that restore dependency caches are updated to use the new key format, ensuring the Node.js version is part of the key. The automatic Yarn cache in the Node setup step is disabled. The move_coverage_to_trash option is removed from Codecov upload steps. Additionally, the base dependency cache key is now output from the setup job for use in dependent jobs. The cache restore step that previously failed the workflow on cache misses is replaced with a bash script that issues warnings instead, removing failure behavior when caches are not found.


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 25704cf and 63b0122.

📒 Files selected for processing (1)
  • .github/actions/restore-cache/action.yml (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: Admin tests - Chrome
  • GitHub Check: Admin-X Settings tests
  • GitHub Check: Ghost-CLI tests
  • GitHub Check: Regression tests (Node 20.11.1, sqlite3)
  • GitHub Check: Regression tests (Node 20.11.1, mysql8)
  • GitHub Check: Comments-UI tests
  • GitHub Check: Signup-form tests
🔇 Additional comments (1)
.github/actions/restore-cache/action.yml (1)

21-31: ⚠️ Potential issue

Fix Bash syntax error and optionally simplify warning logic

The shell if on line 29 has an extra ] which will cause a syntax error when the build cache is missing:

-        if [ "${{ steps.build-cache.outputs.cache-hit }}" != "true" ]]; then
+        if [ "${{ steps.build-cache.outputs.cache-hit }}" != "true" ]; then

Optional refactor: You can collapse each if…fi pair into a one-liner using [[ … ]] && echo … for brevity:

-        if [ "${{ steps.dep-cache.outputs.cache-hit }}" != "true" ]; then
-          echo "::warning::Dependency cache not found for key: ${{ env.DEPENDENCY_CACHE_KEY }}"
-        fi
-        if [ "${{ steps.build-cache.outputs.cache-hit }}" != "true" ]; then
-          echo "::warning::Build cache not found for key: ${{ github.sha }}"
-        fi
+        [[ "${{ steps.dep-cache.outputs.cache-hit }}" != "true" ]] && echo "::warning::Dependency cache not found for key: ${{ env.DEPENDENCY_CACHE_KEY }}"
+        [[ "${{ steps.build-cache.outputs.cache-hit }}" != "true" ]] && echo "::warning::Build cache not found for key: ${{ github.sha }}"

Likely an incorrect or invalid review 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.
    • Generate unit testing code for this file.
    • 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. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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

Documentation and Community

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

@cmraible cmraible changed the title Added NodeJS version to cache keys Added NodeJS version to GHA cache keys May 9, 2025
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: 2

🧹 Nitpick comments (1)
.github/workflows/ci.yml (1)

148-150: Clarify variable naming and usage in setting full cache key
The step writes to an env var named cachekey, then later outputs it as dependency_cache_key. For clarity and consistency, consider renaming cachekey here to dependency_cache_key and reference $NODE_VERSION in your shell context:

- run: echo "cachekey=${cachekey_base}-node-${{ env.NODE_VERSION }}" >> "$GITHUB_ENV"
+ run: echo "dependency_cache_key=${cachekey_base}-node-${NODE_VERSION}"    >> "$GITHUB_ENV"
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3270d20 and aff9492.

📒 Files selected for processing (1)
  • .github/workflows/ci.yml (5 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: Regression tests (Node 20.11.1, mysql8)
  • GitHub Check: Signup-form tests
  • GitHub Check: Admin tests - Chrome
  • GitHub Check: Ghost-CLI tests
  • GitHub Check: Comments-UI tests
  • GitHub Check: Admin-X Settings tests
🔇 Additional comments (4)
.github/workflows/ci.yml (4)

217-219: Welcome addition of dependency_cache_key_base output
Adding dependency_cache_key_base to the job outputs enables downstream matrix jobs to build version-specific keys. This aligns well with the PR objective.


476-479: Use base cache key in unit-tests matrix
Good update—using dependency_cache_key_base with -node-${{ matrix.node }} dynamically restores the correct cache per Node version.


552-555: Use base cache key in database-tests matrix
Consistent with unit-tests, this correctly restores caches per Node version.


680-684: Use base cache key in regression-tests matrix
Great—you’re now restoring dependency caches with the proper Node version suffix.

Comment on lines 155 to 157
echo "dep-cache-${{ env.hash }}-${{ github.sha }}-node-${{ env.NODE_VERSION }}" >> "$GITHUB_ENV"
echo "dep-cache-${{ env.hash }}-node-${{ env.NODE_VERSION }}" >> "$GITHUB_ENV"
echo "dep-cache-node-${{ env.NODE_VERSION }}" >> "$GITHUB_ENV"
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Restore keys should be derived from computed variables
Right now you rebuild fallback keys with env.hash and hard-coded patterns, which won’t match your generated cachekey_base or dependency_cache_key. Instead, reuse those values:

- echo "dep-cache-${{ env.hash }}-${{ github.sha }}-node-${{ env.NODE_VERSION }}" >> "$GITHUB_ENV"
- echo "dep-cache-${{ env.hash }}-node-${{ env.NODE_VERSION }}"           >> "$GITHUB_ENV"
- echo "dep-cache-node-${{ env.NODE_VERSION }}"                            >> "$GITHUB_ENV"
+ echo "${{ env.dependency_cache_key }}"                                    >> "$GITHUB_ENV"
+ echo "${{ env.cachekey_base }}-node-${{ env.NODE_VERSION }}"              >> "$GITHUB_ENV"
+ echo "${{ env.cachekey_base }}"                                           >> "$GITHUB_ENV"
+ echo "dep-cache-node-${{ env.NODE_VERSION }}"                             >> "$GITHUB_ENV"

This ensures your restore-keys actually line up with the keys you generate.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
echo "dep-cache-${{ env.hash }}-${{ github.sha }}-node-${{ env.NODE_VERSION }}" >> "$GITHUB_ENV"
echo "dep-cache-${{ env.hash }}-node-${{ env.NODE_VERSION }}" >> "$GITHUB_ENV"
echo "dep-cache-node-${{ env.NODE_VERSION }}" >> "$GITHUB_ENV"
echo "${{ env.dependency_cache_key }}" >> "$GITHUB_ENV"
echo "${{ env.cachekey_base }}-node-${{ env.NODE_VERSION }}" >> "$GITHUB_ENV"
echo "${{ env.cachekey_base }}" >> "$GITHUB_ENV"
echo "dep-cache-node-${{ env.NODE_VERSION }}" >> "$GITHUB_ENV"

@daniellockyer
Copy link
Contributor

I'd be surprised if this helped - Node.js provides the Node-API for binary dependencies and this is stable across different Node versions. So binaries built for one Node-API can be run on any Node.js version that supports that Node-API version

Def strange that we're seeing an increase in this recently

Not a blocking comment but just my 2c

Copy link
Collaborator Author

Ah okay that makes sense. I still wonder if the NX cache accounts for all that when caching build outputs 🤔

@cmraible cmraible closed this May 18, 2025
@cmraible cmraible deleted the fix-gha-cache branch May 19, 2025 02:41
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