Move GHA to setup-micromamba (#2545)

* Move to setup-micromamba

* Try init-shell

* Activate env in umamba_tests_win_cmd

* Add test_run failure output

* Try pwsh

* Use TEST_MAMBA_EXE in test_run.sh

* Unset CONDARC

* Remove more CONDARC

* Remove unecessary cleanup in main CI

* Flexible Pytest deletion

* Remove explicit activation
This commit is contained in:
Antoine Prouvost 2023-06-15 18:20:10 +02:00 committed by GitHub
parent ec95d18986
commit 7b0b9a5aeb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 109 additions and 165 deletions

View File

@ -21,11 +21,11 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: create build environment
uses: mamba-org/provision-with-micromamba@main
uses: mamba-org/setup-micromamba@v1
with:
environment-file: ./libmamba/environment-static-dev.yml
environment-name: build_env
cache-env: true
cache-environment: true
- uses: hendrikmuhs/ccache-action@main
with:
variant: sccache
@ -33,7 +33,6 @@ jobs:
- name: build libmamba-static
shell: bash -l {0}
run: |
micromamba activate build_env
mkdir build
cd build
cmake .. -DBUILD_LIBMAMBA=ON \
@ -44,12 +43,6 @@ jobs:
ninja
- name: build cache statistics
run: sccache --show-stats
- name: Cleanup
shell: bash
if: always()
run: |
# Do not cache temporary envs with 'cache-env: true'
rm -rf ~/micromamba*/envs/*/envs
libmamba_cpp_tests:
needs: [libmamba_static]
@ -59,40 +52,36 @@ jobs:
os: [ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v3
- name: create build environment
uses: mamba-org/provision-with-micromamba@main
- name: Create build environment
uses: mamba-org/setup-micromamba@v1
with:
environment-file: ./libmamba/environment-dev.yml
environment-name: build_env
cache-env: true
cache-environment: true
- uses: hendrikmuhs/ccache-action@main
with:
variant: sccache
key: ${{ github.job }}-${{ matrix.os }}
restore-keys: |
libmamba_static-${{ matrix.os }}
- name: build and run libmamba C++ tests
- name: Build libmamba
shell: bash -l {0}
run: |
micromamba activate build_env
mkdir build
cd build
cmake .. -DBUILD_LIBMAMBA=ON \
-DBUILD_SHARED=ON \
-DBUILD_LIBMAMBA_TESTS=ON \
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache \
-DCMAKE_C_COMPILER_LAUNCHER=sccache \
-GNinja
ninja testing_libmamba_lock
ninja test
cmake -B build/ \
-D BUILD_LIBMAMBA=ON \
-D BUILD_SHARED=ON \
-D BUILD_LIBMAMBA_TESTS=ON \
-D CMAKE_CXX_COMPILER_LAUNCHER=sccache \
-D CMAKE_C_COMPILER_LAUNCHER=sccache \
-G Ninja
cmake --build build/ --parallel --target test_libmamba testing_libmamba_lock
- name: Run libmamba tests
shell: bash -l {0}
run: |
unset CONDARC # Interferes with tests
cd build && ninja test
- name: build cache statistics
run: sccache --show-stats
- name: Cleanup
shell: bash
if: always()
run: |
# Do not cache temporary envs with 'cache-env: true'
rm -rf ~/micromamba*/envs/*/envs
umamba_tests:
needs: [libmamba_static]
@ -103,11 +92,11 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: create build environment
uses: mamba-org/provision-with-micromamba@main
uses: mamba-org/setup-micromamba@v1
with:
environment-file: ./micromamba/environment-dev.yml
environment-name: build_env
cache-env: true
cache-environment: true
- uses: hendrikmuhs/ccache-action@main
with:
variant: sccache
@ -117,17 +106,15 @@ jobs:
- name: build micromamba
shell: bash -l {0}
run: |
micromamba activate build_env
mkdir build
cd build
cmake .. -DBUILD_MICROMAMBA=ON \
-DBUILD_MICROMAMBA_SERVER=ON \
-DBUILD_LIBMAMBA=ON \
-DBUILD_SHARED=ON \
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache \
-DCMAKE_C_COMPILER_LAUNCHER=sccache \
-GNinja
ninja
cmake -B build/ \
-D BUILD_MICROMAMBA=ON \
-D BUILD_MICROMAMBA_SERVER=ON \
-D BUILD_LIBMAMBA=ON \
-D BUILD_SHARED=ON \
-D CMAKE_CXX_COMPILER_LAUNCHER=sccache \
-D CMAKE_C_COMPILER_LAUNCHER=sccache \
-G Ninja
cmake --build build/ --parallel
- name: build cache statistics
run: sccache --show-stats
- name: install zsh, xonsh, fish and tcsh in linux
@ -144,14 +131,8 @@ jobs:
shell: bash -l -eo pipefail {0}
run: |
export TEST_MAMBA_EXE=$(pwd)/build/micromamba/micromamba
micromamba activate build_env
unset CONDARC # Interferes with tests
pytest -v --capture=tee-sys micromamba/tests/
- name: Cleanup
shell: bash
if: always()
run: |
# Do not cache temporary envs with 'cache-env: true'
rm -rf ~/micromamba*/envs/*/envs
mamba_python_tests:
needs: [libmamba_static]
@ -164,12 +145,12 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: create build environment
uses: mamba-org/provision-with-micromamba@main
uses: mamba-org/setup-micromamba@v1
with:
environment-file: ./mamba/environment-dev.yml
environment-name: build_env
cache-env: true
extra-specs: |
cache-environment: true
create-args: >-
conda-build
python=${{ matrix.python_version }}
- uses: hendrikmuhs/ccache-action@main
@ -184,24 +165,22 @@ jobs:
- name: build libmamba Python bindings
shell: bash -l {0}
run: |
micromamba activate build_env
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX \
-DBUILD_LIBMAMBAPY=ON \
-DBUILD_LIBMAMBA=ON \
-DBUILD_SHARED=ON \
-DBUILD_MAMBA_PACKAGE=ON \
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache \
-DCMAKE_C_COMPILER_LAUNCHER=sccache \
-GNinja
ninja
ninja install
cmake -B build/ \
-D CMAKE_INSTALL_PREFIX="${CONDA_PREFIX}" \
-D BUILD_LIBMAMBAPY=ON \
-D BUILD_LIBMAMBA=ON \
-D BUILD_MICROMAMBA=ON \
-D BUILD_SHARED=ON \
-D BUILD_MAMBA_PACKAGE=ON \
-D CMAKE_CXX_COMPILER_LAUNCHER=sccache \
-D CMAKE_C_COMPILER_LAUNCHER=sccache \
-G Ninja
cmake --build build/ --parallel
cmake --install build/
- name: install libmambapy
shell: bash -l {0}
run: |
micromamba activate build_env
pip install -e ./libmambapy/ --no-deps
python -m pip install --no-deps --no-build-isolation --editable ./libmambapy/
- name: check libmambapy stubs
shell: bash -l {0}
run: |
@ -212,24 +191,23 @@ jobs:
- name: install mamba
shell: bash -l {0}
run: |
micromamba activate build_env
pip install ./mamba[test] --no-deps
python -m pip install --no-deps --no-build-isolation ./mamba[test]
- name: run mamba tests suite
shell: bash -l {0}
run: |
micromamba activate build_env
unset CONDARC # Interferes with tests
pytest -v --capture=tee-sys mamba/tests
- name: run mamba create/update tests
shell: bash -l {0}
run: |
micromamba activate build_env
unset CONDARC # Interferes with tests
mamba create -n test_env xtensor -c conda-forge -y
mamba env create -f mamba/tests/test_env.yml
mamba env update -f mamba/tests/update_env.yml
- name: run mamba local channel test
shell: bash -l {0}
run: |
micromamba activate build_env
unset CONDARC # Interferes with tests
if [ "$RUNNER_OS" == "Linux" ]; then
mkdir -p $CONDA_PREFIX/conda-bld/linux-64
wget -P $CONDA_PREFIX/conda-bld/linux-64 https://anaconda.org/conda-forge/xtensor/0.21.8/download/linux-64/xtensor-0.21.8-hc9558a2_0.tar.bz2
@ -250,7 +228,7 @@ jobs:
- name: Run server auth tests
shell: bash -l {0} -euo pipefail -x
run: |
micromamba activate build_env
export TEST_MAMBA_EXE="${PWD}/build/micromamba/micromamba"
cd mamba/tests
if [[ "$(uname -s)" == "Linux" ]]; then
@ -258,19 +236,11 @@ jobs:
fi
./testserver.sh
- name: Shell init
shell: bash -l {0} -euo pipefail -x
run: |
mamba init
- name: Cleanup
shell: bash
if: always()
run: |
# Do not cache temporary envs with 'cache-env: true'
rm -rf ~/micromamba*/envs/*/envs
libmamba_static_win:
runs-on: ${{ matrix.os }}
strategy:
@ -280,11 +250,12 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: create build environment
uses: mamba-org/provision-with-micromamba@main
uses: mamba-org/setup-micromamba@v1
with:
environment-file: ./libmamba/environment-static-dev-win.yml
environment-name: build_env
cache-env: true
cache-environment: true
init-shell: bash cmd.exe
- name: remove vcpkg manifest file
# we need to remove the vcpkg.json file to be able to work not in manifest mode
run: rm vcpkg.json
@ -302,7 +273,6 @@ jobs:
shell: cmd /C CALL {0}
# Latest VCPKG is from GHA because releases are not up to date with VCPKG server
run: |
call micromamba activate build_env
if %errorlevel% neq 0 exit /b %errorlevel%
set VCPKG_ROOT=C:\vcpkg
if %errorlevel% neq 0 exit /b %errorlevel%
@ -331,7 +301,6 @@ jobs:
- name: build libmamba-static
shell: cmd /C call {0}
run: |
call micromamba activate build_env
if %errorlevel% neq 0 exit /b %errorlevel%
@rem Used by CMake
set VCPKG_ROOT=C:\vcpkg
@ -349,12 +318,6 @@ jobs:
if %errorlevel% neq 0 exit /b %errorlevel%
- name: build cache statistics
run: sccache --show-stats
- name: Cleanup
shell: bash
if: always()
run: |
# Do not cache temporary envs with 'cache-env: true'
rm -rf ~/micromamba*/envs/*/envs
mamba_python_tests_win:
needs: [libmamba_static_win]
@ -367,12 +330,13 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: create build environment
uses: mamba-org/provision-with-micromamba@main
uses: mamba-org/setup-micromamba@v1
with:
environment-file: ./mamba/environment-dev.yml
environment-name: build_env
cache-env: true
extra-specs: |
cache-environment: true
init-shell: bash cmd.exe
create-args: >-
conda-build
curl
- uses: hendrikmuhs/ccache-action@main
@ -387,7 +351,6 @@ jobs:
- name: build libmamba Python bindings
shell: cmd /C call {0}
run: |
call micromamba activate build_env
if %errorlevel% neq 0 exit /b %errorlevel%
mkdir build
if %errorlevel% neq 0 exit /b %errorlevel%
@ -408,7 +371,6 @@ jobs:
- name: install libmambapy
shell: cmd /C call {0}
run: |
call micromamba activate build_env
pip install -e .\libmambapy\ --no-deps
- name: build cache statistics
run: sccache --show-stats
@ -448,12 +410,6 @@ jobs:
if [ "$(grep -c "local" list.txt)" -ne 2 ]; then
exit 1
fi
- name: Cleanup
shell: bash
if: always()
run: |
# Do not cache temporary envs with 'cache-env: true'
rm -rf ~/micromamba*/envs/*/envs
libmamba_cpp_tests_win:
needs: [libmamba_static_win]
@ -466,11 +422,12 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: create build environment
uses: mamba-org/provision-with-micromamba@main
uses: mamba-org/setup-micromamba@v1
with:
environment-file: ./libmamba/environment-dev.yml
environment-name: build_env
cache-env: true
cache-environment: true
init-shell: bash cmd.exe
- uses: hendrikmuhs/ccache-action@main
with:
variant: sccache
@ -480,7 +437,6 @@ jobs:
- name: build and run libmamba C++ tests
shell: cmd /C call {0}
run: |
call micromamba activate build_env
if %errorlevel% neq 0 exit /b %errorlevel%
mkdir build
if %errorlevel% neq 0 exit /b %errorlevel%
@ -496,15 +452,11 @@ jobs:
if %errorlevel% neq 0 exit /b %errorlevel%
ninja install
if %errorlevel% neq 0 exit /b %errorlevel%
@REM Interferes with tests
set CONDARC=
ninja test
- name: build cache statistics
run: sccache --show-stats
- name: Cleanup
shell: bash
if: always()
run: |
# Do not cache temporary envs with 'cache-env: true'
rm -rf ~/micromamba*/envs/*/envs
umamba_tests_win:
runs-on: ${{ matrix.os }}
@ -516,11 +468,12 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: create build environment
uses: mamba-org/provision-with-micromamba@main
uses: mamba-org/setup-micromamba@v1
with:
environment-file: ./micromamba/environment-dev.yml
environment-name: build_env
cache-env: true
cache-environment: true
init-shell: bash cmd.exe
- uses: hendrikmuhs/ccache-action@main
with:
variant: sccache
@ -530,7 +483,6 @@ jobs:
- name: build micromamba
shell: cmd /C call {0}
run: |
call micromamba activate build_env
if %errorlevel% neq 0 exit /b %errorlevel%
mkdir build
if %errorlevel% neq 0 exit /b %errorlevel%
@ -547,9 +499,7 @@ jobs:
ninja install
- name: check that micromamba runs
shell: cmd /C call {0}
run: |
call micromamba activate build_env
.\build\micromamba\micromamba.exe --help
run: .\build\micromamba\micromamba.exe --help
- name: build cache statistics
run: sccache --show-stats
- name: tar micromamba artifact
@ -561,12 +511,6 @@ jobs:
with:
name: _internal_micromamba_binary
path: umamba.tar
- name: Cleanup
shell: bash
if: always()
run: |
# Do not cache temporary envs with 'cache-env: true'
rm -rf ~/micromamba*/envs/*/envs
umamba_tests_win_cmd:
needs: [umamba_tests_win]
@ -588,19 +532,20 @@ jobs:
tar -xvf umamba.tar
- name: create build environment
uses: mamba-org/provision-with-micromamba@main
uses: mamba-org/setup-micromamba@v1
with:
environment-file: ./micromamba/environment-dev.yml
environment-name: build_env
extra-specs: menuinst
create-args: menuinst
init-shell: bash cmd.exe powershell
- name: micromamba python based tests with pwsh
shell: powershell
shell: pwsh
run: |
$env:PYTHONIOENCODING='UTF-8'
$env:MAMBA_ROOT_PREFIX = Join-Path -Path $pwd -ChildPath 'mambaroot'
$env:TEST_MAMBA_EXE = Join-Path -Path $pwd -ChildPath 'build\micromamba\micromamba.exe'
$env:MAMBA_TEST_SHELL_TYPE='powershell'
Remove-Item -Path "env:CONDARC"
pytest -v --capture=tee-sys micromamba/tests/
@ -627,10 +572,3 @@ jobs:
# export MAMBA_TEST_SHELL_TYPE=bash
#
# pytest -v --capture=tee-sys micromamba/tests/test_shell.py
- name: Cleanup
shell: bash
if: always()
run: |
# Do not cache temporary envs with 'cache-env: true'
rm -rf ~/micromamba*/envs/*/envs

View File

@ -12,6 +12,9 @@ readonly repo="${__DIR__}/repo/"
# Default value "mamba" for executable under test
export TEST_MAMBA_EXE="${TEST_MAMBA_EXE:-micromamba}"
# Avoid externally configured .condarc file
unset CONDARC
# Set up a temporary space for Conda environment and packages
readonly test_dir="$(mktemp -d -t mamba-test-reposerver-XXXXXXXXXX)"
export CONDA_ENVS_DIRS="${test_dir}/envs"

View File

@ -73,7 +73,10 @@ def tmp_home(
# Pytest would clean it automatically but this can be large (0.5 Gb for repodata)
# We clean it explicitly
if not request.config.getoption("--no-eager-clean"):
helpers.rmtree(new_home)
try:
helpers.rmtree(new_home)
except PermissionError:
pass
@pytest.fixture

View File

@ -7,7 +7,7 @@ from sys import platform
import pytest
from .helpers import create, random_string, umamba_run
from .helpers import create, random_string, subprocess_run, umamba_run
common_simple_flags = ["", "-d", "--detach", "--clean-env"]
possible_characters_for_process_names = (
@ -95,7 +95,7 @@ class TestRun:
test_script_file_name, test_script_path
)
)
assert subprocess.run(test_script_path, shell=True).returncode == 0
subprocess_run(test_script_path, shell=True)
def test_run_non_existing_env(self):
env_name = random_string()

View File

@ -1,90 +1,90 @@
micromamba run -n base /bin/bash -c "test -t 0"
"${TEST_MAMBA_EXE}" run -n base /bin/bash -c "test -t 0"
test $? -eq 0 && echo "ok" || (echo "fail" ; exit 1)
micromamba run -n base /bin/bash -c "test -t 1"
"${TEST_MAMBA_EXE}" run -n base /bin/bash -c "test -t 1"
test $? -eq 0 && echo "ok" || (echo "fail" ; exit 1)
micromamba run -n base /bin/bash -c "test -t 2"
"${TEST_MAMBA_EXE}" run -n base /bin/bash -c "test -t 2"
test $? -eq 0 && echo "ok" || (echo "fail" ; exit 1)
micromamba run -a "stdin stderr stdout" -n base /bin/bash -c "test -t 0"
"${TEST_MAMBA_EXE}" run -a "stdin stderr stdout" -n base /bin/bash -c "test -t 0"
test $? -eq 0 && echo "ok" || (echo "fail" ; exit 1)
micromamba run -a "stdin stderr stdout" -n base /bin/bash -c "test -t 1"
"${TEST_MAMBA_EXE}" run -a "stdin stderr stdout" -n base /bin/bash -c "test -t 1"
test $? -eq 0 && echo "ok" || (echo "fail" ; exit 1)
micromamba run -a "stdin stderr stdout" -n base /bin/bash -c "test -t 2"
"${TEST_MAMBA_EXE}" run -a "stdin stderr stdout" -n base /bin/bash -c "test -t 2"
test $? -eq 0 && echo "ok" || (echo "fail" ; exit 1)
micromamba run -a "stderr stdout" -n base /bin/bash -c "test -t 0"
"${TEST_MAMBA_EXE}" run -a "stderr stdout" -n base /bin/bash -c "test -t 0"
test $? -eq 1 && echo "ok" || (echo "fail" ; exit 1)
micromamba run -a "stderr stdout" -n base /bin/bash -c "test -t 1"
"${TEST_MAMBA_EXE}" run -a "stderr stdout" -n base /bin/bash -c "test -t 1"
test $? -eq 0 && echo "ok" || (echo "fail" ; exit 1)
micromamba run -a "stderr stdout" -n base /bin/bash -c "test -t 2"
"${TEST_MAMBA_EXE}" run -a "stderr stdout" -n base /bin/bash -c "test -t 2"
test $? -eq 0 && echo "ok" || (echo "fail" ; exit 1)
micromamba run -a "stdin stderr" -n base /bin/bash -c "test -t 0"
"${TEST_MAMBA_EXE}" run -a "stdin stderr" -n base /bin/bash -c "test -t 0"
test $? -eq 0 && echo "ok" || (echo "fail" ; exit 1)
micromamba run -a "stdin stderr" -n base /bin/bash -c "test -t 1"
"${TEST_MAMBA_EXE}" run -a "stdin stderr" -n base /bin/bash -c "test -t 1"
test $? -eq 1 && echo "ok" || (echo "fail" ; exit 1)
micromamba run -a "stdin stderr" -n base /bin/bash -c "test -t 2"
"${TEST_MAMBA_EXE}" run -a "stdin stderr" -n base /bin/bash -c "test -t 2"
test $? -eq 0 && echo "ok" || (echo "fail" ; exit 1)
micromamba run -a "stdin stdout" -n base /bin/bash -c "test -t 0"
"${TEST_MAMBA_EXE}" run -a "stdin stdout" -n base /bin/bash -c "test -t 0"
test $? -eq 0 && echo "ok" || (echo "fail" ; exit 1)
micromamba run -a "stdin stdout" -n base /bin/bash -c "test -t 1"
"${TEST_MAMBA_EXE}" run -a "stdin stdout" -n base /bin/bash -c "test -t 1"
test $? -eq 0 && echo "ok" || (echo "fail" ; exit 1)
micromamba run -a "stdin stdout" -n base /bin/bash -c "test -t 2"
"${TEST_MAMBA_EXE}" run -a "stdin stdout" -n base /bin/bash -c "test -t 2"
test $? -eq 1 && echo "ok" || (echo "fail" ; exit 1)
micromamba run -a "stdout" -n base /bin/bash -c "test -t 0"
"${TEST_MAMBA_EXE}" run -a "stdout" -n base /bin/bash -c "test -t 0"
test $? -eq 1 && echo "ok" || (echo "fail" ; exit 1)
micromamba run -a "stdout" -n base /bin/bash -c "test -t 1"
"${TEST_MAMBA_EXE}" run -a "stdout" -n base /bin/bash -c "test -t 1"
test $? -eq 0 && echo "ok" || (echo "fail" ; exit 1)
micromamba run -a "stdout" -n base /bin/bash -c "test -t 2"
"${TEST_MAMBA_EXE}" run -a "stdout" -n base /bin/bash -c "test -t 2"
test $? -eq 1 && echo "ok" || (echo "fail" ; exit 1)
micromamba run -a "stdin" -n base /bin/bash -c "test -t 0"
"${TEST_MAMBA_EXE}" run -a "stdin" -n base /bin/bash -c "test -t 0"
test $? -eq 0 && echo "ok" || (echo "fail" ; exit 1)
micromamba run -a "stdin" -n base /bin/bash -c "test -t 1"
"${TEST_MAMBA_EXE}" run -a "stdin" -n base /bin/bash -c "test -t 1"
test $? -eq 1 && echo "ok" || (echo "fail" ; exit 1)
micromamba run -a "stdin" -n base /bin/bash -c "test -t 2"
"${TEST_MAMBA_EXE}" run -a "stdin" -n base /bin/bash -c "test -t 2"
test $? -eq 1 && echo "ok" || (echo "fail" ; exit 1)
micromamba run -a "stderr" -n base /bin/bash -c "test -t 0"
"${TEST_MAMBA_EXE}" run -a "stderr" -n base /bin/bash -c "test -t 0"
test $? -eq 1 && echo "ok" || (echo "fail" ; exit 1)
micromamba run -a "stderr" -n base /bin/bash -c "test -t 1"
"${TEST_MAMBA_EXE}" run -a "stderr" -n base /bin/bash -c "test -t 1"
test $? -eq 1 && echo "ok" || (echo "fail" ; exit 1)
micromamba run -a "stderr" -n base /bin/bash -c "test -t 2"
"${TEST_MAMBA_EXE}" run -a "stderr" -n base /bin/bash -c "test -t 2"
test $? -eq 0 && echo "ok" || (echo "fail" ; exit 1)
micromamba run -a "" -n base /bin/bash -c "test -t 0"
"${TEST_MAMBA_EXE}" run -a "" -n base /bin/bash -c "test -t 0"
test $? -eq 1 && echo "ok" || (echo "fail" ; exit 1)
micromamba run -a "" -n base /bin/bash -c "test -t 1"
"${TEST_MAMBA_EXE}" run -a "" -n base /bin/bash -c "test -t 1"
test $? -eq 1 && echo "ok" || (echo "fail" ; exit 1)
micromamba run -a "" -n base /bin/bash -c "test -t 2"
"${TEST_MAMBA_EXE}" run -a "" -n base /bin/bash -c "test -t 2"
test $? -eq 1 && echo "ok" || (echo "fail" ; exit 1)