Skip to content

Commit 335e894

Browse files
committed
Enable testing with wsl
1 parent 389ce0d commit 335e894

2 files changed

Lines changed: 60 additions & 19 deletions

File tree

.github/workflows/test.yml

Lines changed: 57 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,60 @@ on:
1212

1313
jobs:
1414
build:
15-
name: Build
15+
name: ${{ matrix.name || matrix.runs-on }}
1616
env:
17-
ACTIONS_RUNNER_DEBUG: "true"
18-
ACTIONS_STEP_DEBUG: "true"
19-
17+
# ACTIONS_RUNNER_DEBUG: "true"
18+
# ACTIONS_STEP_DEBUG: "true"
19+
# https://docs.github.com/en/actions/learn-github-actions/environment-variables
20+
# https://devblogs.microsoft.com/commandline/share-environment-vars-between-wsl-and-windows/
21+
WSLENV: HOSTNAME:CI:FORCE_COLOR:GITHUB_ACTION:GITHUB_ACTION_PATH/p:GITHUB_ACTION_REPOSITORY:GITHUB_WORKFLOW:GITHUB_WORKSPACE/p:GITHUB_PATH/p:GITHUB_ENV/p:VIRTUAL_ENV/p:SKIP_PODMAN:SKIP_DOCKER:NODE_OPTIONS
22+
# We define a hostname because otherwise the variable might not always be accessible on runners.
23+
HOSTNAME: gha
24+
defaults:
25+
run:
26+
shell: ${{ matrix.shell || 'bash'}}
2027
strategy:
2128
matrix:
22-
runs-on: [ubuntu-24.04, ubuntu-24.04-arm, macos-15, windows-2025]
29+
shell: [bash]
30+
# runs-on: [ubuntu-24.04, ubuntu-24.04-arm, macos-15, windows-2025]
31+
include:
32+
- runs-on: windows-2025
33+
name: wsl
34+
- runs-on: windows-2025
35+
# - runs-on: ubuntu-24.04
36+
# - runs-on: ubuntu-24.04-arm
37+
# - runs-on: macos-15
2338
fail-fast: false
2439

2540
runs-on: ${{ matrix.runs-on }}
2641

2742
steps:
43+
# https://github.com/marketplace/actions/setup-wsl
44+
- name: Activate WSL
45+
if: contains(matrix.name, 'wsl') && (matrix.runs-on || '') != 'self-hosted'
46+
uses: Vampire/setup-wsl@v6.0.0
47+
with:
48+
distribution: Ubuntu-24.04
49+
set-as-default: "true"
50+
# '-i' seems to be the only option that loads .bashrc file that we need
51+
# https://github.com/Vampire/setup-wsl/discussions/54
52+
wsl-shell-command: "bash -i -eo pipefail"
53+
# https://github.com/MicrosoftDocs/WSL/blob/main/WSL/wsl-config.md#L159
54+
wsl-conf: |
55+
[automount]
56+
enabled = true
57+
root = /
58+
options = "metadata,umask=077"
59+
[boot]
60+
command=/etc/init.d/dbus start
61+
[interop]
62+
enabled = false
63+
appendWindowsPath = false
64+
[network]
65+
hostname = wsl
66+
additional-packages: curl
67+
xvfb
68+
# asdf nodejs plugin requires: dirmngr gpg curl gawk
2869

2970
- name: Checkout
3071
uses: actions/checkout@v4
@@ -62,21 +103,21 @@ jobs:
62103
- name: 'Upload artifact #1'
63104
uses: ./
64105
with:
65-
name: 'Artifact-A-${{ matrix.runs-on }}'
106+
name: 'Artifact-A-${{ github.job }}'
66107
path: path/to/dir-1/file1.txt
67108

68109
# Upload using a wildcard pattern
69110
- name: 'Upload artifact #2'
70111
uses: ./
71112
with:
72-
name: 'Artifact-Wildcard-${{ matrix.runs-on }}'
113+
name: 'Artifact-Wildcard-${{ github.job }}'
73114
path: path/**/dir*/
74115

