summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Wittenburg <scott.wittenburg@kitware.com>2020-06-16 22:01:35 -0600
committerScott Wittenburg <scott.wittenburg@kitware.com>2020-09-14 10:37:42 -0600
commitace52bd47670a364df5746d6a4cd8aa34d1b0661 (patch)
treedc49fa058ea59221403676649521a6f39ca4ebe9
parent4ca7d46e1515757e80c56c3f720391b937440e5e (diff)
downloadspack-ace52bd47670a364df5746d6a4cd8aa34d1b0661.tar.gz
spack-ace52bd47670a364df5746d6a4cd8aa34d1b0661.tar.bz2
spack-ace52bd47670a364df5746d6a4cd8aa34d1b0661.tar.xz
spack-ace52bd47670a364df5746d6a4cd8aa34d1b0661.zip
Provide your own script, before_script, and after_script
-rw-r--r--lib/spack/spack/ci.py45
-rw-r--r--lib/spack/spack/cmd/ci.py14
-rw-r--r--lib/spack/spack/schema/gitlab_ci.py19
-rw-r--r--lib/spack/spack/test/cmd/ci.py67
-rwxr-xr-xshare/spack/spack-completion.bash2
5 files changed, 35 insertions, 112 deletions
diff --git a/lib/spack/spack/ci.py b/lib/spack/spack/ci.py
index 283fcab3a1..ce411e09db 100644
--- a/lib/spack/spack/ci.py
+++ b/lib/spack/spack/ci.py
@@ -449,7 +449,6 @@ def format_job_needs(phase_name, strip_compilers, dep_jobs,
def generate_gitlab_ci_yaml(env, print_summary, output_file,
- custom_spack_repo=None, custom_spack_ref=None,
run_optimizer=False, use_dependencies=False):
# FIXME: What's the difference between one that opens with 'spack'
# and one that opens with 'env'? This will only handle the former.
@@ -488,22 +487,6 @@ def generate_gitlab_ci_yaml(env, print_summary, output_file,
os.environ.get('SPACK_IS_PR_PIPELINE', '').lower() == 'true'
)
- # Make sure we use a custom spack if necessary
- before_script = None
- after_script = None
- if custom_spack_repo:
- if not custom_spack_ref:
- custom_spack_ref = 'develop'
- before_script = [
- ('git clone "{0}"'.format(custom_spack_repo)),
- 'pushd ./spack && git checkout "{0}" && popd'.format(
- custom_spack_ref),
- '. "./spack/share/spack/setup-env.sh"',
- ]
- after_script = [
- 'rm -rf "./spack"'
- ]
-
ci_mirrors = yaml_root['mirrors']
mirror_urls = [url for url in ci_mirrors.values()]
@@ -604,19 +587,27 @@ def generate_gitlab_ci_yaml(env, print_summary, output_file,
except AttributeError:
image_name = build_image
+ job_script = [
+ 'spack env activate --without-view .',
+ 'spack ci rebuild',
+ ]
+ if 'script' in runner_attribs:
+ job_script = [s for s in runner_attribs['script']]
+
+ before_script = None
+ if 'before_script' in runner_attribs:
+ before_script = [
+ s for s in runner_attribs['before_script']
+ ]
+
+ after_script = None
+ if 'after_script' in runner_attribs:
+ after_script = [s for s in runner_attribs['after_script']]
+
osname = str(release_spec.architecture)
job_name = get_job_name(phase_name, strip_compilers,
release_spec, osname, build_group)
- debug_flag = ''
- if 'enable-debug-messages' in gitlab_ci:
- debug_flag = '-d '
-
- job_scripts = [
- 'spack env activate --without-view .',
- 'spack {0}ci rebuild'.format(debug_flag),
- ]
-
compiler_action = 'NONE'
if len(phases) > 1:
compiler_action = 'FIND_ANY'
@@ -717,7 +708,7 @@ def generate_gitlab_ci_yaml(env, print_summary, output_file,
job_object = {
'stage': stage_name,
'variables': variables,
- 'script': job_scripts,
+ 'script': job_script,
'tags': tags,
'artifacts': {
'paths': artifact_paths,
diff --git a/lib/spack/spack/cmd/ci.py b/lib/spack/spack/cmd/ci.py
index b98bc6ba52..61f866693e 100644
--- a/lib/spack/spack/cmd/ci.py
+++ b/lib/spack/spack/cmd/ci.py
@@ -46,15 +46,6 @@ def setup_parser(subparser):
help="Absolute path of additional location where generated jobs " +
"yaml file should be copied. Default is not to copy.")
generate.add_argument(
- '--spack-repo', default=None,
- help="Provide a url for this argument if a custom spack repo " +
- "should be cloned as a step in each generated job.")
- generate.add_argument(
- '--spack-ref', default=None,
- help="Provide a git branch or tag if a custom spack branch " +
- "should be checked out as a step in each generated job. " +
- "This argument is ignored if no --spack-repo is provided.")
- generate.add_argument(
'--optimize', action='store_true', default=False,
help="(Experimental) run the generated document through a series of "
"optimization passes designed to reduce the size of the "
@@ -82,8 +73,6 @@ def ci_generate(args):
output_file = args.output_file
copy_yaml_to = args.copy_to
- spack_repo = args.spack_repo
- spack_ref = args.spack_ref
run_optimizer = args.optimize
use_dependencies = args.dependencies
@@ -97,8 +86,7 @@ def ci_generate(args):
# Generate the jobs
spack_ci.generate_gitlab_ci_yaml(
- env, True, output_file, spack_repo, spack_ref,
- run_optimizer=run_optimizer,
+ env, True, output_file, run_optimizer=run_optimizer,
use_dependencies=use_dependencies)
if copy_yaml_to:
diff --git a/lib/spack/spack/schema/gitlab_ci.py b/lib/spack/spack/schema/gitlab_ci.py
index 9d0ba8a77b..122715b6db 100644
--- a/lib/spack/spack/schema/gitlab_ci.py
+++ b/lib/spack/spack/schema/gitlab_ci.py
@@ -91,6 +91,21 @@ properties = {
},
},
},
+ 'before_script': {
+ 'type': 'array',
+ 'default': [],
+ 'items': {'type': 'string'}
+ },
+ 'script': {
+ 'type': 'array',
+ 'default': [],
+ 'items': {'type': 'string'}
+ },
+ 'after_script': {
+ 'type': 'array',
+ 'default': [],
+ 'items': {'type': 'string'}
+ },
},
},
},
@@ -100,10 +115,6 @@ properties = {
'type': 'boolean',
'default': False,
},
- 'enable-debug-messages': {
- 'type': 'boolean',
- 'default': False,
- },
'final-stage-rebuild-index': {
'type': 'object',
'additionalProperties': False,
diff --git a/lib/spack/spack/test/cmd/ci.py b/lib/spack/spack/test/cmd/ci.py
index 7e61a885ff..55333e1717 100644
--- a/lib/spack/spack/test/cmd/ci.py
+++ b/lib/spack/spack/test/cmd/ci.py
@@ -351,7 +351,6 @@ spack:
some-mirror: https://my.fake.mirror
gitlab-ci:
enable-artifacts-buildcache: True
- enable-debug-messages: True
mappings:
- match:
- archive-files
@@ -533,72 +532,6 @@ spack:
assert not any('externaltool' in key for key in yaml_contents)
-def test_ci_generate_debug_with_custom_spack(tmpdir, mutable_mock_env_path,
- env_deactivate, install_mockery,
- mock_packages):
- """Make sure we generate cloning of spack in job script if needed"""
- filename = str(tmpdir.join('spack.yaml'))
- with open(filename, 'w') as f:
- f.write("""\
-spack:
- specs:
- - archive-files
- mirrors:
- some-mirror: https://my.fake.mirror
- gitlab-ci:
- enable-artifacts-buildcache: True
- enable-debug-messages: True
- mappings:
- - match:
- - archive-files
- runner-attributes:
- tags:
- - donotcare
- image: donotcare
-""")
-
- with tmpdir.as_cwd():
- env_cmd('create', 'test', './spack.yaml')
- outfile = str(tmpdir.join('.gitlab-ci.yml'))
-
- with ev.read('test'):
- spack_repo = 'https://github.com/usera/spack.git'
- spack_ref = 'custom-branch'
- expected_clone_str = 'git clone "{0}"'.format(spack_repo)
-
- ci_cmd('generate', '--output-file', outfile, '--spack-repo',
- spack_repo, '--spack-ref', spack_ref)
-
- with open(outfile) as f:
- contents = f.read()
- yaml_contents = syaml.load(contents)
- for ci_key in yaml_contents.keys():
- if '(specs)' in ci_key:
- next_job = yaml_contents[ci_key]
- print(next_job)
- assert('before_script' in next_job)
- before_script = next_job['before_script']
- for step in before_script:
- if expected_clone_str in step:
- break
- else:
- msg = 'job "{0}" did not clone spack repo'.format(
- ci_key)
- print(msg)
- assert(False)
-
- assert('script' in next_job)
- script = next_job['script']
- for step in script:
- if 'spack -d ci rebuild' in step:
- break
- else:
- msg = 'job {0} missing rebuild command'.format(
- ci_key)
- print(msg)
- assert(False)
-
-
def test_ci_rebuild_basic(tmpdir, mutable_mock_env_path, env_deactivate,
install_mockery, mock_packages,
mock_gnupghome):
diff --git a/share/spack/spack-completion.bash b/share/spack/spack-completion.bash
index f77f60dfc9..2de74b888c 100755
--- a/share/spack/spack-completion.bash
+++ b/share/spack/spack-completion.bash
@@ -465,7 +465,7 @@ _spack_ci() {
}
_spack_ci_generate() {
- SPACK_COMPREPLY="-h --help --output-file --copy-to --spack-repo --spack-ref --optimize --dependencies"
+ SPACK_COMPREPLY="-h --help --output-file --copy-to --optimize --dependencies"
}
_spack_ci_rebuild() {