def test(self): '''Perform any tests in the source repository ''' public_log.step = 'test' private_log.step = 'test' hooks.run("pre_test") if not hooks.run("test"): test.test(self.client, self.build_code) hooks.run("post_test")
def setup(self): '''Perform the preparations nessecary for building This method performs the steps before building can take place. This centrally revovles around cloning the build context and extracting source assets. ''' public_log.step = 'setup' private_log.step = 'setup' startup.log_build_destination(self.byon) self.prepare_build_context() self.process_build_context() hooks.run('post_checkout') self.client = startup.login(self.docker_host, self.dockercfg) self.snapshot_docker_state()
def push(self): '''Push the built image to the registry ''' if not self.should_push: return public_log.step = 'push' private_log.step = 'push' private_log.info("Starting Push") hooks.run('pre_push') if not hooks.run('push'): public_log.info("Pushing {}...".format(self.image_name)) registry.push(self.client, self.docker_repo, self.docker_tags, self.push_attempt_count) public_log.info("Done!") hooks.run('post_push')
def _build(self): '''Perform the Docker image build This method performs the main image build and any configured tagging. ''' hooks.run('pre_build') if not hooks.run('build'): build.log_docker_version(self.client) cache_repo = "{}:{}".format( self.docker_repo, self.cache_tag) if self.cache_tag else None build.build_image(self.client, self.build_path, self.dockerfile_path, self.image_name, cache_repo) build.multitag_image(self.client, self.image_name, self.docker_repo, self.docker_tags[1:]) build.add_this_tag(self.client, self.image_name) hooks.run('post_build')
def test_skipped_when_not_file(self): self.mock_isfile.return_value = False assert not hooks.run("name") assert self.mock_execute.called is False
def test_called_when_file(self): self.mock_isfile.return_value = True assert hooks.run("name") self.mock_execute.assert_called_with("hooks/name", "name hook failed!")