Skip to content

Commit c6782ff

Browse files
committed
singularity: improve testing on version 4.x+
1 parent 527884b commit c6782ff

File tree

2 files changed

+24
-25
lines changed

2 files changed

+24
-25
lines changed

.github/workflows/ci-tests.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ jobs:
4747
- name: Set up Singularity and environment-modules
4848
if: ${{ matrix.step == 'unit' || matrix.step == 'mypy' }}
4949
run: |
50-
wget --no-verbose https://github.com/sylabs/singularity/releases/download/v3.10.4/singularity-ce_3.10.4-focal_amd64.deb
51-
sudo apt-get install -y ./singularity-ce_3.10.4-focal_amd64.deb environment-modules
50+
wget --no-verbose https://github.com/sylabs/singularity/releases/download/v4.2.1/singularity-ce_4.2.1-focal_amd64.deb
51+
sudo apt-get install -y ./singularity-ce_4.2.1-focal_amd64.deb environment-modules
5252
5353
- name: Give the test runner user a name to make provenance happy.
5454
if: ${{ matrix.step == 'unit' || matrix.step == 'mypy' }}
@@ -134,8 +134,8 @@ jobs:
134134

135135
- name: Set up Singularity and environment-modules
136136
run: |
137-
wget --no-verbose https://github.com/sylabs/singularity/releases/download/v3.10.4/singularity-ce_3.10.4-focal_amd64.deb
138-
sudo apt-get install -y ./singularity-ce_3.10.4-focal_amd64.deb environment-modules
137+
wget --no-verbose https://github.com/sylabs/singularity/releases/download/v4.2.1/singularity-ce_4.2.1-focal_amd64.deb
138+
sudo apt-get install -y ./singularity-ce_4.2.1-focal_amd64.deb environment-modules
139139
140140
- name: Give the test runner user a name to make provenance happy.
141141
run: sudo usermod -c 'CI Runner' "$(whoami)"
@@ -183,8 +183,8 @@ jobs:
183183
- name: Set up Singularity and environment-modules
184184
if: ${{ matrix.container == 'singularity' }}
185185
run: |
186-
wget --no-verbose https://github.com/sylabs/singularity/releases/download/v3.10.4/singularity-ce_3.10.4-jammy_amd64.deb
187-
sudo apt-get install -y ./singularity-ce_3.10.4-jammy_amd64.deb environment-modules
186+
wget --no-verbose https://github.com/sylabs/singularity/releases/download/v4.2.1/singularity-ce_4.2.1-focal_amd64.deb
187+
sudo apt-get install -y ./singularity-ce_4.2.1-focal_amd64.deb environment-modules
188188
189189
- name: Singularity cache
190190
if: ${{ matrix.container == 'singularity' }}
@@ -231,8 +231,8 @@ jobs:
231231

232232
- name: Set up Singularity and environment-modules
233233
run: |
234-
wget --no-verbose https://github.com/sylabs/singularity/releases/download/v3.10.4/singularity-ce_3.10.4-jammy_amd64.deb
235-
sudo apt-get install -y ./singularity-ce_3.10.4-jammy_amd64.deb environment-modules
234+
wget --no-verbose https://github.com/sylabs/singularity/releases/download/v4.2.1/singularity-ce_4.2.1-focal_amd64.deb
235+
sudo apt-get install -y ./singularity-ce_4.2.1-focal_amd64.deb environment-modules
236236
237237
- name: Set up Python
238238
uses: actions/setup-python@v5

tests/test_environment.py

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from typing import Callable, Union
88

99
import pytest
10+
from packaging.version import Version
1011

1112
from cwltool.singularity import get_version
1213

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

135136
# Singularity variables appear to be in flux somewhat.
136-
version = get_version()[0]
137-
vmajor = version[0]
138-
assert vmajor == 3, "Tests only work for Singularity 3"
139-
vminor = version[1]
137+
version = Version(".".join(map(str, get_version()[0])))
138+
assert version >= Version("3"), "Tests only work for Singularity 3+"
140139
sing_vars: EnvChecks = {
141140
"SINGULARITY_CONTAINER": None,
142141
"SINGULARITY_NAME": None,
143142
}
144-
if vminor < 5:
143+
if version < Version("3.5"):
145144
sing_vars["SINGULARITY_APPNAME"] = None
146-
if vminor >= 5:
145+
if (version >= Version("3.5")) and (version < Version("3.6")):
146+
sing_vars["SINGULARITY_INIT"] = "1"
147+
if version >= Version("3.5"):
147148
sing_vars["PROMPT_COMMAND"] = None
148149
sing_vars["SINGULARITY_ENVIRONMENT"] = None
149-
if vminor == 5:
150-
sing_vars["SINGULARITY_INIT"] = "1"
151-
elif vminor > 5:
150+
if version >= Version("3.6"):
152151
sing_vars["SINGULARITY_COMMAND"] = "exec"
153-
if vminor >= 7:
154-
if vminor > 9:
155-
sing_vars["SINGULARITY_BIND"] = ""
156-
else:
152+
if version >= Version("3.7"):
153+
if version > Version("3.9"):
154+
sing_vars["SINGULARITY_BIND"] = ""
155+
else:
157156

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

161-
sing_vars["SINGULARITY_BIND"] = BIND
162-
if vminor >= 10:
160+
sing_vars["SINGULARITY_BIND"] = BIND
161+
if version >= Version("3.10"):
163162
sing_vars["SINGULARITY_COMMAND"] = "run"
164163
sing_vars["SINGULARITY_NO_EVAL"] = None
165164

0 commit comments

Comments
 (0)