Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Setup pnpm
uses: pnpm/action-setup@v3
- name: Set node version
uses: actions/setup-node@v3
uses: actions/setup-node@v5
Copy link

Choose a reason for hiding this comment

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

The upgrade to actions/setup-node@v5 enables automatic package manager caching, but the workflow still has manual caching steps that will conflict with the new automatic caching.

View Details
📝 Patch Details
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 3858b42..2e16082 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -17,14 +17,7 @@ jobs:
         with:
           cache: 'pnpm'
           node-version: '20'
-      - name: Cache node_modules
-        id: node-modules-cache
-        uses: actions/cache@v4
-        with:
-          path: '**/node_modules'
-          key: node-modules-cache-${{ hashFiles('**/pnpm-lock.yaml') }}
       - name: Install dependencies
-        if: steps.node-modules-cache.outputs.cache-hit != 'true'
         run: pnpm install
       - name: Run tests
         run: pnpm test

Analysis

Caching Conflict in GitHub Actions Workflow

Issue Summary

The GitHub Actions workflow in .github/workflows/test.yml contains a caching configuration that creates redundancy and potential conflicts due to the upgrade to actions/setup-node@v5. This version introduced automatic package manager caching that overlaps with the existing manual caching implementation.

Root Cause Analysis

Automatic Caching in setup-node@v5

The v5.0.0 release of actions/setup-node introduced a breaking change: automatic caching when a valid packageManager field is present in package.json. This project's package.json contains:

{
  "packageManager": "[email protected]"
}

Current Workflow Configuration Issues

The workflow currently employs a dual caching approach:

  1. Automatic caching (line 18): cache: 'pnpm' parameter in setup-node@v5
  2. Manual caching (lines 20-27): Explicit actions/cache@v4 step with conditional install logic

This creates several problems:

  1. Redundant operations: Both caching mechanisms target dependency management for the same package manager
  2. Cache key conflicts: Different caching strategies may use incompatible cache keys
  3. Workflow logic issues: The conditional install step (if: steps.node-modules-cache.outputs.cache-hit != 'true') assumes manual cache control, but automatic caching may interfere with this logic
  4. Resource waste: Unnecessary CI time spent on duplicate caching operations

Technical Details

Setup-node@v5 Caching Behavior

According to the action specification, setup-node@v5 includes:

  • package-manager-cache: Defaults to true, enables automatic caching when packageManager field is detected
  • cache: Specifies package manager for built-in caching functionality
  • Uses actions/cache internally with optimized cache keys

The automatic caching targets package manager stores (like pnpm store), while the manual caching targets node_modules directories. However, both affect the same dependency installation process.

Impact Assessment

Performance Impact

  • Increased CI time: Redundant cache operations add overhead
  • Cache storage usage: Multiple cache entries for the same dependencies
  • Network overhead: Potential for unnecessary cache uploads/downloads

Reliability Impact

  • Unpredictable behavior: Conditional logic may not work as expected with automatic caching
  • Cache invalidation issues: Different caching strategies may have different invalidation triggers

Recommended Solution

Choose one of two approaches:

Option 1: Use Automatic Caching (Recommended)

Remove manual caching and rely on setup-node@v5's built-in functionality:

- name: Set node version
  uses: actions/setup-node@v5
  with:
    cache: 'pnpm'
    node-version: '20'
- name: Install dependencies
  run: pnpm install

Option 2: Disable Automatic Caching

Keep manual caching and disable the automatic behavior:

- name: Set node version
  uses: actions/setup-node@v5
  with:
    package-manager-cache: false
    node-version: '20'

The automatic caching approach (Option 1) is recommended as it's simpler, maintained by GitHub, and optimized for the detected package manager.

References

with:
cache: 'pnpm'
node-version: '20'
Expand Down
Loading