def _build(self): last_build_duration = files.fetch_action_arg( 'build', 'last_build_duration') schema.validate() started_build_time = time.time() container_name = "{}:{}".format(self.config['name'], uuid.uuid4()) print("Starting build {}".format(container_name)) template_parameters = config_helpers.\ get_template_parameters(self.config) params = "" for key, val in template_parameters.items(): params += "{}={} ".format(key.upper(), val) build_cmd = "CONTAINER_NAME={} {}make build".format( container_name, params) if self.args['--verbose']: build_process = process_helpers.run_popen(build_cmd, shell=True, stdout=True, stderr=True) else: build_process = process_helpers.run_popen(build_cmd, shell=True) with process_helpers.prevent_deadlock(build_process): progress_bar.duration_progress( 'Building {}'.format( self.config["name"]), last_build_duration, lambda: build_process.poll() is not None) if build_process.poll() != 0: # When we have an error, get the stdout and error output # and display them both with the error output in red. output, error_msg = build_process.communicate() if output: print(output.decode("utf-8")) if error_msg: error_handling.throw_error(error_msg.decode("utf-8"), 'red') built_time = time.time() # Write last container to file with open('.build.json', 'w') as f: f.write(json.dumps({ "last_container": container_name, "last_build_duration": built_time - started_build_time })) print("Built {}".format(container_name))
def action(self): schema.validate() if sync_helpers.get_sync_spec() is not None: print(colored("This folder is currently being synced, please run " "`mlt sync delete {}` to delete sync spec " "manually".format(sync_helpers.get_sync_spec()), 'yellow')) skip_crd_check = self.args['--skip-crd-check'] if not skip_crd_check: kubernetes_helpers.check_crds(exit_on_failure=True) if self.args['--no-push']: print("Skipping image push") else: self._push() self._deploy_new_container() if self.args["--logs"]: self._tail_logs()
def test_valid_yaml(): cwd = os.getcwd() os.chdir("tests/unit/utils/sample-templates/valid-template") output = schema.validate() assert output is None os.chdir(cwd)
def test_yaml_with_multiple_doc(): cwd = os.getcwd() os.chdir("tests/unit/utils/sample-templates/multiple_doc_template") output = schema.validate() assert output is None os.chdir(cwd)
def test_invalid_yaml(): cwd = os.getcwd() os.chdir("tests/unit/utils/sample-templates/invalid-template") with pytest.raises(ValidationError): schema.validate() os.chdir(cwd)