Skip to content

Commit 0faa2db

Browse files
committed
Manually run things in WSL shell
1 parent f213f41 commit 0faa2db

1 file changed

Lines changed: 52 additions & 27 deletions

File tree

.github/workflows/pr-setup-wsl-tests.yml

Lines changed: 52 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ jobs:
2020
- windows-2022
2121
defaults:
2222
run:
23-
shell: wsl bash --noprofile --norc -euo pipefail "$(script="$(wslpath '{0}')" && sed -i 's/\r$//' "$script" && echo "$script")"
23+
# Actions passes commands as a script with windows line endings, so we need to convert them to unix line endings
24+
shell: wsl.exe bash --noprofile --norc -euo pipefail -c "touch ~/.env && source ~/.env; GITHUB_TOKEN=${{ github.token }} RUNNER_DEBUG=${{ env.RUNNER_DEBUG }} exec $(script="$(wslpath '{0}')" && sed -i 's/\r$//' "$script" && echo "$script")"
25+
2426
steps:
25-
- name: Install Ubuntu in WSL2
27+
- name: Install Ubuntu for WSL2
2628
shell: pwsh
2729
run: |
2830
# Manually download and install Ubuntu to avoid the reboot that kills the Actions runner
@@ -32,44 +34,67 @@ jobs:
3234
$distributionInfo = Invoke-RestMethod -Uri 'https://raw.githubusercontent.com/microsoft/WSL/refs/heads/master/distributions/DistributionInfo.json'
3335
$downloadUrl = $distributionInfo.Distributions.Where({ $_.Name -eq 'Ubuntu' }).Amd64PackageUrl
3436
$filename = [System.IO.Path]::GetFileName($downloadUrl)
35-
Write-Output 'Installing Ubuntu...'
37+
Write-Output 'Installing Ubuntu for WSL2...'
3638
Set-Location $env:TEMP
3739
Invoke-WebRequest -Uri $downloadUrl -OutFile $filename
3840
Expand-Archive -Path $filename -DestinationPath .\
3941
.\ubuntu.exe install --root
42+
- name: Setup Ubuntu Shell Environment
43+
shell: wsl.exe bash -c "cat '{0}' > ~/.env"
44+
run: |
45+
export CI=true
46+
export GITHUB_ACTIONS=true
47+
export GITHUB_WORKSPACE=$(wslpath -a "${{ github.workspace }}")
48+
export RUNNER_OS=Linux
49+
export RUNNER_TEMP=$(wslpath -a "${{ runner.temp }}")
50+
export RUNNER_TOOL_CACHE=$(wslpath -a "${{ runner.tool_cache }}")
4051
- name: Checkout code
41-
uses: actions/checkout@v4
52+
run: |
53+
git clone --depth 1 --single-branch https://github.com/${{ github.repository }}.git .
54+
git fetch --depth 1 origin ${{ github.sha }}
55+
git checkout ${{ github.sha }}
4256
- name: Install node ${{ matrix.node-version }}
43-
uses: actions/setup-node@v4
44-
with:
45-
node-version: ${{ matrix.node-version }}
46-
registry-url: https://registry.npmjs.org
47-
cache: npm
57+
run: |
58+
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
59+
echo 'export NVM_DIR="$HOME/.nvm"' >> ~/.env
60+
echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> ~/.env
61+
source ~/.env
62+
nvm install ${{ matrix.node-version }}
4863
- name: Bundle Deps
49-
uses: lando/prepare-release-action@v3
50-
with:
51-
lando-plugin: true
52-
version: dev
53-
sync: false
64+
run: |
65+
mkdir -p ~/prepare-release-action
66+
git clone --depth 1 https://github.com/lando/prepare-release-action.git ~/prepare-release-action
67+
cd ~/prepare-release-action
68+
export INPUT_PLUGIN=true
69+
export INPUT_VERSION=dev
70+
export INPUT_SYNC=false
71+
node dist/index.js
5472
- name: Install pkg dependencies
5573
run: npm clean-install --prefer-offline --frozen-lockfile --production
5674
- name: Package into node binary
57-
uses: lando/pkg-action@v5
5875
id: pkg-action
59-
with:
60-
entrypoint: bin/lando
61-
node-version: ${{ matrix.node-version }}
62-
options: --options dns-result-order=ipv4first
63-
upload: false
64-
pkg: "@yao-pkg/pkg@5.16.1"
76+
run: |
77+
npm install -g @yao-pkg/pkg@5.16.1
78+
pkg bin/lando --target node${{ matrix.node-version }}-linux-x64 --options dns-result-order=ipv4first --output lando
79+
echo "PKG_OUTPUT=lando" >> ${{ github.env }}
6580
- name: Install full deps
6681
run: npm clean-install --prefer-offline --frozen-lockfile
6782
- name: Setup lando ${{ steps.pkg-action.outputs.file }}
68-
uses: lando/setup-lando@v3
69-
with:
70-
auto-setup: false
71-
lando-version: ${{ steps.pkg-action.outputs.file }}
72-
telemetry: false
83+
run: |
84+
mkdir -p ~/setup-lando
85+
git clone --depth 1 https://github.com/lando/setup-lando.git ~/setup-lando
86+
cd ~/setup-lando
87+
export INPUT_AUTO_SETUP=false
88+
export INPUT_LANDO_VERSION="${{ steps.pkg-action.outputs.file }}"
89+
export INPUT_TELEMETRY=false
90+
node dist/index.js
7391
- name: Run Leia Tests
7492
run: |
75-
npx leia "examples/${{ matrix.leia-test }}/README.md" -c 'Destroy tests' --stdin --debug
93+
mkdir -p ~/run-leia-action
94+
git clone --depth 1 https://github.com/lando/run-leia-action.git ~/run-leia-action
95+
cd ~/run-leia-action
96+
export INPUT_LEIA_TEST="./examples/${{ matrix.leia-test }}/README.md"
97+
export INPUT_CLEANUP_HEADER="Destroy tests"
98+
export INPUT_SHELL="bash"
99+
export INPUT_STDIN=true
100+
node dist/index.js

0 commit comments

Comments
 (0)