Skip to content

Commit

Permalink
Using Spack build cache
Browse files Browse the repository at this point in the history
  • Loading branch information
adrienbernede committed Jun 7, 2024
1 parent 18afd78 commit aa3d7a8
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 26 deletions.
15 changes: 14 additions & 1 deletion .gitlab/custom-jobs-and-variables.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
###############################################################################
# Copyright (c) 2022-23, Lawrence Livermore National Security, LLC and RADIUSS
# Copyright (c) 2022-24, Lawrence Livermore National Security, LLC and RADIUSS
# project contributors. See the COPYRIGHT file for details.
#
# SPDX-License-Identifier: (MIT)
Expand All @@ -16,6 +16,7 @@ variables:
# Arguments for top level allocation
RUBY_SHARED_ALLOC: "--exclusive --reservation=ci --time=5 --nodes=2"
# Arguments for job level allocation
# Note: We repeat the reservation, necessary when jobs are manually re-triggered.
RUBY_JOB_ALLOC: "--overlap --reservation=ci --nodes=1"
# Project specific variants for ruby
PROJECT_RUBY_VARIANTS: "+tests"
Expand Down Expand Up @@ -69,3 +70,15 @@ variables:
artifacts:
reports:
junit: junit.xml

.reproducer_vars:
script:
- |
echo -e "
# Required variables \n
export MODULE_LIST=\"${MODULE_LIST}\" \n
export SPEC=\"${SPEC//\"/\\\"}\" \n
# Allow to set job script for debugging (only this differs from CI) \n
export DEBUG_MODE=true \n
# Using the CI build cache is optional and requires a token. Set it like so: \n
# export REGISTRY_TOKEN=\"<your token here>\" \n"
4 changes: 1 addition & 3 deletions .gitlab/jobs/corona.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
# Override reproducer section to define project specific variables.
.corona_reproducer_vars:
script:
- |
echo -e "export MODULE_LIST=\"${MODULE_LIST}\""
echo -e "export SPEC=\"${SPEC//\"/\\\"}\""
- !reference [.reproducer_vars, script]

# With GitLab CI, included files cannot be empty.
variables:
Expand Down
4 changes: 1 addition & 3 deletions .gitlab/jobs/lassen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
# Override reproducer section to define project specific variables.
.lassen_reproducer_vars:
script:
- |
echo -e "export MODULE_LIST=\"${MODULE_LIST}\""
echo -e "export SPEC=\"${SPEC//\"/\\\"}\""
- !reference [.reproducer_vars, script]

# With GitLab CI, included files cannot be empty.
variables:
Expand Down
4 changes: 1 addition & 3 deletions .gitlab/jobs/poodle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
# Override reproducer section to define project specific variables.
.poodle_reproducer_vars:
script:
- |
echo -e "export MODULE_LIST=\"${MODULE_LIST}\""
echo -e "export SPEC=\"${SPEC//\"/\\\"}\""
- !reference [.reproducer_vars, script]

# With GitLab CI, included files cannot be empty.
variables:
Expand Down
4 changes: 1 addition & 3 deletions .gitlab/jobs/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
# Override reproducer section to define project specific variables.
.ruby_reproducer_vars:
script:
- |
echo -e "export MODULE_LIST=\"${MODULE_LIST}\""
echo -e "export SPEC=\"${SPEC//\"/\\\"}\""
- !reference [.reproducer_vars, script]

# With GitLab CI, included files cannot be empty.
variables:
Expand Down
4 changes: 1 addition & 3 deletions .gitlab/jobs/tioga.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
# Override reproducer section to define project specific variables.
.tioga_reproducer_vars:
script:
- |
echo -e "export MODULE_LIST=\"${MODULE_LIST}\""
echo -e "export SPEC=\"${SPEC//\"/\\\"}\""
- !reference [.reproducer_vars, script]

# With GitLab CI, included files cannot be empty.
variables:
Expand Down
70 changes: 62 additions & 8 deletions scripts/gitlab/build-and-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ then
fi

###############################################################################
# Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Caliper
# Copyright (c) 2016-24, Lawrence Livermore National Security, LLC and Caliper
# project contributors. See the Caliper/LICENSE file for details.
#
# SPDX-License-Identifier: (BSD-3-Clause)
Expand All @@ -26,6 +26,27 @@ spec=${SPEC:-""}
module_list=${MODULE_LIST:-""}
job_unique_id=${CI_JOB_ID:-""}
use_dev_shm=${USE_DEV_SHM:-true}
spack_debug=${SPACK_DEBUG:-false}
debug_mode=${DEBUG_MODE:-false}

