Run tests on github windows runner using WSL
This commit is contained in:
parent
0f5ee86b38
commit
f33e7c2e1f
3 changed files with 63 additions and 35 deletions
86
.github/workflows/test.yml
vendored
86
.github/workflows/test.yml
vendored
|
@ -21,52 +21,68 @@ jobs:
|
||||||
- ubuntu-24.04
|
- ubuntu-24.04
|
||||||
- macos-13
|
- macos-13
|
||||||
- macos-15
|
- macos-15
|
||||||
|
- windows-2022
|
||||||
|
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: bash
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- uses: Vampire/setup-wsl@v4
|
||||||
|
if: ${{ runner.os == 'Windows' }}
|
||||||
|
|
||||||
- name: Install dependencies on Linux
|
- name: Install dependencies on Linux
|
||||||
if: ${{ runner.os == 'Linux' }}
|
if: ${{ runner.os == 'Linux' }}
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y expect
|
sudo apt-get install -y \
|
||||||
if [ "${{ matrix.os }}" != "ubuntu-20.04" ]; then
|
expect \
|
||||||
sudo apt-get install -y j2cli
|
${{ matrix.os != 'ubuntu-20.04' && 'j2cli' || '' }}
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Install dependencies on macOS
|
- name: Install dependencies on macOS
|
||||||
if: ${{ runner.os == 'macOS' }}
|
if: ${{ runner.os == 'macOS' }}
|
||||||
run: |
|
run: |
|
||||||
command -v expect || brew install expect
|
command -v expect || brew install expect
|
||||||
|
|
||||||
|
- name: Install dependencies on Windows (WSL)
|
||||||
|
if: ${{ runner.os == 'Windows' }}
|
||||||
|
shell: wsl-bash {0}
|
||||||
|
run: |
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y --no-install-recommends \
|
||||||
|
dos2unix \
|
||||||
|
expect \
|
||||||
|
gettext-base \
|
||||||
|
git \
|
||||||
|
gnupg \
|
||||||
|
j2cli \
|
||||||
|
lsb-release \
|
||||||
|
man \
|
||||||
|
python3-pip
|
||||||
|
|
||||||
- name: Prepare tools directory
|
- name: Prepare tools directory
|
||||||
run: |
|
run: |
|
||||||
mkdir "$RUNNER_TEMP/tools"
|
mkdir "${{ runner.temp }}/tools"
|
||||||
echo "$RUNNER_TEMP/tools" >> "$GITHUB_PATH"
|
echo "${{ runner.temp }}/tools" >> "${{ github.path }}"
|
||||||
|
|
||||||
- name: Install shellcheck
|
- name: Install shellcheck
|
||||||
run: |
|
run: |
|
||||||
if [ "$RUNNER_OS" = "macOS" ]; then
|
cd "${{ runner.temp }}"
|
||||||
OS=darwin
|
|
||||||
else
|
|
||||||
OS=linux
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$RUNNER_ARCH" = "ARM64" ]; then
|
OS=${{ runner.os == 'macOS' && 'darwin' || 'linux' }}
|
||||||
ARCH=aarch64
|
ARCH=${{ runner.arch == 'ARM64' && 'aarch64' || 'x86_64' }}
|
||||||
else
|
|
||||||
ARCH=x86_64
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd "$RUNNER_TEMP"
|
|
||||||
|
|
||||||
BASE_URL="https://github.com/koalaman/shellcheck/releases/download"
|
BASE_URL="https://github.com/koalaman/shellcheck/releases/download"
|
||||||
SC="v$SC_VER/shellcheck-v$SC_VER.$OS.$ARCH.tar.xz"
|
SC="v$SC_VER/shellcheck-v$SC_VER.$OS.$ARCH.tar.xz"
|
||||||
|
|
||||||
curl -L "$BASE_URL/$SC" | tar Jx shellcheck-v$SC_VER/shellcheck
|
curl -L "$BASE_URL/$SC" | tar Jx shellcheck-v$SC_VER/shellcheck
|
||||||
mv shellcheck-v$SC_VER/shellcheck tools
|
mv shellcheck-v$SC_VER/shellcheck tools
|
||||||
|
|
||||||
- name: Install esh
|
- name: Install esh
|
||||||
run: |
|
run: |
|
||||||
cd "$RUNNER_TEMP/tools"
|
cd "${{ runner.temp }}/tools"
|
||||||
|
|
||||||
BASE_URL="https://github.com/jirutka/esh/raw/refs/tags"
|
BASE_URL="https://github.com/jirutka/esh/raw/refs/tags"
|
||||||
curl -L -o esh "$BASE_URL/v$ESH_VER/esh"
|
curl -L -o esh "$BASE_URL/v$ESH_VER/esh"
|
||||||
|
@ -76,8 +92,9 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
for version in 1.12.0 2.5.0; do
|
for version in 1.12.0 2.5.0; do
|
||||||
git fetch origin $version:refs/tags/$version
|
git fetch origin $version:refs/tags/$version
|
||||||
git cat-file blob $version:yadm > "$RUNNER_TEMP/tools/yadm-$version"
|
git cat-file blob $version:yadm \
|
||||||
chmod +x "$RUNNER_TEMP/tools/yadm-$version"
|
> "${{ runner.temp }}/tools/yadm-$version"
|
||||||
|
chmod +x "${{ runner.temp }}/tools/yadm-$version"
|
||||||
done
|
done
|
||||||
|
|
||||||
- name: Set up Python 3.11
|
- name: Set up Python 3.11
|
||||||
|
@ -86,13 +103,26 @@ jobs:
|
||||||
with:
|
with:
|
||||||
python-version: 3.11
|
python-version: 3.11
|
||||||
|
|
||||||
- name: Install Python dependencies
|
- name: Install dependencies and run tests (Linux/macOS)
|
||||||
run: |
|
if: ${{ runner.os != 'Windows' }}
|
||||||
python -m pip install --upgrade pip
|
|
||||||
python -m pip install -r test/requirements.txt
|
|
||||||
|
|
||||||
- name: Run tests
|
|
||||||
run: |
|
run: |
|
||||||
git config --global user.email test@yadm.io
|
git config --global user.email test@yadm.io
|
||||||
git config --global user.name "Yadm Test"
|
git config --global user.name "Yadm Test"
|
||||||
pytest -v --color=yes --basetemp="$RUNNER_TEMP/pytest"
|
|
||||||
|
python3 -m pip install --upgrade pip
|
||||||
|
python3 -m pip install -r test/requirements.txt
|
||||||
|
pytest -v --color=yes --basetemp="${{ runner.temp }}/pytest"
|
||||||
|
|
||||||
|
- name: Install dependencies and run tests (WSL)
|
||||||
|
if: ${{ runner.os == 'Windows' }}
|
||||||
|
shell: wsl-bash {0}
|
||||||
|
run: |
|
||||||
|
git config --global user.email test@yadm.io
|
||||||
|
git config --global user.name "Yadm Test"
|
||||||
|
|
||||||
|
dos2unix yadm.1 .github/workflows/*.yml test/pinentry-mock
|
||||||
|
chmod +x test/pinentry-mock
|
||||||
|
|
||||||
|
python3 -m pip install --upgrade pip
|
||||||
|
python3 -m pip install -r test/requirements.txt
|
||||||
|
pytest -v --color=yes
|
||||||
|
|
|
@ -102,9 +102,9 @@ def tst_sys():
|
||||||
system = platform.system()
|
system = platform.system()
|
||||||
if system == "Linux":
|
if system == "Linux":
|
||||||
# Additional check for WSL
|
# Additional check for WSL
|
||||||
with open("/proc/version", "r", encoding="utf-8") as f:
|
with open("/proc/version", encoding="utf-8") as f:
|
||||||
if "icrosoft" in f.read():
|
if "icrosoft" in f.read():
|
||||||
return "WSL"
|
system = "WSL"
|
||||||
return system
|
return system
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,8 @@ def test_set_operating_system(runner, paths, tst_sys, proc_value, expected_os):
|
||||||
# Normally /proc/version (set in PROC_VERSION) is inspected to identify
|
# Normally /proc/version (set in PROC_VERSION) is inspected to identify
|
||||||
# WSL. During testing, we will override that value.
|
# WSL. During testing, we will override that value.
|
||||||
proc_version = paths.root.join("proc_version")
|
proc_version = paths.root.join("proc_version")
|
||||||
proc_version.write(proc_value)
|
if proc_value != "missing":
|
||||||
|
proc_version.write(proc_value)
|
||||||
script = f"""
|
script = f"""
|
||||||
YADM_TEST=1 source {paths.pgm}
|
YADM_TEST=1 source {paths.pgm}
|
||||||
PROC_VERSION={proc_version}
|
PROC_VERSION={proc_version}
|
||||||
|
@ -35,8 +36,5 @@ def test_set_operating_system(runner, paths, tst_sys, proc_value, expected_os):
|
||||||
assert run.success
|
assert run.success
|
||||||
assert run.err == ""
|
assert run.err == ""
|
||||||
if expected_os == "uname":
|
if expected_os == "uname":
|
||||||
if tst_sys != "WSL":
|
expected_os = tst_sys if tst_sys != "WSL" else "Linux"
|
||||||
expected_os = tst_sys
|
|
||||||
else:
|
|
||||||
expected_os = "Linux"
|
|
||||||
assert run.out.rstrip() == expected_os
|
assert run.out.rstrip() == expected_os
|
||||||
|
|
Loading…
Reference in a new issue