diff --git a/.github/workflows/test-eb-hooks.yml b/.github/workflows/test-eb-hooks.yml index dfcc576c..bf8a48cc 100644 --- a/.github/workflows/test-eb-hooks.yml +++ b/.github/workflows/test-eb-hooks.yml @@ -51,6 +51,28 @@ jobs: module load EESSI-extend diff "$TEMP_FILE" "$EASYBUILD_HOOKS" + - name: Check whether eessi_supported_toolchains.json (used by eb_hooks.py) is up-to-date + if: ${{ github.event_name == 'pull_request' }} + run: | + FILE="eessi_supported_toolchains.json" + TEMP_FILE="$(mktemp)" + + # Fetch base branch + git fetch origin ${{ github.base_ref }} + + # Check if the file has changed in the PR + if git diff --name-only origin/${{ github.base_ref }}...HEAD | grep -q "^$FILE$"; then + echo "$FILE changed in PR. Using PR version." + cp "$FILE" "$TEMP_FILE" + else + echo "File not changed in PR. Using default branch version." + git show origin/${{ github.base_ref }}:$FILE > "$TEMP_FILE" + fi + + # Compare to what is shipped next to the hooks in the repository + module load EESSI-extend + diff "$TEMP_FILE" "$(dirname $EASYBUILD_HOOKS)/$FILE" + check_eb_hooks_functionality: runs-on: ubuntu-24.04 strategy: diff --git a/eb_hooks.py b/eb_hooks.py index fc26f88b..547f9e0e 100644 --- a/eb_hooks.py +++ b/eb_hooks.py @@ -67,31 +67,32 @@ STACK_REPROD_SUBDIR = 'reprod' -EESSI_SUPPORTED_TOP_LEVEL_TOOLCHAINS = { - '2023.06': [ - {'name': 'foss', 'version': '2022b'}, - {'name': 'foss', 'version': '2023a'}, - {'name': 'foss', 'version': '2023b'}, - ], - '2025.06': [ - {'name': 'foss', 'version': '2024a'}, - {'name': 'foss', 'version': '2025a'}, - {'name': 'foss', 'version': '2025b'}, - ], - '2026.06': [ - {'name': 'foss', 'version': '2026.1'}, - {'name': 'lfoss', 'version': '2026.1'}, - ], -} -if EASYBUILD_VERSION >= '5.2.0': - EESSI_SUPPORTED_TOP_LEVEL_TOOLCHAINS['2025.06'].append( - {'name': 'lfoss', 'version': '2025b'} - ) -if EASYBUILD_VERSION >= '5.3.1': - EESSI_SUPPORTED_TOP_LEVEL_TOOLCHAINS['2025.06'].append( - {'name': 'rompi', 'version': '2025a'} - ) +def load_supported_top_level_toolchains(): + """ + Load the supported top-level toolchains per EESSI version from eessi_supported_toolchains.json, + which is located next to this hooks file (both in the software-layer-scripts repository, and when installed + in /init/easybuild). Toolchains that require a more recent EasyBuild version than the one + being used (as specified via 'min_easybuild_version') are left out. + """ + toolchains_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'eessi_supported_toolchains.json') + try: + with open(toolchains_file) as fh: + toolchains = json.load(fh) + except (OSError, ValueError) as err: + raise EasyBuildError(f"Failed to load supported toolchains from {toolchains_file} " + f"(it is expected to be located next to the EasyBuild hooks file): {err}") + + return { + eessi_version: [ + {'name': tc['name'], 'version': tc['version']} for tc in tcs + if EASYBUILD_VERSION >= tc.get('min_easybuild_version', '0') + ] + for eessi_version, tcs in toolchains.items() + } + + +EESSI_SUPPORTED_TOP_LEVEL_TOOLCHAINS = load_supported_top_level_toolchains() # Supported compute capabilities by CUDA toolkit version # Obtained by installing all CUDAs from 12.0.0 to 13.3.0, then using: diff --git a/eessi_supported_toolchains.json b/eessi_supported_toolchains.json new file mode 100644 index 00000000..d89d38fe --- /dev/null +++ b/eessi_supported_toolchains.json @@ -0,0 +1,18 @@ +{ + "2023.06": [ + {"name": "foss", "version": "2022b"}, + {"name": "foss", "version": "2023a"}, + {"name": "foss", "version": "2023b"} + ], + "2025.06": [ + {"name": "foss", "version": "2024a"}, + {"name": "foss", "version": "2025a"}, + {"name": "foss", "version": "2025b"}, + {"name": "lfoss", "version": "2025b", "min_easybuild_version": "5.2.0"}, + {"name": "rompi", "version": "2025a", "min_easybuild_version": "5.3.1"} + ], + "2026.06": [ + {"name": "foss", "version": "2026.1"}, + {"name": "lfoss", "version": "2026.1"} + ] +} diff --git a/install_scripts.sh b/install_scripts.sh index 48745a3d..29ffcf24 100755 --- a/install_scripts.sh +++ b/install_scripts.sh @@ -225,6 +225,7 @@ fi # Copy over EasyBuild hooks file used for installations hook_files=( eb_hooks.py + eessi_supported_toolchains.json ) copy_files_by_list ${TOPDIR} ${INSTALL_PREFIX}/init/easybuild "${hook_files[@]}"