Skip to content

fix(setup/yarn): replace deprecated save-always with cache/restore + cache/save #32

@james-gre

Description

@james-gre

Problem

The setup/yarn action uses save-always: true on actions/cache, which has been deprecated (see actions/cache#1315). This produces deprecation warnings in CI logs.

Proposed Fix

Replace the single actions/cache step with the explicit two-step pattern recommended by the actions/cache maintainers:

  1. actions/cache/restore — restores cached node_modules at the start
  2. actions/cache/save with if: always() — saves the cache even on failure (equivalent behavior to save-always: true)

Diff summary (setup/yarn/action.yml)

-    - name: Restore node_modules
-      uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb #v5.0.1
+    - name: Restore cached node_modules
+      uses: actions/cache/restore@9255dc7a253b0ccc959486e2bca901246202afeb #v5.0.1
+      with:
+        path: |
+          node_modules
+          src/node_modules
+        key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock', 'src/yarn.lock') }}
+    - name: Save node_modules cache
+      uses: actions/cache/save@9255dc7a253b0ccc959486e2bca901246202afeb #v5.0.1
+      if: always()
       with:
-        save-always: true
         path: |
           node_modules
           src/node_modules
         key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock', 'src/yarn.lock') }}
-        # we faced issues with restoring on partial matches because yarn classic doesn't cleanup properly on install, don't uncomment
-        # restore-keys: ${{ runner.os }}-yarn-
  • Same pin: @9255dc7a253b0ccc959486e2bca901246202afeb (v5.0.1)
  • Preserves the "always save" behavior without the deprecated parameter
  • Removes the stale restore-keys comment (intentionally disabled per prior decision)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions