Skip to content

Commit 706f9e8

Browse files
authored
Merge pull request #102 from trz42/fix_csh_CI
fix script to init EESSI for `csh` shells, fixes also the CI for `csh` and speeds up CI
2 parents a9faaa7 + 40bc520 commit 706f9e8

File tree

3 files changed

+80
-47
lines changed

3 files changed

+80
-47
lines changed

.github/workflows/scripts/test_init_scripts.sh

Lines changed: 59 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,59 +2,81 @@
22
export LMOD_PAGER=cat
33

44
if [ -z ${EESSI_VERSION} ] || [ ! -d /cvmfs/software.eessi.io/versions/${EESSI_VERSION} ]; then
5-
echo "\$EESSI_VERSION has to be set to a valid EESSI version."
6-
exit 1
5+
echo "\$EESSI_VERSION has to be set to a valid EESSI version."
6+
exit 1
77
fi
88

99
if [ -z ${EXPECTED_EASYBUILD_VERSION} ]; then
10-
echo "\$EXPECTED_EASYBUILD_VERSION has to be set to an EasyBuild version that is expected to be available in EESSI version ${EESSI_VERSION}."
11-
exit 1
10+
echo "\$EXPECTED_EASYBUILD_VERSION has to be set to an EasyBuild version that is expected to be available in EESSI version ${EESSI_VERSION}."
11+
exit 1
1212
fi
1313

1414
# initialize assert framework
1515
if [ ! -d assert.sh ]; then
16-
echo "assert.sh not cloned."
17-
echo ""
18-
echo "run \`git clone https://github.com/lehmannro/assert.sh.git\`"
19-
exit 1
16+
echo "assert.sh not cloned."
17+
echo ""
18+
echo "run \`git clone https://github.com/lehmannro/assert.sh.git\`"
19+
exit 1
2020
fi
2121
. assert.sh/assert.sh
2222

23-
TEST_SHELLS=("bash" "zsh" "fish" "ksh")
23+
TEST_SHELLS=("bash" "zsh" "fish" "ksh" "csh")
2424
SHELLS=$@
2525

