Skip to content

Commit ebefcdc

Browse files
authored
fix: install certifi (#35)
Defensive, related to modflowpy/flopy#2806 and modflowpy/flopy#2807. Also tolerate old names for programs.
1 parent 7fc2162 commit ebefcdc

2 files changed

Lines changed: 28 additions & 3 deletions

File tree

action.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,15 @@ runs:
152152
args="$args --ostag ${{ inputs.ostag }}"
153153
fi
154154
155+
# work around broken/incomplete local CA trust stores on some runners by pointing
156+
# Python's default SSL context at certifi's CA bundle, regardless of which install
157+
# path below ends up running
158+
python3 -m pip install --quiet --disable-pip-version-check certifi || true
159+
cert_file="$(python3 -m certifi 2>/dev/null || true)"
160+
if [[ -n "$cert_file" ]]; then
161+
export SSL_CERT_FILE="$cert_file"
162+
fi
163+
155164
# download the installation script if necessary
156165
if command -v get-modflow &> /dev/null
157166
then

test/test.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
'crt',
3232
'mt3dms',
3333
'mf2005dbl',
34-
'zonbud3',
34+
'zonbud',
3535
'gridgen',
3636
'mflgrdbl',
3737
'mfnwt',
@@ -59,6 +59,12 @@
5959
"modflow6-nightly-build": ["libmf6"]
6060
}
6161

62+
# executables that have been renamed upstream at some point; accept the old
63+
# name too, so tests pass against both latest and older pinned release tags
64+
exe_aliases = {
65+
'zonbud': ['zonbud3'],
66+
}
67+
6268
# apply subset filter, if provided
6369
if subset:
6470
expected_exes = {k: [vv for vv in v if vv in subset] for k, v in expected_exes.items()}
@@ -98,6 +104,14 @@ def get_expected_files(repository) -> Tuple[List[str], List[str]]:
98104
return exes, libs
99105

100106

107+
def alt_names(exe) -> List[str]:
108+
"""Given an (possibly suffixed) expected exe name, return itself plus any
109+
known former/alternate names it may appear as, with the same suffix."""
110+
base, _, suffix = exe.partition('.')
111+
suffix = f".{suffix}" if suffix else ""
112+
return [exe] + [f"{alias}{suffix}" for alias in exe_aliases.get(base, [])]
113+
114+
101115
# check install location exists
102116
assert path.is_dir(), f"Install location {path} doesn't exist"
103117
print(f"Found install location: {path}")
@@ -109,15 +123,17 @@ def get_expected_files(repository) -> Tuple[List[str], List[str]]:
109123

110124
# check executables exist
111125
found = sorted([p.name for p in path.glob("*")])
126+
found_set = set(found)
112127
exp_exes, exp_libs = get_expected_files(repo)
113128
expected = exp_exes + exp_libs
114-
assert set(found) >= set(exp_exes), f"Executables/libraries missing:\n Found {set(found)}\n Expected {set(exp_exes)}"
129+
missing = [exe for exe in exp_exes if not (set(alt_names(exe)) & found_set)]
130+
assert not missing, f"Executables/libraries missing:\n Found {found_set}\n Expected {set(exp_exes)}"
115131
print(f"Found all expected executables/libraries:")
116132
pprint(expected)
117133

118134
# check executables are on the PATH
119135
for exe in exp_exes:
120-
assert which(exe), f"Executable {exe} not found on path"
136+
assert any(which(name) for name in alt_names(exe)), f"Executable {exe} not found on path"
121137
print(f"Verified executables are on system path")
122138

123139

0 commit comments

Comments
 (0)