Skip to content

Commit

Permalink
singularity: improve testing on version 4.x+
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-c committed Dec 17, 2024
1 parent 527884b commit c6782ff
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 25 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ jobs:
- name: Set up Singularity and environment-modules
if: ${{ matrix.step == 'unit' || matrix.step == 'mypy' }}
run: |
wget --no-verbose https://github.com/sylabs/singularity/releases/download/v3.10.4/singularity-ce_3.10.4-focal_amd64.deb
sudo apt-get install -y ./singularity-ce_3.10.4-focal_amd64.deb environment-modules
wget --no-verbose https://github.com/sylabs/singularity/releases/download/v4.2.1/singularity-ce_4.2.1-focal_amd64.deb
sudo apt-get install -y ./singularity-ce_4.2.1-focal_amd64.deb environment-modules
- name: Give the test runner user a name to make provenance happy.
if: ${{ matrix.step == 'unit' || matrix.step == 'mypy' }}
Expand Down Expand Up @@ -134,8 +134,8 @@ jobs:

- name: Set up Singularity and environment-modules
run: |
wget --no-verbose https://github.com/sylabs/singularity/releases/download/v3.10.4/singularity-ce_3.10.4-focal_amd64.deb
sudo apt-get install -y ./singularity-ce_3.10.4-focal_amd64.deb environment-modules
wget --no-verbose https://github.com/sylabs/singularity/releases/download/v4.2.1/singularity-ce_4.2.1-focal_amd64.deb
sudo apt-get install -y ./singularity-ce_4.2.1-focal_amd64.deb environment-modules
- name: Give the test runner user a name to make provenance happy.
run: sudo usermod -c 'CI Runner' "$(whoami)"
Expand Down Expand Up @@ -183,8 +183,8 @@ jobs:
- name: Set up Singularity and environment-modules
if: ${{ matrix.container == 'singularity' }}
run: |
wget --no-verbose https://github.com/sylabs/singularity/releases/download/v3.10.4/singularity-ce_3.10.4-jammy_amd64.deb
sudo apt-get install -y ./singularity-ce_3.10.4-jammy_amd64.deb environment-modules
wget --no-verbose https://github.com/sylabs/singularity/releases/download/v4.2.1/singularity-ce_4.2.1-focal_amd64.deb
sudo apt-get install -y ./singularity-ce_4.2.1-focal_amd64.deb environment-modules
- name: Singularity cache
if: ${{ matrix.container == 'singularity' }}
Expand Down Expand Up @@ -231,8 +231,8 @@ jobs:

- name: Set up Singularity and environment-modules
run: |
wget --no-verbose https://github.com/sylabs/singularity/releases/download/v3.10.4/singularity-ce_3.10.4-jammy_amd64.deb
sudo apt-get install -y ./singularity-ce_3.10.4-jammy_amd64.deb environment-modules
wget --no-verbose https://github.com/sylabs/singularity/releases/download/v4.2.1/singularity-ce_4.2.1-focal_amd64.deb
sudo apt-get install -y ./singularity-ce_4.2.1-focal_amd64.deb environment-modules
- name: Set up Python
uses: actions/setup-python@v5
Expand Down
33 changes: 16 additions & 17 deletions tests/test_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from typing import Callable, Union

import pytest
from packaging.version import Version

from cwltool.singularity import get_version

Expand Down Expand Up @@ -133,33 +134,31 @@ def PWD(v: str, env: Env) -> bool:
}

# Singularity variables appear to be in flux somewhat.
version = get_version()[0]
vmajor = version[0]
assert vmajor == 3, "Tests only work for Singularity 3"
vminor = version[1]
version = Version(".".join(map(str, get_version()[0])))
assert version >= Version("3"), "Tests only work for Singularity 3+"
sing_vars: EnvChecks = {
"SINGULARITY_CONTAINER": None,
"SINGULARITY_NAME": None,
}
if vminor < 5:
if version < Version("3.5"):
sing_vars["SINGULARITY_APPNAME"] = None
if vminor >= 5:
if (version >= Version("3.5")) and (version < Version("3.6")):
sing_vars["SINGULARITY_INIT"] = "1"
if version >= Version("3.5"):
sing_vars["PROMPT_COMMAND"] = None
sing_vars["SINGULARITY_ENVIRONMENT"] = None
if vminor == 5:
sing_vars["SINGULARITY_INIT"] = "1"
elif vminor > 5:
if version >= Version("3.6"):
sing_vars["SINGULARITY_COMMAND"] = "exec"
if vminor >= 7:
if vminor > 9:
sing_vars["SINGULARITY_BIND"] = ""
else:
if version >= Version("3.7"):
if version > Version("3.9"):
sing_vars["SINGULARITY_BIND"] = ""
else:

def BIND(v: str, env: Env) -> bool:
return v.startswith(tmp_prefix) and v.endswith(":/tmp")
def BIND(v: str, env: Env) -> bool:
return v.startswith(tmp_prefix) and v.endswith(":/tmp")

sing_vars["SINGULARITY_BIND"] = BIND
if vminor >= 10:
sing_vars["SINGULARITY_BIND"] = BIND
if version >= Version("3.10"):
sing_vars["SINGULARITY_COMMAND"] = "run"
sing_vars["SINGULARITY_NO_EVAL"] = None

Expand Down

0 comments on commit c6782ff

Please sign in to comment.