File indexing completed on 2025-01-17 09:57:16
0001
0002
0003 set -e
0004
0005 echo "::group::Checking if there is a working CVMFS mount"
0006
0007 if [ ! -d "/cvmfs/singularity.opensciencegrid.org" ]; then
0008 echo "The directory /cvmfs/singularity.opensciencegrid.org cannot be accessed!"
0009 echo "Make sure you are using the cvmfs-contrib/github-action-cvmfs@v2 action"
0010 exit 1
0011 fi
0012
0013 echo "CVMFS mount present"
0014 echo "::endgroup::"
0015
0016 if [ -z "${SANDBOX_PATH}" ]; then
0017 SANDBOX_PATH="/cvmfs/singularity.opensciencegrid.org/eicweb/${EIC_SHELL_PLATFORM_RELEASE}"
0018 if [[ "${EIC_SHELL_RELEASE}" == *"dev"* ]]; then
0019 SANDBOX_PATH="/cvmfs/singularity.opensciencegrid.org/eicweb/${EIC_SHELL_PLATFORM}:${EIC_SHELL_RELEASE}"
0020 fi
0021 fi
0022
0023 echo "Full EIC shell path is ${SANDBOX_PATH}"
0024
0025 if [ ! -d "${SANDBOX_PATH}" ]; then
0026 echo "Did not find an EIC shell under this path!"
0027 exit 1
0028 fi
0029
0030 echo "#!/usr/bin/env bash
0031 export LC_ALL=C
0032 set -Euo pipefail
0033 trap 's=\$?; echo \"\$0: Error on line \"\$LINENO\": \$BASH_COMMAND\"; exit \$s' ERR
0034 IFS=\$'\n\t'
0035 set -e
0036
0037 ${SETUP:+source ${SETUP}}
0038
0039 ${RUN}
0040 " > ${GITHUB_WORKSPACE}/action_payload.sh
0041 chmod a+x ${GITHUB_WORKSPACE}/action_payload.sh
0042
0043 if [[ ${APPTAINER_VERSION} == "latest" ]] ; then
0044 v=$(curl -sL --retry 5 https://api.github.com/repos/apptainer/apptainer/releases/latest | jq -r ".tag_name")
0045
0046 while [[ ${v} == "null" ]] ; do
0047 sleep 5
0048 v=$(curl -sL --retry 5 https://api.github.com/repos/apptainer/apptainer/releases/latest | jq -r ".tag_name")
0049 done
0050 else
0051 v=${APPTAINER_VERSION}
0052 fi
0053
0054 echo "::group::Installing Apptainer ${v}"
0055 for deb in "apptainer_${v/v/}_amd64.deb" "apptainer-suid_${v/v/}_amd64.deb"; do
0056 sudo wget --tries 5 --quiet --timestamping --output-document /var/cache/apt/archives/${deb} https://github.com/apptainer/apptainer/releases/download/${v}/${deb}
0057 sudo apt-get -q -y install /var/cache/apt/archives/${deb}
0058 done
0059 echo "::endgroup::"
0060
0061 worker=$(echo ${SANDBOX_PATH} | sha256sum | awk '{print$1}')
0062 if apptainer instance list | grep ${worker} ; then
0063 echo "Reusing exisitng Apptainer image from ${SANDBOX_PATH}"
0064 else
0065 echo "Starting Apptainer image from ${SANDBOX_PATH}"
0066 apptainer instance start --bind /cvmfs --bind ${GITHUB_WORKSPACE}:${GITHUB_WORKSPACE} --network ${NETWORK_TYPES:-bridge} ${SANDBOX_PATH} ${worker}
0067 fi
0068
0069 echo "####################################################################"
0070 echo "###################### Executing user payload ######################"
0071 echo "VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV"
0072
0073 apptainer exec instance://${worker} /bin/bash -c "cd ${GITHUB_WORKSPACE}; ./action_payload.sh"