75116
# Upload a multi-path artifact
76117
- name: 'Upload artifact #3'
77118
uses: ./
78119
with:
79-
name: 'Multi-Path-Artifact-${{ matrix.runs-on }}'
120+
name: 'Multi-Path-Artifact-${{ github.job }}'
80121
path: |
81122
path/to/dir-1/*
82123
path/to/dir-[23]/*
@@ -85,7 +126,7 @@ jobs:
85126
- name: 'Upload symlinked artifact'
86127
uses: ./
87128
with:
88-
name: 'Symlinked-Artifact-${{ matrix.runs-on }}'
129+
name: 'Symlinked-Artifact-${{ github.job }}'
89130
path: |
90131
symlink/abs.txt
91132
symlink/rel.txt
@@ -94,7 +135,7 @@ jobs:
94135
- name: 'Download artifact #1'
95136
uses: actions/download-artifact@v4
96137
with:
97-
name: 'Artifact-A-${{ matrix.runs-on }}'
138+
name: 'Artifact-A-${{ github.job }}'
98139
path: some/new/path
99140

100141
- name: 'Verify Artifact #1'
@@ -114,7 +155,7 @@ jobs:
114155
- name: 'Download artifact #2'
115156
uses: actions/download-artifact@v4
116157
with:
117-
name: 'Artifact-Wildcard-${{ matrix.runs-on }}'
158+
name: 'Artifact-Wildcard-${{ github.job }}'
118159
path: some/other/path
119160

120161
- name: 'Verify Artifact #2'
@@ -135,7 +176,7 @@ jobs:
135176
- name: 'Download artifact #3'
136177
uses: actions/download-artifact@v4
137178
with:
138-
name: 'Artifact-Wildcard-${{ matrix.runs-on }}'
179+
name: 'Artifact-Wildcard-${{ github.job }}'
139180
path: verify-artifact-3
140181

141182
- name: 'Verify Artifact #3'
@@ -156,7 +197,7 @@ jobs:
156197
- name: 'Download artifact #4'
157198
uses: actions/download-artifact@v4
158199
with:
159-
name: 'Multi-Path-Artifact-${{ matrix.runs-on }}'
200+
name: 'Multi-Path-Artifact-${{ github.job }}'
160201
path: multi/artifact
161202

162203
- name: 'Verify Artifact #4'
@@ -176,7 +217,7 @@ jobs:
176217
- name: 'Download symlinked artifact'
177218
uses: actions/download-artifact@v4
178219
with:
179-
name: 'Symlinked-Artifact-${{ matrix.runs-on }}'
220+
name: 'Symlinked-Artifact-${{ github.job }}'
180221
path: from/symlink
181222

182223
- name: 'Verify symlinked artifact'
@@ -209,15 +250,15 @@ jobs:
209250
- name: 'Overwrite artifact #1'
210251
uses: ./
211252
with:
212-
name: 'Artifact-A-${{ matrix.runs-on }}'
253+
name: 'Artifact-A-${{ github.job }}'
213254
path: path/to/dir-1/file1.txt
214255
overwrite: true
215256

216257
# Download replaced Artifact #1 and verify the correctness of the content
217258
- name: 'Download artifact #1 again'
218259
uses: actions/download-artifact@v4
219260
with:
220-
name: 'Artifact-A-${{ matrix.runs-on }}'
261+
name: 'Artifact-A-${{ github.job }}'
221262
path: overwrite/some/new/path
222263

223264
- name: 'Verify Artifact #1 again'

action.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,13 @@ runs:
9494
prefix=~/.local/bin
9595
chmod +x $prefix/gitleaks
9696
gitleaks --version
97-
shell: bash
97+
# shell: bash
9898

9999
- name: Ensure gitleaks
100100
if: steps.cache_gitleaks.outputs.cache-hit != 'true'
101101
# && runner.os == 'Linux'
102102
id: gitleaks
103-
shell: bash
103+
# shell: bash
104104
run: ${GITHUB_ACTION_PATH}/scripts/ensure-gitleaks.sh
105105
env:
106106
DEBUG: ${{ runner.debug == '1' }}
@@ -119,7 +119,7 @@ runs:
119119
env:
120120
INPUT_PATH: ${{ inputs.path }}
121121
DEBUG: ${{ runner.debug == '1' }}
122-
shell: bash
122+
# shell: bash
123123

124124
- name: Upload safe artifact using original actions/upload-artifact
125125
uses: actions/upload-artifact@v4

0 commit comments

Comments
 (0)