if [[ ${debug_mode} == true ]]
then
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo "~~~~~ Debug mode:"
echo "~~~~~ - Spack debug mode."
echo "~~~~~ - Deactivated shared memory."
echo "~~~~~ - Do not push to buildcache."
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
use_dev_shm=false
spack_debug=true
fi

# REGISTRY_TOKEN allows you to provide your own personal access token to the CI
# registry. Be sure to set the token with at least read access to the registry.
registry_token=${REGISTRY_TOKEN:-""}
ci_registry_user=${CI_REGISTRY_USER:-"${USER}"}
ci_registry_image=${CI_REGISTRY_IMAGE:-"czregistry.llnl.gov:5050/radiuss/raja"}
ci_registry_token=${CI_JOB_TOKEN:-"${registry_token}"}

if [[ -n ${module_list} ]]
then
Expand Down Expand Up @@ -63,6 +84,15 @@ echo "project_dir: ${project_dir}"

mkdir -p ${prefix}

spack_cmd="${prefix}/spack/bin/spack"
spack_env_path="${prefix}/spack_env"
uberenv_cmd="./scripts/uberenv/uberenv.py"
if [[ ${spack_debug} == true ]]
then
spack_cmd="${spack_cmd} --debug --stacktrace"
uberenv_cmd="${uberenv_cmd} --spack-debug"
fi

# Dependencies
if [[ "${option}" != "--build-only" && "${option}" != "--test-only" ]]
then
Expand All @@ -72,7 +102,7 @@ then

if [[ -z ${spec} ]]
then
echo "SPEC is undefined, aborting..."
echo "[Error]: SPEC is undefined, aborting..."
exit 1
fi

Expand All @@ -87,14 +117,38 @@ then
mkdir -p ${spack_user_cache}

# generate cmake cache file with uberenv and radiuss spack package
./scripts/uberenv/uberenv.py --spec="${spec}" ${prefix_opt}
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo "~~~~~ Spack setup and environment "
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
${uberenv_cmd} --setup-and-env-only --spec="${spec}" ${prefix_opt}

if [[ -n ${ci_registry_token} ]]
then
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo "~~~~~ GitLab registry as Spack Build Cache "
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
${spack_cmd} -D ${spack_env_path} mirror add --unsigned --oci-username ${ci_registry_user} --oci-password ${ci_registry_token} gitlab_ci oci://${ci_registry_image}
fi

echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo "~~~~~ Spack build of dependencies "
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
${uberenv_cmd} --skip-setup-and-env --spec="${spec}" ${prefix_opt}

if [[ -n ${ci_registry_token} && ${debug_mode} == false ]]
then
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo "~~~~~ Push dependencies to Build Cache "
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
${spack_cmd} -D ${spack_env_path} buildcache push --only dependencies gitlab_ci
fi

echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo "~~~~~ Dependencies built $(date)"
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
fi

# find cmake cache file (hostconfig)
# Find cmake cache file (hostconfig)
if [[ -z ${hostconfig} ]]
then
# If no host config file was provided, we assume it was generated.
Expand All @@ -121,7 +175,7 @@ else
fi

hostconfig=$(basename ${hostconfig_path})
echo "Found hostconfig: ${hostconfig}"
echo "[Information]: Found hostconfig: ${hostconfig}"

# Build Directory
# When using /dev/shm, we use prefix for both spack builds and source build, unless BUILD_ROOT was defined
Expand Down Expand Up @@ -187,7 +241,7 @@ then
fi

echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo "~~~~~ Caliper Built $(date)"
echo "~~~~~ Caliper built $(date)"
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
fi

Expand Down Expand Up @@ -222,10 +276,10 @@ then

if grep -q "Errors while running CTest" ./tests_output.txt
then
echo "[Error]: failure(s) while running CTest" && exit 1
echo "[Error]: Failure(s) while running CTest" && exit 1
fi

echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo "~~~~~ Caliper Tests Complete $(date)"
echo "~~~~~ Caliper tests complete $(date)"
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
fi
2 changes: 1 addition & 1 deletion scripts/uberenv
Submodule uberenv updated 1 files
+35 −17 uberenv.py

0 comments on commit aa3d7a8

Please sign in to comment.