Skip to content

Commit 7ac5203

Browse files
committed
feat(github-actions): setup common action for WSL CI setup
This will allow us to re-use this code in various jobs of the Angular CLI repository, without having to duplicate logic.
1 parent 2667d13 commit 7ac5203

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: 'Setup WSL'
2+
description: 'Sets up WSL for the current Windows VM'
3+
author: 'Angular'
4+
5+
outputs:
6+
cmd_path:
7+
description: WSL unix path pointing to `cmd.exe` of the host system.
8+
value: ${{steps.wsl_paths.outputs.cmd_path}}
9+
npm_path:
10+
description: WSL unix path pointing to `npm` of the host system.
11+
value: ${{steps.wsl_paths.outputs.npm_path}}
12+
git_path:
13+
description: WSL unix path pointing to `git` of the host system.
14+
value: ${{steps.wsl_paths.outputs.git_path}}
15+
tmp_dir:
16+
description: WSL unix path pointing to the temporary directory in the host system.
17+
value: ${{steps.wsl_paths.outputs.tmp_dir}}
18+
19+
runs:
20+
using: composite
21+
steps:
22+
# Git checkout converts to CRLF by default. This causes the Aspect lock
23+
# files to differ. See: https://github.com/actions/checkout/issues/135.
24+
- run: |
25+
git config --system core.autocrlf false
26+
git config --system core.eol lf
27+
28+
# Configure the WSL VM.
29+
- uses: Vampire/setup-wsl@v4
30+
with:
31+
wsl-conf: |
32+
[interop]
33+
appendWindowsPath=false
34+
[wsl2]
35+
firewall=false
36+
localhostForwarding=false
37+
wsl-shell-command: bash --login -euo pipefail
38+
additional-packages: |
39+
curl
40+
ca-certificates
41+
g++
42+
unzip
43+
zip
44+
git
45+
python3
46+
tar
47+
48+
- name: Determining paths for common WSL usage (e.g. path to cmd, npm, git)
49+
id: wsl_paths
50+
run: |
51+
cmd_path=$(which cmd.exe)
52+
cmd_wsl_path=$(wsl exec wslpath -u $cmd_path)
53+
npm_path=$(which npm)
54+
npm_wls_path=$(wsl exec wslpath -u "$npm_path")
55+
tmp_dir_wsl_path=$(wsl exec wslpath -u "/tmp")
56+
57+
git_bin=$(which git)
58+
git_bin_wsl_path=$(wsl exec wslpath -u "$git_bin")
59+
60+
echo "cmd_path=$cmd_wsl_path" >> $GITHUB_OUTPUT
61+
echo "npm_path=$npm_wls_path" >> $GITHUB_OUTPUT
62+
echo "tmp_path=$tmp_dir_wsl_path" >> $GITHUB_OUTPUT
63+
echo "git_path=$git_bin_wsl_path" >> $GITHUB_OUTPUT
64+
65+
- name: Disable WSL <> Host virtual network firewall (to allow for testing)
66+
shell: powershell
67+
run: Set-NetFirewallProfile -Profile Public -DisabledInterfaceAliases "vEthernet (WSL)"
68+
69+
- name: Setup nvm
70+
shell: wsl-bash {0}
71+
run: |
72+
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash
73+
export NVM_DIR="$HOME/.nvm"
74+
# Note: Specify `--install` due to https://github.com/nvm-sh/nvm/issues/1985.
75+
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" --install
76+
- run: nvm install
77+
shell: wsl-bash {0}

0 commit comments

Comments
 (0)