2626
for shell in ${SHELLS[@]}; do
27-
echo = | awk 'NF += (OFS = $_) + 100'
28-
echo RUNNING TESTS FOR SHELL: $shell
29-
echo = | awk 'NF += (OFS = $_) + 100'
27+
echo = | awk 'NF += (OFS = $_) + 100'
28+
echo RUNNING TESTS FOR SHELL: $shell
29+
echo = | awk 'NF += (OFS = $_) + 100'
3030
if [[ ! " ${TEST_SHELLS[*]} " =~ [[:space:]]${shell}[[:space:]] ]]; then
31-
### EXCEPTION FOR CSH ###
32-
echo -e "\033[33mWe don't now how to test the shell '$shell', PRs are Welcome.\033[0m"
31+
### EXCEPTION FOR CSH ###
32+
echo -e "\033[33mWe don't now how to test the shell '$shell', PRs are Welcome.\033[0m"
3333
else
34-
# TEST 1: Source Script and check Module Output
35-
assert "$shell -c 'source init/lmod/$shell' 2>&1 " "Module for EESSI/$EESSI_VERSION loaded successfully"
36-
# TEST 2: Check if module overviews first section is the loaded EESSI module
37-
MODULE_SECTIONS=($($shell -c "source init/lmod/$shell 2>/dev/null; module ov 2>&1 | grep -e '---'"))
38-
PATTERN="/cvmfs/software\.eessi\.io/versions/$EESSI_VERSION/software/linux/x86_64/(intel/haswell|amd/zen3)/modules/all"
39-
assert_raises 'echo "${MODULE_SECTIONS[1]}" | grep -E "$PATTERN"'
40-
# TEST 3: Check if module overviews second section is the EESSI init module
41-
assert "echo ${MODULE_SECTIONS[4]}" "/cvmfs/software.eessi.io/versions/$EESSI_VERSION/init/modules"
42-
# Test 4: Load EasyBuild module and check version
43-
# eb --version outputs: "This is EasyBuild 5.1.1 (framework: 5.1.1, easyblocks: 5.1.1) on host ..."
44-
command="$shell -c 'source init/lmod/$shell 2>/dev/null; module load EasyBuild/${EXPECTED_EASYBUILD_VERSION}; eb --version | cut -d \" \" -f4'"
45-
assert "$command" "$EXPECTED_EASYBUILD_VERSION"
46-
# Test 5: Load EasyBuild module and check path
47-
EASYBUILD_PATH=$($shell -c "source init/lmod/$shell 2>/dev/null; module load EasyBuild/${EXPECTED_EASYBUILD_VERSION}; which eb")
48-
# escape the dots in ${EASYBUILD_VERSION}
49-
PATTERN="/cvmfs/software\.eessi\.io/versions/$EESSI_VERSION/software/linux/x86_64/(intel/haswell|amd/zen3)/software/EasyBuild/${EXPECTED_EASYBUILD_VERSION//./\\.}/bin/eb"
50-
echo "$EASYBUILD_PATH" | grep -E "$PATTERN"
51-
assert_raises 'echo "$EASYBUILD_PATH" | grep -E "$PATTERN"'
52-
53-
#End Test Suite
54-
assert_end "source_eessi_$shell"
55-
fi
56-
done
34+
# TEST 1: Source Script and check Module Output
35+
expected="Module for EESSI/$EESSI_VERSION loaded successfully"
36+
assert "$shell -c 'source init/lmod/$shell' 2>&1 " "${expected}"
37+
38+
# TEST 2: Check if module overviews first section is the loaded EESSI module
39+
if [ "$shell" = "csh" ]; then
40+
# module is defined as alias, but aliases are only retained in interactive
41+
# shells we work around this by creating a .cshrc file (which sources the
42+
# init script), and then simply run the remaining commands
43+
echo "source init/lmod/$shell" > ~/.cshrc
44+
MODULE_SECTIONS=($($shell -c "module ov" 2>&1 | grep -e '---'))
45+
else
46+
MODULE_SECTIONS=($($shell -c "source init/lmod/$shell 2>/dev/null; module ov 2>&1 | grep -e '---'"))
47+
fi
48+
PATTERN="/cvmfs/software\.eessi\.io/versions/$EESSI_VERSION/software/linux/x86_64/(intel/haswell|amd/zen3)/modules/all"
49+
assert_raises 'echo "${MODULE_SECTIONS[1]}" | grep -E "$PATTERN"'
50+
51+
# TEST 3: Check if module overviews second section is the EESSI init module
52+
assert "echo ${MODULE_SECTIONS[4]}" "/cvmfs/software.eessi.io/versions/$EESSI_VERSION/init/modules"
5753

54+
# TEST 4: Load EasyBuild module and check version
55+
# eb --version outputs: "This is EasyBuild 5.1.1 (framework: 5.1.1, easyblocks: 5.1.1) on host ..."
56+
if [ "$shell" = "csh" ]; then
57+
echo "source init/lmod/$shell" > ~/.cshrc
58+
command="$shell -c 'module load EasyBuild/${EXPECTED_EASYBUILD_VERSION}; eb --version' | cut -d \" \" -f4"
59+
else
60+
command="$shell -c 'source init/lmod/$shell 2>/dev/null; module load EasyBuild/${EXPECTED_EASYBUILD_VERSION}; eb --version | cut -d \" \" -f4'"
61+
fi
62+
assert "$command" "$EXPECTED_EASYBUILD_VERSION"
63+
64+
# TEST 5: Load EasyBuild module and check path
65+
if [ "$shell" = "csh" ]; then
66+
echo "source init/lmod/$shell" > ~/.cshrc
67+
EASYBUILD_PATH=$($shell -c "module load EasyBuild/${EXPECTED_EASYBUILD_VERSION}; which eb")
68+
else
69+
EASYBUILD_PATH=$($shell -c "source init/lmod/$shell 2>/dev/null; module load EasyBuild/${EXPECTED_EASYBUILD_VERSION}; which eb")
70+
fi
71+
# escape the dots in ${EASYBUILD_VERSION}
72+
PATTERN="/cvmfs/software\.eessi\.io/versions/$EESSI_VERSION/software/linux/x86_64/(intel/haswell|amd/zen3)/software/EasyBuild/${EXPECTED_EASYBUILD_VERSION//./\\.}/bin/eb"
73+
echo "$EASYBUILD_PATH" | grep -E "$PATTERN"
74+
assert_raises 'echo "$EASYBUILD_PATH" | grep -E "$PATTERN"'
75+
76+
# End Test Suite
77+
assert_end "source_eessi_$shell"
78+
fi
79+
done
5880

