Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

singularity: improve testing on version 4.x+ #2088

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading