Skip to content

Commit 0000d92

Browse files
committed
feat(github-actions): add caching to WSL environment
WSL actions don't benefit much from the default setup-node action and caching, so we should have our own caching to speed up jobs and improve stability. This commit adds this functionality.
1 parent 574e509 commit 0000d92

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

github-actions/setup-wsl/action.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ inputs:
1111
description: Networking mode for the WSL config
1212
default: NAT
1313
required: false
14+
cache_version:
15+
description: Version that can be used to invalidate the cache
16+
default: 1
17+
required: false
1418

1519
outputs:
1620
cmd_path:
@@ -87,6 +91,16 @@ runs:
8791
shell: powershell
8892
run: New-Item -ItemType SymbolicLink -Path "C:\wsl_root" -Target "\\wsl.localhost\Debian"
8993

94+
- name: Cache for nvm, yarn profile caches.
95+
uses: actions/cache@v4
96+
with:
97+
path: |
98+
C:\wsl_root\Debian\root\.nvm\versions
99+
C:\wsl_root\Debian\root\.yarn\berry\cache
100+
key: "${{ runner.os }}-wsl-cache-v${{inputs.cache_version}}-${{hashFiles('**/.nvmrc')}}-${{hashFiles('**/yarn.lock')}}"
101+
restore-keys: |
102+
${{ runner.os }}-wsl-cache-v${{inputs.cache_version}}-
103+
90104
- name: Setup nvm
91105
shell: wsl-bash {0}
92106
run: |

0 commit comments

Comments
 (0)