5981
# RESET PAGER
6082
export LMOD_PAGER=

.github/workflows/tests_init_module.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ jobs:
2727
- name: Check out software-layer repository
2828
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
2929

30+
- name: Avoid processing man-db trigger
31+
run: |
32+
# avoid processing trigger for man-db (seems to slow down installation)
33+
echo "set man-db/auto-update false" | sudo debconf-communicate
34+
sudo dpkg-reconfigure man-db
35+
3036
- name: Mount EESSI CernVM-FS pilot repository
3137
uses: cvmfs-contrib/github-action-cvmfs@55899ca74cf78ab874bdf47f5a804e47c198743c # v4.0
3238
with:
@@ -46,7 +52,7 @@ jobs:
4652
- name: Install missing shells
4753
run: |
4854
sudo apt update
49-
sudo apt install zsh ksh fish
55+
sudo apt install zsh ksh fish tcsh
5056
echo "# INIT ZSH" > ~/.zshrc
5157
5258
- name: Run tests for available shells

init/lmod/csh

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
11
# Choose an EESSI CVMFS repository
2-
if (! $?EESSI_CVMFS_REPO) then; set EESSI_CVMFS_REPO = "/cvmfs/software.eessi.io"; endif
2+
if (! $?EESSI_CVMFS_REPO) then
3+
set EESSI_CVMFS_REPO = "/cvmfs/software.eessi.io"
4+
endif
35
# Choose an EESSI version
46
setenv EESSI_VERSION_DEFAULT "__EESSI_VERSION_DEFAULT__"
5-
if (! $?EESSI_VERSION) then; set EESSI_VERSION = "${EESSI_VERSION_DEFAULT}"; endif
7+
if (! $?EESSI_VERSION) then
8+
set EESSI_VERSION = "${EESSI_VERSION_DEFAULT}"
9+
endif
610
# Path to top-level module tree
711
setenv MODULEPATH "${EESSI_CVMFS_REPO}/versions/${EESSI_VERSION}/init/modules"
8-
source "${EESSI_CVMFS_REPO}/versions/${EESSI_VERSION}/compat/linux/$(uname -m)/usr/share/Lmod/init/csh"
12+
source "${EESSI_CVMFS_REPO}/versions/${EESSI_VERSION}/compat/linux/`uname -m`/usr/share/Lmod/init/csh"
913

1014
if (! $?__Init_Default_Modules ) then
11-
setenv __Init_Default_Modules 1;
15+
setenv __Init_Default_Modules 1
1216

13-
## ability to predefine elsewhere the default list
14-
if (! $?LMOD_SYSTEM_DEFAULT_MODULES) then; setenv LMOD_SYSTEM_DEFAULT_MODULES "EESSI/$EESSI_VERSION"; endif
15-
module --initial_load --no_redirect restore
17+
# ability to predefine elsewhere the default list
18+
if (! $?LMOD_SYSTEM_DEFAULT_MODULES) then
19+
setenv LMOD_SYSTEM_DEFAULT_MODULES "EESSI/${EESSI_VERSION}"
20+
endif
21+
module --initial_load --no_redirect restore
1622
else
17-
module refresh
23+
module refresh
1824
endif
19-

0 commit comments

Comments
 (0)