diff options
Diffstat (limited to 'lib/spack/spack/ci.py')
-rw-r--r-- | lib/spack/spack/ci.py | 49 |
1 files changed, 32 insertions, 17 deletions
diff --git a/lib/spack/spack/ci.py b/lib/spack/spack/ci.py index 8d337196ce..f23445f1df 100644 --- a/lib/spack/spack/ci.py +++ b/lib/spack/spack/ci.py @@ -1271,6 +1271,7 @@ def get_concrete_specs(env, root_spec, job_name, related_builds, def register_cdash_build(build_name, base_url, project, site, track): url = base_url + '/api/v1/addBuild.php' time_stamp = datetime.datetime.now().strftime('%Y%m%d-%H%M') + build_id = None build_stamp = '{0}-{1}'.format(time_stamp, track) payload = { "project": project, @@ -1292,17 +1293,20 @@ def register_cdash_build(build_name, base_url, project, site, track): request = Request(url, data=enc_data, headers=headers) - response = opener.open(request) - response_code = response.getcode() + try: + response = opener.open(request) + response_code = response.getcode() - if response_code != 200 and response_code != 201: - msg = 'Adding build failed (response code = {0}'.format(response_code) - tty.warn(msg) - return (None, None) + if response_code != 200 and response_code != 201: + msg = 'Adding build failed (response code = {0}'.format(response_code) + tty.warn(msg) + return (None, None) - response_text = response.read() - response_json = json.loads(response_text) - build_id = response_json['buildid'] + response_text = response.read() + response_json = json.loads(response_text) + build_id = response_json['buildid'] + except Exception as e: + print("Registering build in CDash failed: {0}".format(e)) return (build_id, build_stamp) @@ -1412,15 +1416,26 @@ def read_cdashid_from_mirror(spec, mirror_url): return int(contents) -def push_mirror_contents(env, spec, specfile_path, mirror_url, sign_binaries): +def _push_mirror_contents(env, specfile_path, sign_binaries, mirror_url): + """Unchecked version of the public API, for easier mocking""" + unsigned = not sign_binaries + tty.debug('Creating buildcache ({0})'.format( + 'unsigned' if unsigned else 'signed')) + hashes = env.all_hashes() if env else None + matches = spack.store.specfile_matches(specfile_path, hashes=hashes) + push_url = spack.mirror.push_url_from_mirror_url(mirror_url) + spec_kwargs = {'include_root': True, 'include_dependencies': False} + kwargs = { + 'force': True, + 'allow_root': True, + 'unsigned': unsigned + } + bindist.push(matches, push_url, spec_kwargs, **kwargs) + + +def push_mirror_contents(env, specfile_path, mirror_url, sign_binaries): try: - unsigned = not sign_binaries - tty.debug('Creating buildcache ({0})'.format( - 'unsigned' if unsigned else 'signed')) - spack.cmd.buildcache._createtarball( - env, spec_file=specfile_path, add_deps=False, - output_location=mirror_url, force=True, allow_root=True, - unsigned=unsigned) + _push_mirror_contents(env, specfile_path, sign_binaries, mirror_url) except Exception as inst: # If the mirror we're pushing to is on S3 and there's some # permissions problem, for example, we can't just target |