def compose_dry_run(self, data): try: output = docker.run_dry_run_compose( file_util.get_absolue_path( DryRunStep.DRY_RUN_COMPOSE_FILENAME), data) self.log.debug('Output from dry run was: %s', output) except Exception as ex: raise PipelineException(str(ex), self.get_slack_message(ex, data))
def run_step(self, data): data[pipeline_data.CONFIGURATION_FILE] = file_util.get_absolue_path( self.conf_file) conf_lines = self.trim(file_util.get_lines(self.conf_file)) if self.has_missing_conf_vars(conf_lines): self.handle_step_error( 'Missing the following configuration variables in `{}`: {}'. format(self.conf_file, self.get_missing_conf_vars(conf_lines))) data = self.add_conf_vars(conf_lines, data) return data
def run_step(self, data): if not file_util.is_file(DockerFileStep.FILE_DOCKERFILE): self.handle_step_error('Could not find Dockerfile at "{}"'.format( DockerFileStep.FILE_DOCKERFILE)) data[pipeline_data.DOCKERFILE_FILE] = file_util.get_absolue_path( DockerFileStep.FILE_DOCKERFILE ) return data
def compose_dry_run(self, data): self.log.info( 'Doing a dry run using "/docker-compose.yml" to test the newly built Docker iamge' ) try: output = docker.run_dry_run_compose( file_util.get_absolue_path( DryRunStep.DRY_RUN_COMPOSE_FILENAME), data) self.log.debug('Output from dry run was: %s', output) except Exception as ex: raise PipelineException(str(ex), self.get_slack_message(ex, data))
def run_unit_tests(self, data): self.log.info("Running unit tests") try: output = docker.run_unit_test_compose( file_util.get_absolue_path( UnitTestStep.UNIT_TEST_COMPOSE_FILENAME), data) self.log.info(output) except Exception as ex: self.handle_step_error( f'\n:rotating_light: <!here> {image_version_util.get_image(data)} *unit test(s) failed*, see <{environment.get_console_url()}|:github: Github Actions log here>.', ex)
def check_dependencies(): package_json = file_util.get_absolue_path(PACKAGE_JSON) if environment.is_run_inside_docker(): package_json = file_util.get_docker_mounted_path(PACKAGE_JSON) image_name = IMAGE_NAME # Mount the local package.json file into the Docker instance cmd = f'docker run --tty --rm -v {package_json}:/package.json {image_name}' try: return process.run_with_output(cmd) except PipelineException as pipeline_ex: log.warning('Could not check dependencies: "%s"', str(pipeline_ex)) return None
def run_unit_tests(self, data): try: output = docker.run_unit_test_compose( file_util.get_absolue_path( UnitTestStep.UNIT_TEST_COMPOSE_FILENAME ), data ) self.log.debug('Output from unit tests was: %s', output) except Exception as ex: self.handle_step_error( f'\n:rotating_light: <!here> {image_version_util.get_image(data)} *unit test(s) failed*, see <{environment.get_build_url()}|:jenkins: Jenkins console log here>.', self.get_stack_trace_shortend(ex), )
def select_and_run_pipeline(): logger = logging.getLogger(__name__) docker_conf = file_util.get_absolue_path('/docker.conf') has_docker_conf = os.path.isfile(docker_conf) npm_conf = file_util.get_absolue_path('/npm.conf') has_npm_conf = os.path.isfile(npm_conf) if has_docker_conf: logger.info("Has docker.conf") docker_pipeline = DockerDeployPipeline() docker_pipeline.run_pipeline() if has_npm_conf: logger.info("Has npm.conf") npm_pipeline = NpmPipeline() npm_pipeline.run_pipeline() if has_docker_conf is False and has_npm_conf is False: workspace = environment.get_project_root() text = f'Could not fins any `/docker.conf` or `/npm.conf` in repository *{workspace}*.' slack.send(text) logger.error(text) sys.exit(1)
def run_integration_tests(self, data): try: self.log.info( "Running integration tests in '%s'", IntegrationTestStep.INTEGRATION_TEST_COMPOSE_FILENAME) output = docker.run_integration_tests( file_util.get_absolue_path( IntegrationTestStep.INTEGRATION_TEST_COMPOSE_FILENAME), data) self.log.debug('Output from integration tests was: %s', output) except Exception as ex: self.handle_step_error( f'\n:rotating_light: <!here> {image_version_util.get_image(data)} *integration test(s) failed*, see <{environment.get_build_url()}|:jenkins: Jenkins console log here>.', self.get_stack_trace_shortend(ex), )
def select_and_run_pipeline(): logger = logging.getLogger(__name__) docker_conf = file_util.get_absolue_path('/docker.conf') has_docker_conf = os.path.isfile(docker_conf) npm_conf = file_util.get_absolue_path('/npm.conf') has_npm_conf = os.path.isfile(npm_conf) if has_docker_conf: logger.info("Has docker.conf") docker_pipeline = DockerDeployPipeline() docker_pipeline.run_pipeline() if has_npm_conf: logger.info("Has npm.conf") npm_pipeline = NpmPipeline() npm_pipeline.run_pipeline() if has_docker_conf is False and has_npm_conf is False: workspace = environment.get_project_root() message = f'No docker.conf or npm.conf found for project {workspace}' slack.send_to_slack(message) logger.error(message) sys.exit(1)