Skip to content

refactors GitLab CI dependency setup to use a persistent filesystem Spack cache - #1091

Open
adrienbernede wants to merge 21 commits into
developfrom
woptim/ci-spack-optimized
Open

refactors GitLab CI dependency setup to use a persistent filesystem Spack cache#1091
adrienbernede wants to merge 21 commits into
developfrom
woptim/ci-spack-optimized

Conversation

@adrienbernede

@adrienbernede adrienbernede commented Jul 22, 2026

Copy link
Copy Markdown
Member

Summary

This PR refactors GitLab CI dependency setup to use a persistent filesystem Spack cache with branch-aware behavior, while simplifying the main orchestration flow.

What changed

  1. Persistent Spack cache configuration

    • Added project-level cache variables in .gitlab/custom-variables.yml:
      • UMPIRE_CI_STORAGE_ROOT
      • UMPIRE_CI_STORAGE_GROUP
      • UMPIRE_CI_STORAGE_UMASK
      • UMPIRE_CI_FORCE_SPACK
      • UMPIRE_CI_UPSTREAM_TARGET (develop)
    • Added Spack config fragments:
      • scripts/gitlab/umpire-ci-cache-common.yaml (install tree + filesystem mirror + permissions)
      • scripts/gitlab/umpire-ci-cache-upstream.yaml (upstream install tree include)
  2. build_and_test.sh simplification

    • Reworked cache logic to:
      • resolve branch cache target
      • compute deterministic cache key
      • check for reusable host-config in branch cache then upstream (develop) cache
    • Removed glob-based host-config discovery in parent flow and switched to deterministic host-config paths.
    • Explicitly skips dependency installation when HOST_CONFIG is provided.
    • On cache miss, delegates dependency build/publish to a dedicated script.
  3. Extracted cache-miss dependency path

    • Added scripts/gitlab/build_deps_on_cache_miss.sh to handle:
      • Spack setup/concretization/build
      • filesystem buildcache push
      • optional registry mirror/push
      • host-config publication to cache
    • Applies configured umask before artifact creation.
    • Removes HOST_CONFIG branching from this script (it only runs on miss path).
  4. Shared GitLab logging helpers

    • Added scripts/gitlab/gitlab_logs_helpers.bash.
    • Centralized print_*, section rendering, and run_section helpers.
    • build_and_test.sh and build_deps_on_cache_miss.sh now source this file.

Behavior notes

  • Non-upstream branches can reuse develop install tree as Spack upstream when available.
  • Branch-specific cache artifacts are still isolated by target key.
  • HOST_CONFIG path is treated as authoritative and bypasses dependency build/install.

TODOs:

  • UMPIRE_CI_STORAGE_GROUP is not use to set group in local spack config files due to variable expansion failing, found a better option to keep the group value coherent between script (chgrp) and spack config.
  • Trying to by-pass spack present a risk to miss changes in the configuration. For example, in this implement we do not catch changes due to a dependency pointing at a branch (e.g. develop). Instead, the state of the branch used at cache creation is reused. Solution: either avoid using @develop for dependencies, or add a mechanism to catch those situations and for using Spack to potentially rebuild the dep.
  • We may want to prevent populating the upstream install tree (default branch) when the pipeline was triggered for multi-project support.
  • Looking for a host-config file using a glob is not reliable.

@adrienbernede
adrienbernede requested a review from Copilot July 23, 2026 16:47

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Refactors GitLab CI dependency setup to leverage a persistent filesystem-backed Spack cache with branch-aware reuse (including optional upstream reuse), and simplifies the orchestration by extracting the cache-miss build/publish path into a dedicated script.

Changes:

  • Added Spack config fragments for filesystem install/buildcache and upstream reuse.
  • Added shared GitLab log/section helpers and updated build orchestration to use deterministic cache keys + host-config paths.
  • Added a dedicated cache-miss dependency build/publish script and wired it into build_and_test.sh.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
scripts/gitlab/umpire-ci-cache-upstream.yaml Adds Spack upstream install tree configuration driven by CI env.
scripts/gitlab/umpire-ci-cache-common.yaml Defines filesystem install tree + mirror and package permission defaults.
scripts/gitlab/gitlab_logs_helpers.bash Centralizes GitLab section logging with nesting and timing.
scripts/gitlab/build_deps_on_cache_miss.sh Implements the cache-miss path: Spack setup/build, buildcache push, and host-config publish.
scripts/gitlab/build_and_test.sh Simplifies orchestration: cache key/target resolution, cache hit reuse, and cache-miss delegation.
.gitlab/custom-variables.yml Introduces CI variables controlling persistent storage, permissions, and upstream behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread scripts/gitlab/umpire-ci-cache-common.yaml Outdated
Comment thread scripts/gitlab/gitlab_logs_helpers.bash Outdated
Comment thread scripts/gitlab/gitlab_logs_helpers.bash Outdated
Comment thread scripts/gitlab/gitlab_logs_helpers.bash Outdated
Comment on lines +81 to +102
find_project_hostconfig ()
{
local hostconfigs=()
shopt -s nullglob
hostconfigs=( "${project_dir}"/*.cmake )
shopt -u nullglob

if [[ ${#hostconfigs[@]} == 1 ]]
then
printf '%s\n' "${hostconfigs[0]}"
elif [[ ${#hostconfigs[@]} == 0 ]]
then
print_error "No result for: ${project_dir}/*.cmake"
print_error "Spack generated host-config not found."
return 1
else
print_error "More than one result for: ${project_dir}/*.cmake"
print_error "${hostconfigs[@]}"
print_error "Expected a single generated host-config."
return 1
fi
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to fix this.

Comment thread scripts/gitlab/build_and_test.sh
Comment thread scripts/gitlab/build_and_test.sh
Comment thread scripts/gitlab/build_and_test.sh
…st-config, simplify hostconfig lookup

- Add clean_hostconfig() to remove stale .cmake files before spack_build
- Simplify find_project_hostconfig() to a single -ne 1 check, always search prefix
- Validate prefix exists as a directory before proceeding
- Remove main() wrapper, inline script core, remove script-scope local declarations
- Pass --prefix explicitly to run_uberenv instead of positional argument
- Move find_project_hostconfig call before filesystem buildcache push
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants