gitlab: Fix pipeline generation for non-develop protected pipelines (#31378)

Release branches and tags run protected pipelines, and we noticed
that those pipelines were generating all jobs in the stack, even
when the mirror contained all the built specs and an up to date
index.  The problem was caused because the override mirror was
not present in spacks mirror configuration at the time when the
binary_distribution.update() method was called.  This fixes that
by always adding the mirror override, if present, to the list of
configured mirrors.
This commit is contained in:
Scott Wittenburg 2022-07-01 12:56:36 -06:00 committed by GitHub
parent 8b4de69f6a
commit 87b8321fa9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -771,9 +771,13 @@ def generate_gitlab_ci_yaml(env, print_summary, output_file,
mirrors_to_check = {
'override': remote_mirror_override
}
else:
spack.mirror.add(
'ci_pr_mirror', remote_mirror_override, cfg.default_modify_scope())
# If we have a remote override and we want generate pipeline using
# --check-index-only, then the override mirror needs to be added to
# the configured mirrors when bindist.update() is run, or else we
# won't fetch its index and include in our local cache.
spack.mirror.add(
'ci_pr_mirror', remote_mirror_override, cfg.default_modify_scope())
pipeline_artifacts_dir = artifacts_root
if not pipeline_artifacts_dir:
@ -819,7 +823,7 @@ def generate_gitlab_ci_yaml(env, print_summary, output_file,
user_artifacts_dir, ci_project_dir)
# Speed up staging by first fetching binary indices from all mirrors
# (including the per-PR mirror we may have just added above).
# (including the override mirror we may have just added above).
try:
bindist.binary_index.update()
except bindist.FetchCacheError as e:
@ -853,8 +857,7 @@ def generate_gitlab_ci_yaml(env, print_summary, output_file,
finally:
# Clean up remote mirror override if enabled
if remote_mirror_override:
if spack_pipeline_type != 'spack_protected_branch':
spack.mirror.remove('ci_pr_mirror', cfg.default_modify_scope())
spack.mirror.remove('ci_pr_mirror', cfg.default_modify_scope())
all_job_names = []
output_object = {}