diff options
author | Scott Wittenburg <scott.wittenburg@kitware.com> | 2021-06-24 16:15:19 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-24 16:15:19 -0600 |
commit | d7405ddd3908f328d052d1de7520620924825b7b (patch) | |
tree | 133814b295eb3b1e675e357a3b83f83b4071cb4b /lib | |
parent | 010b431692f5b7fd755e685cad057e6c288c161e (diff) | |
download | spack-d7405ddd3908f328d052d1de7520620924825b7b.tar.gz spack-d7405ddd3908f328d052d1de7520620924825b7b.tar.bz2 spack-d7405ddd3908f328d052d1de7520620924825b7b.tar.xz spack-d7405ddd3908f328d052d1de7520620924825b7b.zip |
Pipelines: Set a pipeline type variable (#24505)
Spack pipelines need to take specific actions internally that depend
on whether the pipeline is being run on a PR to spack or a merge to
the develop branch. Pipelines can also run in other repositories,
which represents other possible use cases than just the two mentioned
above. This PR creates a "SPACK_PIPELINE_TYPE" gitlab variable which
is propagated to rebuild jobs, and is also used internally to determine
which pipeline-specific tasks to run.
One goal of the PR is fix an issue where rebuild jobs which failed on
develop pipelines did not properly report the broken full hash to the
"broken-specs-url".
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/ci.py | 7 | ||||
-rw-r--r-- | lib/spack/spack/cmd/ci.py | 13 | ||||
-rw-r--r-- | lib/spack/spack/test/cmd/ci.py | 10 |
3 files changed, 17 insertions, 13 deletions
diff --git a/lib/spack/spack/ci.py b/lib/spack/spack/ci.py index e966a5a970..3e5e134e05 100644 --- a/lib/spack/spack/ci.py +++ b/lib/spack/spack/ci.py @@ -549,9 +549,8 @@ def generate_gitlab_ci_yaml(env, print_summary, output_file, generate_job_name = os.environ.get('CI_JOB_NAME', None) parent_pipeline_id = os.environ.get('CI_PIPELINE_ID', None) - is_pr_pipeline = ( - os.environ.get('SPACK_IS_PR_PIPELINE', '').lower() == 'true' - ) + spack_pipeline_type = os.environ.get('SPACK_PIPELINE_TYPE', None) + is_pr_pipeline = spack_pipeline_type == 'spack_pull_request' spack_pr_branch = os.environ.get('SPACK_PR_BRANCH', None) pr_mirror_url = None @@ -1073,7 +1072,7 @@ def generate_gitlab_ci_yaml(env, print_summary, output_file, 'SPACK_JOB_LOG_DIR': rel_job_log_dir, 'SPACK_JOB_REPRO_DIR': rel_job_repro_dir, 'SPACK_LOCAL_MIRROR_DIR': rel_local_mirror_dir, - 'SPACK_IS_PR_PIPELINE': str(is_pr_pipeline) + 'SPACK_PIPELINE_TYPE': str(spack_pipeline_type) } if pr_mirror_url: diff --git a/lib/spack/spack/cmd/ci.py b/lib/spack/spack/cmd/ci.py index 1bc73ec452..1f87924538 100644 --- a/lib/spack/spack/cmd/ci.py +++ b/lib/spack/spack/cmd/ci.py @@ -196,8 +196,7 @@ def ci_rebuild(args): compiler_action = get_env_var('SPACK_COMPILER_ACTION') cdash_build_name = get_env_var('SPACK_CDASH_BUILD_NAME') related_builds = get_env_var('SPACK_RELATED_BUILDS_CDASH') - pr_env_var = get_env_var('SPACK_IS_PR_PIPELINE') - dev_env_var = get_env_var('SPACK_IS_DEVELOP_PIPELINE') + spack_pipeline_type = get_env_var('SPACK_PIPELINE_TYPE') pr_mirror_url = get_env_var('SPACK_PR_MIRROR_URL') remote_mirror_url = get_env_var('SPACK_REMOTE_MIRROR_URL') @@ -242,8 +241,11 @@ def ci_rebuild(args): # Is this a pipeline run on a spack PR or a merge to develop? It might # be neither, e.g. a pipeline run on some environment repository. - spack_is_pr_pipeline = True if pr_env_var == 'True' else False - spack_is_develop_pipeline = True if dev_env_var == 'True' else False + spack_is_pr_pipeline = spack_pipeline_type == 'spack_pull_request' + spack_is_develop_pipeline = spack_pipeline_type == 'spack_protected_branch' + + tty.debug('Pipeline type - PR: {0}, develop: {1}'.format( + spack_is_pr_pipeline, spack_is_develop_pipeline)) # Figure out what is our temporary storage mirror: Is it artifacts # buildcache? Or temporary-storage-url-prefix? In some cases we need to @@ -495,10 +497,13 @@ def ci_rebuild(args): # list of known broken full hashes. This allows spack PR pipelines to # avoid wasting compute cycles attempting to build those hashes. if install_exit_code != 0 and spack_is_develop_pipeline: + tty.debug('Install failed on develop') if 'broken-specs-url' in gitlab_ci: broken_specs_url = gitlab_ci['broken-specs-url'] dev_fail_hash = job_spec.full_hash() broken_spec_path = url_util.join(broken_specs_url, dev_fail_hash) + tty.msg('Reporting broken develop build as: {0}'.format( + broken_spec_path)) tmpdir = tempfile.mkdtemp() empty_file_path = os.path.join(tmpdir, 'empty.txt') diff --git a/lib/spack/spack/test/cmd/ci.py b/lib/spack/spack/test/cmd/ci.py index cdc5247799..b267596a72 100644 --- a/lib/spack/spack/test/cmd/ci.py +++ b/lib/spack/spack/test/cmd/ci.py @@ -612,14 +612,14 @@ spack: outputfile = str(tmpdir.join('.gitlab-ci.yml')) with ev.read('test'): - os.environ['SPACK_IS_PR_PIPELINE'] = 'True' + os.environ['SPACK_PIPELINE_TYPE'] = 'spack_pull_request' os.environ['SPACK_PR_BRANCH'] = 'fake-test-branch' monkeypatch.setattr( ci, 'SPACK_PR_MIRRORS_ROOT_URL', r"file:///fake/mirror") try: ci_cmd('generate', '--output-file', outputfile) finally: - del os.environ['SPACK_IS_PR_PIPELINE'] + del os.environ['SPACK_PIPELINE_TYPE'] del os.environ['SPACK_PR_BRANCH'] with open(outputfile) as f: @@ -630,8 +630,8 @@ spack: assert('variables' in yaml_contents) pipeline_vars = yaml_contents['variables'] - assert('SPACK_IS_PR_PIPELINE' in pipeline_vars) - assert(pipeline_vars['SPACK_IS_PR_PIPELINE'] == 'True') + assert('SPACK_PIPELINE_TYPE' in pipeline_vars) + assert(pipeline_vars['SPACK_PIPELINE_TYPE'] == 'spack_pull_request') def test_ci_generate_with_external_pkg(tmpdir, mutable_mock_env_path, @@ -779,7 +779,7 @@ spack: set_env_var('SPACK_CDASH_BUILD_NAME', '(specs) archive-files') set_env_var('SPACK_RELATED_BUILDS_CDASH', '') set_env_var('SPACK_REMOTE_MIRROR_URL', mirror_url) - set_env_var('SPACK_IS_DEVELOP_PIPELINE', 'True') + set_env_var('SPACK_PIPELINE_TYPE', 'spack_protected_branch') ci_cmd('rebuild', fail_on_error=False) |