forked from EESSI/software-layer
-
Notifications
You must be signed in to change notification settings - Fork 1
130 lines (119 loc) · 6.67 KB
/
tests_scripts.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# documentation: https://help.github.com/en/articles/workflow-syntax-for-github-actions
name: Tests for scripts
on:
push:
paths:
- create_directory_tarballs.sh
- create_lmodsitepackage.py
- eessi_container.sh
- EESSI-install-software.sh
- install_software_layer.sh
- load_easybuild_module.sh
- run_in_compat_layer_env.sh
- scripts/utils.sh
- update_lmod_cache.sh
pull_request:
paths:
- create_directory_tarballs.sh
- create_lmodsitepackage.py
- eessi_container.sh
- EESSI-install-software.sh
- install_software_layer.sh
- load_easybuild_module.sh
- run_in_compat_layer_env.sh
- scripts/utils.sh
- update_lmod_cache.sh
permissions:
contents: read # to fetch code (actions/checkout)
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: install Apptainer
run: |
./install_apptainer_ubuntu.sh
- name: prepare repos info for NESSI
run: |
curl -Ls https://github.com/NorESSI/filesystem-layer/tarball/v0.4.1 | tar xzf - --strip-components=1 --no-wildcards-match-slash --wildcards '*/repos/'
- name: list available repos
run: |
export EESSI_REPOS_CFG_DIR_OVERRIDE=${PWD}/repos
./eessi_container.sh --list-repos
- name: test load_easybuild_module.sh script
run: |
# bind current directory into container as /software-layer
export SINGULARITY_BIND="${PWD}:/software-layer"
# can't test with EasyBuild versions older than v4.5.2 when using EESSI 2023.06,
# since Python in compat layer is Python 3.11.x;
# testing with a single EasyBuild version takes a while in GitHub Actions, so stick to a single sensible version
for EB_VERSION in '4.6.0'; do
# Create script that uses load_easybuild_module.sh which we can run in compat layer environment
# note: Be careful with single vs double quotes below!
# ${EB_VERSION} should be expanded, so use double quotes;
# For statements using variables that are only defined in the script, like ${EASYBUILD_INSTALLPATH},
# use single quotes to avoid expansion while creating the script.
test_script="${PWD}/eb-${EB_VERSION}.sh"
echo '#!/bin/bash' > ${test_script}
# both $EB and $TMPDIR environment must be set, required by load_easybuild_module.sh script
echo 'export EB="eb"' >> ${test_script}
echo 'export TMPDIR=$(mktemp -d)' >> ${test_script}
# set up environment to have utility functions in place that load_easybuild_module.sh script relies on,
# along with $EESSI_* environment variables, and Lmod
echo 'ls -l /software-layer/' >> ${test_script}
echo 'source /software-layer/scripts/utils.sh' >> ${test_script}
echo 'source /software-layer/init/eessi_environment_variables' >> ${test_script}
echo 'source ${EPREFIX}/usr/share/Lmod/init/bash' >> ${test_script}
# minimal configuration for EasyBuild so we can test installation aspect of load_easybuild_module.sh script
echo "export EASYBUILD_INSTALLPATH=/tmp/eb-${EB_VERSION}" >> ${test_script}
echo 'module use ${EASYBUILD_INSTALLPATH}/modules/all' >> ${test_script}
echo '' >> ${test_script}
echo "source /software-layer/load_easybuild_module.sh ${EB_VERSION}" >> ${test_script}
echo 'module list' >> ${test_script}
echo 'eb --version' >> ${test_script}
chmod u+x ${test_script}
# run wrapper script + capture & check output
out="${PWD}/eb-${EB_VERSION}.out"
export EESSI_REPOS_CFG_DIR_OVERRIDE=${PWD}/repos
# skip installation of CUDA SDKs, since this is too heavy for CI
sed -i "s@./EESSI-install-software.sh@./EESSI-install-software.sh --skip-cuda-install@g" install_software_layer.sh
./eessi_container.sh --access rw --mode run --verbose --repository nessi.no-2023.06-software /software-layer/run_in_compat_layer_env.sh /software-layer/eb-${EB_VERSION}.sh 2>&1 | tee ${out}
pattern="^This is EasyBuild ${EB_VERSION} "
grep "${pattern}" ${out} || (echo "Pattern '${pattern}' not found in output!" && exit 1)
done
- name: test install_software_layer.sh script
run: |
# bind current directory into container as /software-layer
export SINGULARITY_BIND="${PWD}:/software-layer"
# force using x86_64/generic, to avoid triggering an installation from scratch
sed -i "s@./EESSI-install-software.sh@\"export EESSI_SOFTWARE_SUBDIR_OVERRIDE='x86_64/generic'; ./EESSI-install-software.sh\"@g" install_software_layer.sh
export EESSI_REPOS_CFG_DIR_OVERRIDE=${PWD}/repos
./eessi_container.sh --mode run --verbose --repository nessi.no-2023.06-software /software-layer/install_software_layer.sh
- name: test create_directory_tarballs.sh script
run: |
# bind current directory into container as /software-layer
export SINGULARITY_BIND="${PWD}:/software-layer"
# scripts need to be copied to /tmp,
# since create_directory_tarballs.sh must be accessible from within build container
export EESSI_REPOS_CFG_DIR_OVERRIDE=${PWD}/repos
./eessi_container.sh --mode run --verbose --repository nessi.no-2023.06-software /software-layer/create_directory_tarballs.sh 2023.06
# check if tarballs have been produced
ls -l *.tar.gz
- name: test create_lmodsitepackage.py script
run: |
# bind current directory into container as /software-layer
export SINGULARITY_BIND="${PWD}:/software-layer"
# Creates .lmod/SitePackage.lua in current dir, which then gets bind-mounted into /software-layer
python3 create_lmodsitepackage.py .
# run some commands to make sure that generated Lmod SitePackage file works
test_script="${PWD}/test_lmod_sitepackage.sh"
echo '#!/bin/bash' > ${test_script}
echo 'export LMOD_PACKAGE_PATH="/software-layer/.lmod"' > ${test_script}
echo 'ml --config' >> ${test_script}
chmod u+x ${test_script}
out="${PWD}/test_create_lmodsitepackage.out"
./eessi_container.sh --mode run --verbose /software-layer/run_in_compat_layer_env.sh /software-layer/test_lmod_sitepackage.sh 2>&1 | tee ${out}
for pattern in "^Site Pkg location.*/software-layer/.lmod/SitePackage.lua" "LMOD_SITEPACKAGE_LOCATION.*/software-layer/.lmod/SitePackage.lua"; do
grep "${pattern}" ${out} || (echo "Pattern '${pattern}' not found in output!" && exit 1)
done