Skip to content

Commit

Permalink
Parametrize mamba version instead
Browse files Browse the repository at this point in the history
Signed-off-by: Julien Jerphanion <git@jjerphan.xyz>
  • Loading branch information
jjerphan committed Feb 3, 2025
1 parent c601b15 commit 6aee934
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 121 deletions.
28 changes: 0 additions & 28 deletions examples/miniforge-mamba2/EULA.txt

This file was deleted.

25 changes: 0 additions & 25 deletions examples/miniforge-mamba2/construct.yaml

This file was deleted.

8 changes: 0 additions & 8 deletions examples/miniforge-mamba2/test_install.bat

This file was deleted.

45 changes: 0 additions & 45 deletions examples/miniforge-mamba2/test_install.sh

This file was deleted.

4 changes: 3 additions & 1 deletion examples/miniforge/construct.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{% set mamba_version = os.environ.get("CONSTRUCTOR_TEST_MAMBA_VERSION") %}

name: Miniforge3
version: 24.11.2-1
company: conda-forge
Expand All @@ -13,7 +15,7 @@ transmute_file_type: .conda
specs:
- python 3.12.*
- conda 24.11.2
- mamba 1.5.12
- mamba {{ mamba_version }}
- pip
- miniforge_console_shortcut 1.* # [win]

Expand Down
73 changes: 60 additions & 13 deletions examples/miniforge/test_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,67 @@ echo "+ Testing conda channels"
conda config --show --json | python -c "import sys, json; info = json.loads(sys.stdin.read()); assert 'conda-forge' in info['channels'], info"
echo " OK"

echo "+ Testing mamba installation"
mamba --version
echo " OK"
# Get versions with conda
MAMBA_VERSION=$(conda list "^mamba$" --json | python -c "import sys, json; info = json.loads(sys.stdin.read()); print(info[0]['version'])")
LIBMAMBA_VERSION=$(conda list "^libmamba$" --json | python -c "import sys, json; info = json.loads(sys.stdin.read()); print(info[0]['version'])")
LIBMAMBAPY_VERSION=$(conda list "^libmambapy$" --json | python -c "import sys, json; info = json.loads(sys.stdin.read()); print(info[0]['version'])")

echo "+ mamba info"
mamba info
# Assert that their are all equal to CONSTRUCTOR_TEST_MAMBA_VERSION
if [ "$MAMBA_VERSION" != "$CONSTRUCTOR_TEST_MAMBA_VERSION" ]; then
echo "ERROR: Mamba version mismatch: expected $CONSTRUCTOR_TEST_MAMBA_VERSION, got $MAMBA_VERSION"
exit 1
fi

echo "+ Testing mamba version"
mamba --version | grep mamba | cut -d' ' -f2 | grep -q 1.5.12
mamba --version | grep conda | cut -d' ' -f2 | grep -q 24.11.2
if [ "$LIBMAMBA_VERSION" != "$CONSTRUCTOR_TEST_MAMBA_VERSION" ]; then
echo "ERROR: libmamba version mismatch: expected $CONSTRUCTOR_TEST_MAMBA_VERSION, got $LIBMAMBA_VERSION"
exit 1
fi

mamba info --json | python -c "import sys, json; info = json.loads(sys.stdin.read()); assert info['mamba_version'] == '1.5.12', info"
echo " OK"
if [ "$LIBMAMBAPY_VERSION" != "$CONSTRUCTOR_TEST_MAMBA_VERSION" ]; then
echo "ERROR: libmambapy version mismatch: expected $CONSTRUCTOR_TEST_MAMBA_VERSION, got $LIBMAMBAPY_VERSION"
exit 1
fi

echo "+ Testing mamba channels"
mamba info --json | python -c "import sys, json; info = json.loads(sys.stdin.read()); assert any('conda-forge' in c for c in info['channels']), info"
echo " OK"
MAMBA_MAJOR_VERSION=$(echo "$MAMBA_VERSION" | cut -d'.' -f1)

# The commands and output are slightly different between mamba 1 and 2,
# so we need to test them separately.
if [ "$MAMBA_MAJOR_VERSION" -eq "1" ]; then
echo "+ Testing mamba 1 installation"
mamba --version

echo "+ mamba info"
mamba info

echo "+ Testing mamba version"
mamba --version | grep mamba | cut -d' ' -f2 | grep -q "$MAMBA_VERSION"
mamba --version | grep conda | cut -d' ' -f2 | grep -q 24.11.2

mamba info --json | python -c "import sys, json; info = json.loads(sys.stdin.read()); assert info['mamba_version'] == '$MAMBA_VERSION', info"

echo "+ Testing mamba channels"
mamba info --json | python -c "import sys, json; info = json.loads(sys.stdin.read()); assert any('conda-forge' in c for c in info['channels']), info"
echo " OK"
else
echo "+ Testing mamba 2 installation"
mamba --version | grep -q "$MAMBA_VERSION"

echo "+ mamba info"
mamba info

echo "+ mamba config sources"
mamba config sources

echo "+ mamba config list"
mamba config list

echo "+ Testing mamba 2 version"
mamba info --json | python -c "import sys, json; info = json.loads(sys.stdin.read()); assert info['mamba version'] == '$MAMBA_VERSION', info"

echo "+ Testing libmambapy 2 version"
python -c "import libmambapy; assert libmambapy.__version__ == '$MAMBA_VERSION', f'libmamba version got: {libmambapy.__version__}; expected: {MAMBA_VERSION}'"

echo "+ Testing mamba channels"
mamba info --json | python -c "import sys, json; info = json.loads(sys.stdin.read()); assert any('conda-forge' in c for c in info['channels']), info"
echo " OK"
fi
4 changes: 3 additions & 1 deletion tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,9 @@ def test_example_extra_files(tmp_path, request):
),
reason="Known issue with conda-standalone<=23.10: shortcuts are created but not removed.",
)
def test_example_miniforge(tmp_path, request):
@pytest.mark.parametrize("mamba_version", ("1.5.12", "2.0.5"))
def test_example_miniforge(tmp_path, request, mamba_version, monkeypatch):
monkeypatch.setenv("CONSTRUCTOR_TEST_MAMBA_VERSION", mamba_version)
input_path = _example_path("miniforge")
for installer, install_dir in create_installer(input_path, tmp_path):
if installer.suffix == ".sh":
Expand Down

0 comments on commit 6aee934

Please sign in to comment.