diff --git a/.github/workflows/scripts/test_init_scripts.sh b/.github/workflows/scripts/test_init_scripts.sh index bbf424a6..f543835c 100755 --- a/.github/workflows/scripts/test_init_scripts.sh +++ b/.github/workflows/scripts/test_init_scripts.sh @@ -2,59 +2,81 @@ export LMOD_PAGER=cat if [ -z ${EESSI_VERSION} ] || [ ! -d /cvmfs/software.eessi.io/versions/${EESSI_VERSION} ]; then - echo "\$EESSI_VERSION has to be set to a valid EESSI version." - exit 1 + echo "\$EESSI_VERSION has to be set to a valid EESSI version." + exit 1 fi if [ -z ${EXPECTED_EASYBUILD_VERSION} ]; then - echo "\$EXPECTED_EASYBUILD_VERSION has to be set to an EasyBuild version that is expected to be available in EESSI version ${EESSI_VERSION}." - exit 1 + echo "\$EXPECTED_EASYBUILD_VERSION has to be set to an EasyBuild version that is expected to be available in EESSI version ${EESSI_VERSION}." + exit 1 fi # initialize assert framework if [ ! -d assert.sh ]; then - echo "assert.sh not cloned." - echo "" - echo "run \`git clone https://github.com/lehmannro/assert.sh.git\`" - exit 1 + echo "assert.sh not cloned." + echo "" + echo "run \`git clone https://github.com/lehmannro/assert.sh.git\`" + exit 1 fi . assert.sh/assert.sh -TEST_SHELLS=("bash" "zsh" "fish" "ksh") +TEST_SHELLS=("bash" "zsh" "fish" "ksh" "csh") SHELLS=$@ for shell in ${SHELLS[@]}; do - echo = | awk 'NF += (OFS = $_) + 100' - echo RUNNING TESTS FOR SHELL: $shell - echo = | awk 'NF += (OFS = $_) + 100' + echo = | awk 'NF += (OFS = $_) + 100' + echo RUNNING TESTS FOR SHELL: $shell + echo = | awk 'NF += (OFS = $_) + 100' if [[ ! " ${TEST_SHELLS[*]} " =~ [[:space:]]${shell}[[:space:]] ]]; then - ### EXCEPTION FOR CSH ### - echo -e "\033[33mWe don't now how to test the shell '$shell', PRs are Welcome.\033[0m" + ### EXCEPTION FOR CSH ### + echo -e "\033[33mWe don't now how to test the shell '$shell', PRs are Welcome.\033[0m" else - # TEST 1: Source Script and check Module Output - assert "$shell -c 'source init/lmod/$shell' 2>&1 " "Module for EESSI/$EESSI_VERSION loaded successfully" - # TEST 2: Check if module overviews first section is the loaded EESSI module - MODULE_SECTIONS=($($shell -c "source init/lmod/$shell 2>/dev/null; module ov 2>&1 | grep -e '---'")) - PATTERN="/cvmfs/software\.eessi\.io/versions/$EESSI_VERSION/software/linux/x86_64/(intel/haswell|amd/zen3)/modules/all" - assert_raises 'echo "${MODULE_SECTIONS[1]}" | grep -E "$PATTERN"' - # TEST 3: Check if module overviews second section is the EESSI init module - assert "echo ${MODULE_SECTIONS[4]}" "/cvmfs/software.eessi.io/versions/$EESSI_VERSION/init/modules" - # Test 4: Load EasyBuild module and check version - # eb --version outputs: "This is EasyBuild 5.1.1 (framework: 5.1.1, easyblocks: 5.1.1) on host ..." - command="$shell -c 'source init/lmod/$shell 2>/dev/null; module load EasyBuild/${EXPECTED_EASYBUILD_VERSION}; eb --version | cut -d \" \" -f4'" - assert "$command" "$EXPECTED_EASYBUILD_VERSION" - # Test 5: Load EasyBuild module and check path - EASYBUILD_PATH=$($shell -c "source init/lmod/$shell 2>/dev/null; module load EasyBuild/${EXPECTED_EASYBUILD_VERSION}; which eb") - # escape the dots in ${EASYBUILD_VERSION} - PATTERN="/cvmfs/software\.eessi\.io/versions/$EESSI_VERSION/software/linux/x86_64/(intel/haswell|amd/zen3)/software/EasyBuild/${EXPECTED_EASYBUILD_VERSION//./\\.}/bin/eb" - echo "$EASYBUILD_PATH" | grep -E "$PATTERN" - assert_raises 'echo "$EASYBUILD_PATH" | grep -E "$PATTERN"' - - #End Test Suite - assert_end "source_eessi_$shell" - fi -done + # TEST 1: Source Script and check Module Output + expected="Module for EESSI/$EESSI_VERSION loaded successfully" + assert "$shell -c 'source init/lmod/$shell' 2>&1 " "${expected}" + + # TEST 2: Check if module overviews first section is the loaded EESSI module + if [ "$shell" = "csh" ]; then + # module is defined as alias, but aliases are only retained in interactive + # shells we work around this by creating a .cshrc file (which sources the + # init script), and then simply run the remaining commands + echo "source init/lmod/$shell" > ~/.cshrc + MODULE_SECTIONS=($($shell -c "module ov" 2>&1 | grep -e '---')) + else + MODULE_SECTIONS=($($shell -c "source init/lmod/$shell 2>/dev/null; module ov 2>&1 | grep -e '---'")) + fi + PATTERN="/cvmfs/software\.eessi\.io/versions/$EESSI_VERSION/software/linux/x86_64/(intel/haswell|amd/zen3)/modules/all" + assert_raises 'echo "${MODULE_SECTIONS[1]}" | grep -E "$PATTERN"' + + # TEST 3: Check if module overviews second section is the EESSI init module + assert "echo ${MODULE_SECTIONS[4]}" "/cvmfs/software.eessi.io/versions/$EESSI_VERSION/init/modules" + # TEST 4: Load EasyBuild module and check version + # eb --version outputs: "This is EasyBuild 5.1.1 (framework: 5.1.1, easyblocks: 5.1.1) on host ..." + if [ "$shell" = "csh" ]; then + echo "source init/lmod/$shell" > ~/.cshrc + command="$shell -c 'module load EasyBuild/${EXPECTED_EASYBUILD_VERSION}; eb --version' | cut -d \" \" -f4" + else + command="$shell -c 'source init/lmod/$shell 2>/dev/null; module load EasyBuild/${EXPECTED_EASYBUILD_VERSION}; eb --version | cut -d \" \" -f4'" + fi + assert "$command" "$EXPECTED_EASYBUILD_VERSION" + + # TEST 5: Load EasyBuild module and check path + if [ "$shell" = "csh" ]; then + echo "source init/lmod/$shell" > ~/.cshrc + EASYBUILD_PATH=$($shell -c "module load EasyBuild/${EXPECTED_EASYBUILD_VERSION}; which eb") + else + EASYBUILD_PATH=$($shell -c "source init/lmod/$shell 2>/dev/null; module load EasyBuild/${EXPECTED_EASYBUILD_VERSION}; which eb") + fi + # escape the dots in ${EASYBUILD_VERSION} + PATTERN="/cvmfs/software\.eessi\.io/versions/$EESSI_VERSION/software/linux/x86_64/(intel/haswell|amd/zen3)/software/EasyBuild/${EXPECTED_EASYBUILD_VERSION//./\\.}/bin/eb" + echo "$EASYBUILD_PATH" | grep -E "$PATTERN" + assert_raises 'echo "$EASYBUILD_PATH" | grep -E "$PATTERN"' + + # End Test Suite + assert_end "source_eessi_$shell" + fi +done # RESET PAGER export LMOD_PAGER= diff --git a/.github/workflows/tests_init_module.yml b/.github/workflows/tests_init_module.yml index f0694a92..b4d31435 100644 --- a/.github/workflows/tests_init_module.yml +++ b/.github/workflows/tests_init_module.yml @@ -27,6 +27,12 @@ jobs: - name: Check out software-layer repository uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - name: Avoid processing man-db trigger + run: | + # avoid processing trigger for man-db (seems to slow down installation) + echo "set man-db/auto-update false" | sudo debconf-communicate + sudo dpkg-reconfigure man-db + - name: Mount EESSI CernVM-FS pilot repository uses: cvmfs-contrib/github-action-cvmfs@55899ca74cf78ab874bdf47f5a804e47c198743c # v4.0 with: @@ -46,7 +52,7 @@ jobs: - name: Install missing shells run: | sudo apt update - sudo apt install zsh ksh fish + sudo apt install zsh ksh fish tcsh echo "# INIT ZSH" > ~/.zshrc - name: Run tests for available shells diff --git a/init/lmod/csh b/init/lmod/csh index 28ad59e8..2adb314c 100644 --- a/init/lmod/csh +++ b/init/lmod/csh @@ -1,19 +1,24 @@ # Choose an EESSI CVMFS repository -if (! $?EESSI_CVMFS_REPO) then; set EESSI_CVMFS_REPO = "/cvmfs/software.eessi.io"; endif +if (! $?EESSI_CVMFS_REPO) then + set EESSI_CVMFS_REPO = "/cvmfs/software.eessi.io" +endif # Choose an EESSI version setenv EESSI_VERSION_DEFAULT "__EESSI_VERSION_DEFAULT__" -if (! $?EESSI_VERSION) then; set EESSI_VERSION = "${EESSI_VERSION_DEFAULT}"; endif +if (! $?EESSI_VERSION) then + set EESSI_VERSION = "${EESSI_VERSION_DEFAULT}" +endif # Path to top-level module tree setenv MODULEPATH "${EESSI_CVMFS_REPO}/versions/${EESSI_VERSION}/init/modules" -source "${EESSI_CVMFS_REPO}/versions/${EESSI_VERSION}/compat/linux/$(uname -m)/usr/share/Lmod/init/csh" +source "${EESSI_CVMFS_REPO}/versions/${EESSI_VERSION}/compat/linux/`uname -m`/usr/share/Lmod/init/csh" if (! $?__Init_Default_Modules ) then - setenv __Init_Default_Modules 1; + setenv __Init_Default_Modules 1 - ## ability to predefine elsewhere the default list - if (! $?LMOD_SYSTEM_DEFAULT_MODULES) then; setenv LMOD_SYSTEM_DEFAULT_MODULES "EESSI/$EESSI_VERSION"; endif - module --initial_load --no_redirect restore + # ability to predefine elsewhere the default list + if (! $?LMOD_SYSTEM_DEFAULT_MODULES) then + setenv LMOD_SYSTEM_DEFAULT_MODULES "EESSI/${EESSI_VERSION}" + endif + module --initial_load --no_redirect restore else - module refresh + module refresh endif -