-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor job script creation into its own shell script. This should improve general readability. Also use the opportunity and create a dedicated, temporary home directory for the CI run. This way all files created in the home directory by the job do not end up in the real one. (cherry picked from commit e4ecb3c)
- Loading branch information
1 parent
2598b60
commit fa7108b
Showing
3 changed files
with
46 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#! /bin/bash | ||
|
||
if [ $# -lt 4 ] | ||
then | ||
echo "*** Please call like: $0 LABEL CONTAINER JOBSH CTEST [CTESTARG ...]" | ||
exit 1 | ||
fi | ||
|
||
label="$1"; shift | ||
container="$1"; shift | ||
jobsh="$1"; shift | ||
# Convert commandline array into single string, with proper quoting | ||
ctestcmd="$(printf ' %q' "$@")" | ||
# Strip leading space | ||
ctestcmd="${ctestcmd:1}" | ||
|
||
echo "*** Creating job script ..: ${jobsh}" | ||
|
||
( | ||
echo '# #! /bin/bash' | ||
echo "# export LABEL=${label}" | ||
echo ' echo "*** Job started at .......: $(date -R)"' | ||
echo ' echo "*** Job ID ...............: $SLURM_JOB_ID"' | ||
echo ' echo "*** Compute node .........: $(hostname -f)"' | ||
echo "# source <(sed -e '/^#/d' -e '/^export/!s/^.*=/export &/' /etc/environment)" | ||
printf '# ./test/test-start-container.sh %q %q\n' "${container}" "${ctestcmd}" | ||
echo '# retval=$?' | ||
echo '# mkdir -p build' | ||
echo '# echo $retval >"build/${LABEL}-last-exit-code"' | ||
echo '# exit $retval' | ||
echo 'newhomedir="$(mktemp --tmpdir -d FairRoot-CI-home.XXXXXX)"' | ||
echo ' echo "*** Temporary homedir ....: $newhomedir"' | ||
echo ' unset http_proxy' | ||
echo ' unset HTTP_PROXY' | ||
printf 'singularity exec -B/shared -H "${newhomedir}" %q bash -l -c %q\n' \ | ||
"${SINGULARITY_CONTAINER_ROOT}/fairroot/${container}" \ | ||
"${ctestcmd}" | ||
) >> "$jobsh" | ||
|
||
echo "*** Content:" | ||
sed -e 's/^/ /' "$jobsh" |
File renamed without changes.