Skip to content

Commit

Permalink
Enable testing using WSL1 (#1843)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea authored Feb 5, 2022
1 parent f35978b commit 3a86d06
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 18 deletions.
26 changes: 21 additions & 5 deletions .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ jobs:
unit:
name: ${{ matrix.name || matrix.tox_env }}
runs-on: ${{ matrix.os }}
defaults:
run:
shell: ${{ matrix.shell || 'bash'}}
strategy:
fail-fast: false
# max-parallel: 5
Expand All @@ -119,6 +122,10 @@ jobs:
- tox_env: py36
os: ubuntu-20.04
python-version: 3.6
- name: py39 (wsl)
tox_env: py39
os: windows-latest
shell: "wsl-bash {0}"
- tox_env: py37
os: ubuntu-20.04
python-version: 3.7
Expand Down Expand Up @@ -146,26 +153,34 @@ jobs:
env:
TOX_PARALLEL_NO_SPINNER: 1
FORCE_COLOR: 1
# vars safe to be passed to wsl:
WSLENV: FORCE_COLOR:TOXENV:TOX_PARALLEL_NO_SPINNER

steps:

- name: Activate WSL1
if: "contains(matrix.shell, 'wsl')"
uses: Vampire/setup-wsl@v1

- name: MacOS workaround for https://github.com/actions/virtual-environments/issues/1187
if: ${{ matrix.os == 'macOS-latest' }}
run: |
sudo sysctl -w net.link.generic.system.hwcksum_tx=0
sudo sysctl -w net.link.generic.system.hwcksum_rx=0
- uses: actions/checkout@v2
with:
fetch-depth: 0 # needed by setuptools-scm

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: >-
Log the currently selected Python
version info (${{ matrix.python-version }})

- name: Run ./tools/test-setup.sh
run: |
python --version --version
which python
./tools/test-setup.sh
# - name: Pip cache
# uses: actions/cache@v1
# with:
Expand Down Expand Up @@ -214,6 +229,7 @@ jobs:
# produce a single .coverage file at repo root
run: coverage combine .tox/.coverage.*
- name: Upload coverage data
if: "runner.os == 'Linux'"
uses: codecov/codecov-action@v1
with:
name: ${{ matrix.tox_env }}
Expand Down
41 changes: 28 additions & 13 deletions tools/test-setup.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,32 @@
#!/bin/bash
set -euxo pipefail
# Used by Zuul CI to perform extra bootstrapping
# This tool is used to setup the environment for running the tests. Its name
# name and location is based on Zuul CI, which can automatically run it.
set -euo pipefail

# sudo used only because currently zuul default tox_executable=tox instead of
# "python3 -m tox"
# https://zuul-ci.org/docs/zuul-jobs/python-roles.html#rolevar-ensure-tox.tox_executable
# User specific environment
# shellcheck disable=SC2076
if ! [[ "$PATH" =~ "$HOME/.local/bin" ]]
then
PATH="$HOME/.local/bin:$PATH"
fi

# Install pip if not already install on the system
python3 -m pip --version || {
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
sudo python3 get-pip.py
}
if [ -f "/usr/bin/apt-get" ]; then
if [ ! -f "/var/cache/apt/pkgcache.bin" ]; then
sudo apt-get update # mandatory or other apt-get commands fail
fi
# avoid outdated ansible and pipx
sudo apt-get remove -y ansible pipx || true
sudo apt-get install -y --no-install-recommends -o=Dpkg::Use-Pty=0 \
git python3-venv python3-pip
fi

# Workaround until ensure-tox will allow upgrades
# https://review.opendev.org/#/c/690057/
sudo python3 -m pip install -U tox
which pipx || python3 -m pip install --user pipx
which -a pipx
which pre-commit || pipx install pre-commit
which tox || pipx install tox

# Log some useful info in case of unexpected failures:
uname
python3 --version
tox --version
pre-commit --version

0 comments on commit 3a86d06

Please sign in to comment.