|
# documentation: https://help.github.com/en/articles/workflow-syntax-for-github-actions |
|
name: Tests for eessi_container.sh script |
|
on: |
|
push: |
|
branches: [ "main" ] |
|
pull_request: |
|
workflow_dispatch: |
|
permissions: |
|
contents: read # to fetch code (actions/checkout) |
|
jobs: |
|
eessi_container_script: |
|
runs-on: ubuntu-24.04 |
|
strategy: |
|
fail-fast: false |
|
matrix: |
|
SCRIPT_TEST: |
|
- help |
|
- listrepos_default |
|
- listrepos_custom |
|
- no_cvmfs_mounts |
|
- exec |
|
- run |
|
- shell |
|
- container |
|
- resume |
|
- unionfs |
|
# FIXME disabled because '--access rw' is not working in CI environment |
|
#- readwrite |
|
#- save |
|
steps: |
|
- name: Check out software-layer repository |
|
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 |
|
|
|
- name: install Apptainer |
|
run: | |
|
./install_apptainer_ubuntu.sh |
|
|
|
- name: Collect info on test environment |
|
run: | |
|
mount |
|
df -h |
|
|
|
- name: Test eessi_container.sh script |
|
run: | |
|
test_cmd="cat /etc/os-release" |
|
out_pattern="Debian GNU/Linux 12" |
|
|
|
if [[ ${{matrix.SCRIPT_TEST}} == 'help' ]]; then |
|
./eessi_container.sh --help |
|
|
|
# test use of --list-repos without custom repos.cfg |
|
elif [[ ${{matrix.SCRIPT_TEST}} == 'listrepos_default' ]]; then |
|
outfile=out_listrepos.txt |
|
./eessi_container.sh --verbose --list-repos | tee ${outfile} |
|
# make sure that the default EESSI software repository is available |
|
grep "software.eessi.io" ${outfile} |
|
|
|
# test use of --list-repos with custom repos.cfg |
|
elif [[ ${{matrix.SCRIPT_TEST}} == 'listrepos_custom' ]]; then |
|
outfile=out_listrepos.txt |
|
outfile2=out_listrepos_2.txt |
|
mkdir -p ${PWD}/cfg |
|
echo "[EESSI/20AB.CD]" > cfg/repos.cfg |
|
echo "repo_version = 20AB.CD" >> cfg/repos.cfg |
|
echo "[EESSI/20HT.TP]" >> cfg/repos.cfg |
|
echo "repo_version = 20HT.TP" >> cfg/repos.cfg |
|
./eessi_container.sh --verbose --list-repos | tee ${outfile} |
|
# make sure that the default EESSI software repository is available |
|
grep "software.eessi.io" ${outfile} |
|
|
|
export EESSI_REPOS_CFG_DIR_OVERRIDE=${PWD}/cfg |
|
./eessi_container.sh --verbose --list-repos | tee ${outfile2} |
|
grep "EESSI/20AB.CD" ${outfile2} |
|
|
|
# test use of --repository None |
|
elif [[ ${{matrix.SCRIPT_TEST}} == 'no_cvmfs_mounts' ]]; then |
|
outfile=out_nocvmfs.txt |
|
./eessi_container.sh --verbose --repository None --mode exec mount | tee ${outfile} |
|
# make sure that there are no CVMFS mounts in the container, i.e. mount does not have any lines line: |
|
# cvmfs2 on /cvmfs/... |
|
! grep "^cvmfs" ${outfile} |
|
|
|
# test use of --mode exec |
|
elif [[ ${{matrix.SCRIPT_TEST}} == 'exec' ]]; then |
|
outfile=out_exec.txt |
|
echo "${test_cmd}" > test_script.sh |
|
chmod u+x test_script.sh |
|
export SINGULARITY_BIND="$PWD:/test" |
|
./eessi_container.sh --verbose --mode exec /test/test_script.sh | tee ${outfile} |
|
grep "${out_pattern}" ${outfile} |
|
|
|
# test use of --mode run, which should now print a warning |
|
elif [[ ${{matrix.SCRIPT_TEST}} == 'run' ]]; then |
|
outfile=out_run.txt |
|
echo "${test_cmd}" > test_script.sh |
|
chmod u+x test_script.sh |
|
export SINGULARITY_BIND="$PWD:/test" |
|
./eessi_container.sh --verbose --mode run /test/test_script.sh | tee ${outfile} |
|
grep "${out_pattern}" ${outfile} |
|
warn_message="Note: the behaviour of the run mode has changed." |
|
grep "${warn_message}" ${outfile} |
|
|
|
# test use of --mode shell |
|
elif [[ ${{matrix.SCRIPT_TEST}} == 'shell' ]]; then |
|
outfile=out_shell.txt |
|
./eessi_container.sh --verbose --mode shell <<< "${test_cmd}" 2>&1 | tee ${outfile} |
|
grep "${out_pattern}" ${outfile} |
|
|
|
# test use of --container option, using a totally different container; |
|
# cfr. https://github.com/easybuilders/easybuild-containers |
|
elif [[ ${{matrix.SCRIPT_TEST}} == 'container' ]]; then |
|
outfile=out_container.txt |
|
container="docker://ghcr.io/eessi/build-node:debian10" |
|
./eessi_container.sh --verbose --container ${container} --mode shell <<< "${test_cmd}" 2>&1 | tee ${outfile} |
|
grep "Debian GNU/Linux 10" ${outfile} |
|
|
|
# test use of '--access rw' to get write access in container |
|
elif [[ ${{matrix.SCRIPT_TEST}} == 'readwrite' ]]; then |
|
outfile=out_readwrite.txt |
|
fn="test_${RANDOM}.txt" |
|
echo "touch /cvmfs/software.eessi.io/${fn}" > test_script.sh |
|
chmod u+x test_script.sh |
|
export SINGULARITY_BIND="$PWD:/test" |
|
./eessi_container.sh --verbose --access rw --mode exec /test/test_script.sh > ${outfile} |
|
|
|
tmpdir=$(grep "\-\-resume" ${outfile} | sed "s/.*--resume \([^']*\).*/\1/g") |
|
# note: must use '--access rw' again here, since touched file is in overlay upper dir |
|
./eessi_container.sh --verbose --resume ${tmpdir} --access rw --mode shell <<< "ls -l /cvmfs/software.eessi.io/${fn}" > ${outfile} |
|
grep "/cvmfs/software.eessi.io/${fn}$" $outfile |
|
|
|
# test use of --resume |
|
elif [[ ${{matrix.SCRIPT_TEST}} == 'resume' ]]; then |
|
outfile=out_resume.txt |
|
./eessi_container.sh --verbose --mode shell <<< "${test_cmd}" > ${outfile} |
|
|
|
tmpdir=$(grep "\-\-resume" ${outfile} | sed "s/.*--resume \([^']*\).*/\1/g") |
|
rm -f ${outfile} |
|
|
|
# make sure that container image exists |
|
test -f ${tmpdir}/ghcr.io_eessi_build_node_debian12.sif || (echo "Container image not found in ${tmpdir}" >&2 && ls ${tmpdir} && exit 1) |
|
|
|
./eessi_container.sh --verbose --resume ${tmpdir} --mode shell <<< "${test_cmd}" > ${outfile} |
|
cat ${outfile} |
|
grep "Resuming from previous run using temporary storage at ${tmpdir}" ${outfile} |
|
grep "${out_pattern}" ${outfile} |
|
|
|
# test use of --save (+ --resume) |
|
elif [[ ${{matrix.SCRIPT_TEST}} == 'save' ]]; then |
|
outfile=out_save.txt |
|
fn="test_${RANDOM}.txt" |
|
test_cmd="touch /cvmfs/software.eessi.io/${fn}" |
|
./eessi_container.sh --verbose --mode shell --access rw --save test-save.tar <<< "${test_cmd}" 2>&1 | tee ${outfile} |
|
rm -f ${outfile} |
|
|
|
./eessi_container.sh --verbose --mode shell --access rw --resume test-save.tar <<< "ls -l /cvmfs/software.eessi.io/${fn}" > ${outfile} |
|
grep "/cvmfs/software.eessi.io/${fn}$" $outfile |
|
|
|
tar tfv test-save.tar | grep "overlay-upper/${fn}" |
|
|
|
# test use of --overlay-tool unionfs |
|
elif [[ ${{matrix.SCRIPT_TEST}} == 'unionfs' ]]; then |
|
outfile=out_unionfs.txt |
|
container="docker://ghcr.io/eessi/build-node:debian12" |
|
export SINGULARITY_BIND="$PWD:/test" |
|
echo 'ls -ld /cvmfs*/software.eessi.io/*' > test_script.sh |
|
chmod u+x test_script.sh |
|
./eessi_container.sh --verbose --container ${container} --access rw --overlay-tool unionfs --mode exec /test/test_script.sh 2>&1 | tee ${outfile} |
|
for pattern in "/cvmfs/software.eessi.io/versions" "/cvmfs_ro/software.eessi.io/versions"; do |
|
grep "${pattern}" ${outfile} || (echo "Pattern '${pattern}' not found in ${outfile}"; exit 1) |
|
done |
|
|
|
else |
|
echo "Unknown test case: ${{matrix.SCRIPT_TEST}}" >&2 |
|
exit 1 |
|
fi |