Skip to content

Commit e7cf75b

Browse files
committed
Add capability for site supported toolchains
1 parent 4f9802d commit e7cf75b

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

.github/workflows/test-eb-hooks.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,13 @@ jobs:
6363
- EESSI_VERSION: '2023.06'
6464
COMPATIBLE_EASYCONFIG: 'M4-1.4.19-GCCcore-13.2.0.eb'
6565
INCOMPATIBLE_EASYCONFIG: 'M4-1.4.19-GCCcore-14.2.0.eb'
66+
# Pick a site toolchain that will allow the incompatible easyconfig
67+
EESSI_SITE_TOP_LEVEL_TOOLCHAINS: '[{"GCCcore": "14.2.0"}]'
6668
- EESSI_VERSION: '2025.06'
6769
COMPATIBLE_EASYCONFIG: 'M4-1.4.19-GCCcore-14.2.0.eb'
6870
INCOMPATIBLE_EASYCONFIG: 'M4-1.4.19-GCCcore-13.2.0.eb'
71+
# Pick a site toolchain that will allow the incompatible easyconfig
72+
EESSI_SITE_TOP_LEVEL_TOOLCHAINS: '[{"GCCcore": "13.2.0"}]'
6973

7074
steps:
7175
- name: Check out software-layer repository
@@ -89,9 +93,23 @@ jobs:
8993
9094
# Test an easyconfig that should work
9195
eb --hooks=$PWD/eb_hooks.py "$COMPATIBLE_EASYCONFIG" --stop fetch
96+
echo "Success for hook with easyconfig $COMPATIBLE_EASYCONFIG with EESSI/${{matrix.EESSI_VERSION}}"
9297
9398
# Pick an outdated toolchain for the negative test
9499
eb --hooks=$PWD/eb_hooks.py "$INCOMPATIBLE_EASYCONFIG" --stop fetch 2>&1 1>/dev/null | grep -q "not supported in EESSI"
100+
echo "Found expected failure for hook with easyconfig $INCOMPATIBLE_EASYCONFIG and EESSI/${{matrix.EESSI_VERSION}}"
95101
96102
# Check the override works
97103
EESSI_OVERRIDE_TOOLCHAIN_CHECK=1 eb --hooks=$PWD/eb_hooks.py "$INCOMPATIBLE_EASYCONFIG" --stop fetch
104+
echo "Hook ignored via EESSI_OVERRIDE_TOOLCHAIN_CHECK with easyconfig $INCOMPATIBLE_EASYCONFIG and EESSI/${{matrix.EESSI_VERSION}}"
105+
106+
# Now check if we can set a site list of supported toolchains
107+
export EESSI_SITE_TOP_LEVEL_TOOLCHAINS=${{matrix.EESSI_SITE_TOP_LEVEL_TOOLCHAINS}}
108+
eb --hooks=$PWD/eb_hooks.py "$INCOMPATIBLE_EASYCONFIG" --stop fetch
109+
echo "Site supported toolchain $EESSI_SITE_TOP_LEVEL_TOOLCHAINS successfully used with easyconfig $INCOMPATIBLE_EASYCONFIG and EESSI/${{matrix.EESSI_VERSION}}"
110+
111+
# Make sure an invalid list of dicts fails
112+
export EESSI_SITE_TOP_LEVEL_TOOLCHAINS="Not a list of dicts"
113+
eb --hooks=$PWD/eb_hooks.py "$INCOMPATIBLE_EASYCONFIG" --stop fetch 2>&1 1>/dev/null | grep -q "does not contain a valid list of dictionaries"
114+
echo "Incorrect format for EESSI_SITE_TOP_LEVEL_TOOLCHAINS caught"
115+

eb_hooks.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# Hooks to customize how EasyBuild installs software in EESSI
22
# see https://docs.easybuild.io/en/latest/Hooks.html
3+
import ast
34
import datetime
45
import glob
6+
import json
57
import os
68
import re
79

@@ -142,10 +144,27 @@ def parse_hook(ec, *args, **kwargs):
142144
ec = inject_gpu_property(ec)
143145

144146

147+
def parse_list_of_dicts_env(var_name):
148+
list_string = os.getenv(var_name, '[]')
149+
150+
list_of_dicts = []
151+
try:
152+
# Try JSON format first
153+
list_of_dicts = json.loads(list_string)
154+
except json.JSONDecodeError:
155+
try:
156+
# Fall back to Python literal format
157+
list_of_dicts = ast.literal_eval(list_string)
158+
except (ValueError, SyntaxError):
159+
raise ValueError(f"Environment variable '{var_name}' does not contain a valid list of dictionaries.")
160+
161+
return list_of_dicts
162+
163+
145164
def verify_toolchains_supported_by_eessi_version(easyconfigs):
146165
"""Each EESSI version supports a limited set of toolchains, sanity check the easyconfigs for toolchain support."""
147166
eessi_version = get_eessi_envvar('EESSI_VERSION')
148-
supported_eessi_toolchains = []
167+
supported_eessi_toolchains = parse_list_of_dicts_env('EESSI_SITE_TOP_LEVEL_TOOLCHAINS')
149168
for top_level_toolchain in EESSI_SUPPORTED_TOP_LEVEL_TOOLCHAINS[eessi_version]:
150169
supported_eessi_toolchains += get_toolchain_hierarchy(top_level_toolchain)
151170
for ec in easyconfigs:

0 commit comments

Comments
 (0)