Skip to content
Snippets Groups Projects
stack_env.sh 2.33 KiB
Newer Older
Nicolas Richart's avatar
Nicolas Richart committed
#!/usr/bin/env sh

if [ $# -eq 1 ]
then
    name=$1
    suffix="-${name}"
    if [ "${name}" == "gcc" ]
    then
        suffix=""
    fi
else
    suffix=""
fi


Nicolas Richart's avatar
Nicolas Richart committed
export STACK_CONFIG_PATH=${CI_PROJECT_DIR}/stacks/${stack}
export STACK_CONFIG=${STACK_CONFIG_PATH}/config.json
Nicolas Richart's avatar
Nicolas Richart committed
export SPACK_VERSION=$(jq -r .spack.version ${STACK_CONFIG})
export MOUNT_POINT=$(jq -r .stack.mount_point ${STACK_CONFIG})
export STACK_VERSION=$(jq -r .stack.version ${STACK_CONFIG})
export STACK_LOCATION=${MOUNT_POINT}/${stack}/${environment}/${STACK_VERSION}

export full_environment=${environment}${suffix}
export SPACK_SYSTEM_CONFIG_PATH=${STACK_LOCATION}/spack/var/spack/environments/${full_environment}
#export SPACK_USER_CACHE_PATH=$(mktemp -p /tmp -d slurm_user_cache_XXXXXXX)
#export SPACK_USER_CONFIG_PATH=$(mktemp -p /tmp -d slurm_user_config_XXXXXXX)
Nicolas Richart's avatar
Nicolas Richart committed

export SPACK_VERSION=$(jq -r .spack.version ${STACK_CONFIG})

env_json=$(jq '.stack.environments | to_entries | .[] | select(.key == env.environment) | .value' ${STACK_CONFIG})

export environment_type=$(echo $env_json | jq -Mrc '.type // "local_cluster"')
export target=$(echo $env_json | jq -Mrc '.target')
export accelerator=$(echo $env_json | jq -Mrc '.accelerator // "none"')

if [ "$accelerator" != "none" ]
then
    export acc_type=$(echo $env_json | jq -Mrc '.accelerator.type')
    export acc_arch=$(echo $env_json | jq -Mrc '.accelerator.arch')
Nicolas Richart's avatar
Nicolas Richart committed
else
Nicolas Richart's avatar
Nicolas Richart committed
    export acc_type="none"
set +u
if [ "x$GPG_KEY_ID" == "x" ]
then
    export GPG_KEY_ID=$(gpg --show-keys $GPG_PRIVATE_KEY 2> /dev/null | head -n 2 | tail -1)
fi
set -u

Nicolas Richart's avatar
Nicolas Richart committed
echo "STACK_CONFIG_PATH: ${STACK_CONFIG_PATH}"
echo "STACK_CONFIG: ${STACK_CONFIG}"
echo "SPACK_VERSION: ${SPACK_VERSION}"
echo "MOUNT_POINT: ${MOUNT_POINT}"
echo "STACK_LOCATION: ${STACK_LOCATION}"
echo "SPACK_SYSTEM_CONFIG_PATH: ${SPACK_SYSTEM_CONFIG_PATH}"

if [ "$accelerator" == "none" ]
then
Nicolas Richart's avatar
Nicolas Richart committed
    echo "{ \"target\": \"${target}\", \"type\": \"${environment_type}\", \"accelerator\": \"${accelerator}\" }" | jq -C .
Nicolas Richart's avatar
Nicolas Richart committed
    echo "{ \"target\": \"${target}\", \"type\": \"${environment_type}\", \"accelerator\": ${accelerator} }" | jq -C .
# echo "SPACK_USER_CACHE_PATH: ${SPACK_USER_CACHE_PATH}"
# echo "SPACK_USER_CONFIG_PATH: ${SPACK_USER_CONFIG_PATH}"

if [ "x${CI_DEFAULT_BRANCH}" != "x" ]
then
   squash_base=${CI_DEFAULT_BRANCH}
else
   squash_base=main
fi