def _build(self): """Execute and assert initial build. Explicitly spawning with a tty here to ensure output (e.g. from pip) includes color """ with change_dir(self.working_dir): runner = CliRunner() result = runner.invoke( cli, ['deploy', '--deploy-environment', 'dev', '--ci'], color=True) assert result.exit_code == 0, 'exit code should be zero' assert '\x1b[31mERROR: ' not in result.output, \ 'no red ERROR should be present'
def deploy(self): """Deploy provider.""" self.copy_fixture("decline-deploy-app.cdk") self.copy_runway("decline-deploy") with change_dir(self.cdk_test_dir): child = pexpect.spawn("runway deploy") try: child.logfile = sys.stdout.buffer child.expect("Do you wish to deploy these changes (y/n)?", timeout=120) child.sendline("n") i = child.expect("Aborted") except pexpect.EOF: self.logger.debug("EOF Reached") return 0 else: return i
def lint(self, base_dir=None, dirs_to_scan=None): """Call code linters.""" from flake8.main import application as flake8_app from yamllint.cli import run as yamllint_run if base_dir is None: base_dir = self.env_root if dirs_to_scan is None: dirs_to_scan = self.get_env_dirs() if os.path.isfile(os.path.join(base_dir, '.flake8')): # config file in env will be picked up automatically flake8_config = [] else: # no config file in env; use runway defaults flake8_config = [ ('--append-config=' + os.path.join( os.path.dirname(os.path.dirname(os.path.abspath(__file__))), # noqa 'templates', '.flake8' )) ] if os.path.isfile(os.path.join(base_dir, '.yamllint')): yamllint_config = os.path.join(base_dir, '.yamllint') elif os.path.isfile(os.path.join(base_dir, '.yamllint.yml')): yamllint_config = os.path.join(base_dir, '.yamllint.yml') else: yamllint_config = os.path.join( os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))), 'templates', '.yamllint.yml' ) with change_dir(base_dir): with ignore_exit_code_0(): LOGGER.info('Starting Flake8 linting...') flake8_run = flake8_app.Application() flake8_run.run( flake8_config + dirs_to_scan + self.get_python_files_at_env_root() # noqa pylint: disable=line-too-long ) flake8_run.exit() with ignore_exit_code_0(): LOGGER.info('Flake8 linting complete.') LOGGER.info('Starting yamllint...') yamllint_run( ["--config-file=%s" % yamllint_config] + dirs_to_scan + self.get_yaml_files_at_env_root() # noqa pylint: disable=line-too-long ) LOGGER.info('yamllint complete.')
def deploy(self): """Deploy provider.""" self.copy_fixture('decline-deploy-app.cdk') self.copy_runway('decline-deploy') with change_dir(self.cdk_test_dir): child = pexpect.spawn('runway deploy') try: child.logfile = sys.stdout.buffer child.expect('Do you wish to deploy these changes (y/n)?', timeout=120) child.sendline('n') i = child.expect('Aborted') except pexpect.EOF: self.logger.debug('EOF Reached') return 0 else: return i
def run_stacker(self, command='build'): """Deploys the CFN module to create S3 and DynamoDB resources.""" if command not in ('build', 'destroy'): raise ValueError('run_stacker: command must be one of %s' % ['build', 'destroy']) self.logger.info('Running "%s" on tf_state.cfn ...', command) self.logger.debug('tf_state_dir: %s', self.tf_state_dir) with change_dir(self.tf_state_dir): stacker_cmd = [ 'stacker.cmd' if platform.system().lower() == 'windows' else 'stacker', command, '-i', '-r', 'us-east-1' ] if command == 'destroy': stacker_cmd = stacker_cmd + ['-f'] stacker_cmd = stacker_cmd + ['dev-us-east-1.env', 'tfstate.yaml'] self.logger.debug('STACKER_CMD: %s', stacker_cmd) cmd_opts = {'cmd_list': stacker_cmd} return run_command(**cmd_opts) # noqa
def deploy(self): """Deploy provider.""" self.copy_fixture('sampleapp.cfn') self.copy_runway('default-to-series') with change_dir(self.parallelism_test_dir): return run_command(['runway', 'deploy'])
def deploy(self): """Deploy provider.""" self.copy_fixture("sampleapp.cfn") self.copy_runway("default-to-series") with change_dir(self.parallelism_test_dir): return run_command(["runway", "deploy"])
def teardown(self): """Teardown any created resources.""" self.logger.info('Tearing down: %s', self.TEST_NAME) with change_dir(self.base_dir): run_command(['runway', 'destroy']) self.clean()
def deploy(self): """Deploy provider.""" self.copy_runway('git') with change_dir(self.sources_test_dir): return run_command(['runway', 'deploy'])
def deploy(self): """Deploy provider.""" self.copy_fixture(self.module_dir) self.copy_runway("multiple-stacks") with change_dir(self.cdk_test_dir): return run_command(["runway", "deploy"])
def teardown(self): self.logger.info('Tearing down: %s', self.TEST_NAME) self.delete_venv(self.module_dir) with change_dir(self.staticsite_test_dir): run_command(['runway', 'destroy']) self.clean()
def deploy(self): """Deploy provider.""" self.copy_fixture(self.module_dir) self.copy_runway('multiple-stacks') with change_dir(self.cdk_test_dir): return run_command(['runway', 'deploy'])
def deploy_provider(self, version): """Deploy provider.""" self.copy_template('provider-version{}.tf'.format(version)) self.copy_runway('s3') with change_dir(self.base_dir): return run_command(['runway', 'deploy'])
def deploy(self): """Deploy provider.""" self.copy_fixture(self.module_dir) self.copy_runway('basic-site') with change_dir(self.staticsite_test_dir): return run_command(['runway', 'deploy'])
def teardown(self): """Teardown scaffolding.""" self.logger.info("Tearing down: %s", self.TEST_NAME) with change_dir(self.parallelism_test_dir): run_command(["runway", "destroy"]) self.clean()
def deploy(self): """Deploy provider.""" self.copy_runway("git") with change_dir(self.sources_test_dir): return run_command(["runway", "deploy"])