From 8974c002658e2c68cd37ab7adafa3a3927ce6c70 Mon Sep 17 00:00:00 2001 From: Fabrice Normandin Date: Tue, 28 May 2024 09:51:06 -0400 Subject: [PATCH] Run unit tests on the Windows Subsystem for Linux Signed-off-by: Fabrice Normandin --- .github/workflows/build.yml | 57 ++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e8b5b4a0..1cf7290a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -83,9 +83,64 @@ jobs: name: coverage-reports-unit-${{ matrix.platform }}-${{ matrix.python-version }} path: ./coverage.xml + unit-tests-wsl: + name: Run unit tests on the Windows Subsystem for Linux + needs: [linting] + strategy: + matrix: + python-version: ['3.8', '3.9', '3.10', '3.11'] + runs-on: windows-latest + defaults: + run: + shell: wsl-bash {0} + steps: + - uses: Vampire/setup-wsl@v3 + with: + distribution: Ubuntu-22.04 + - uses: actions/checkout@v4 + # - uses: Ubuntu/WSL/.github/actions/wsl-checkout@main #? + - name: Install poetry + run: pip install poetry + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + cache: 'poetry' + + - name: Install poetry (only on MacOS) + if: runner.os == 'macOS' + run: pip install poetry + + - name: Install dependencies + run: poetry install --with=dev + + - name: Setup passwordless SSH access to localhost for tests + # Adapted from https://stackoverflow.com/a/60367309/6388696 + run: | + ssh-keygen -t ed25519 -f ~/.ssh/testkey -N '' + cat > ~/.ssh/config < ~/.ssh/authorized_keys + chmod og-rw ~ + ssh -o 'StrictHostKeyChecking no' localhost id + + - name: Test with pytest + run: poetry run pytest --cov=milatools --cov-report=xml --cov-append + + - name: Store coverage report as an artifact + uses: actions/upload-artifact@v4 + with: + name: coverage-reports-unit-WSL-${{ matrix.python-version }} + path: ./coverage.xml + + mock-slurm-integration-tests: name: integration tests with a mock slurm cluster - needs: [unit-tests] + needs: [unit-tests, unit-tests-wsl] runs-on: ${{ matrix.platform }} strategy: