Skip to content

Commit e00c1ff

Browse files
committed
fix(github-actions): speed up builds inside WSL by leveraging virtual FS
Instead of building from inside WSL but referencing the host windows file system (which is known slowness gotcha), we should build fully inside the WSL environment.
1 parent 0f920f4 commit e00c1ff

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

github-actions/setup-wsl/action.yml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ outputs:
3535
wsl_root_unc_path:
3636
description: UNC Windows path pointing to the WSL file system root.
3737
value: \\\\wsl.localhost\Debian
38+
repo_path:
39+
description: Path to the copied repository directory
40+
value: ${{steps.disk_path.outputs.repo}}
3841

3942
runs:
4043
using: composite
@@ -91,17 +94,28 @@ runs:
9194
shell: powershell
9295
run: New-Item -ItemType SymbolicLink -Path "C:\wsl_root" -Target "\\wsl.localhost\Debian"
9396

97+
- name: Linking workspace into WSL for fast disk access
98+
shell: wsl-bash {0}
99+
id: disk_path
100+
env:
101+
WSLENV: 'GITHUB_OUTPUT/p'
102+
run: |
103+
mkdir $HOME/repo
104+
cp -R ./* $HOME/repo/
105+
echo "repo=$(wslpath -w $HOME/repo)" >> $GITHUB_OUTPUT
106+
94107
- name: Cache for nvm, yarn profile caches.
95108
uses: actions/cache@v4
96109
with:
97110
path: |
98-
C:\wsl_root\Debian\root\.nvm\versions
99-
C:\wsl_root\Debian\root\.yarn\berry\cache
111+
C:\\wsl_root\\Debian\\root\\.nvm\\versions
112+
C:\\wsl_root\\Debian\\root\\.yarn\\berry\cache
100113
key: "${{ runner.os }}-wsl-cache-v${{inputs.cache_version}}-${{hashFiles('**/.nvmrc')}}-${{hashFiles('**/yarn.lock')}}"
101114
restore-keys: |
102115
${{ runner.os }}-wsl-cache-v${{inputs.cache_version}}-
103116
104117
- name: Setup nvm
118+
working-directory: ${{steps.paths.outputs.repo}}
105119
shell: wsl-bash {0}
106120
run: |
107121
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash
@@ -110,6 +124,8 @@ runs:
110124
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" --install
111125
112126
- run: nvm install
127+
working-directory: ${{steps.paths.outputs.repo}}
113128
shell: wsl-bash {0}
114129
- run: npm install -g yarn@1
130+
working-directory: ${{steps.paths.outputs.repo}}
115131
shell: wsl-bash {0}

0 commit comments

Comments
 (0)