def run(self): projdir = self.projdir if not prompt_user('Ready to upload to PyPI?'): fail('Not ready to upload to PyPI.') env = deepcopy(os.environ) env['PATH'] = self._fixed_path(projdir) cmd = ' '.join(['twine', 'upload', 'dist/*']) logger.info( 'Running: %s (cwd=%s)', cmd, projdir ) res = subprocess.run( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=projdir, timeout=1800, env=env, shell=True ) if res.returncode != 0: logger.error( 'ERROR: command exited %d:\n%s', res.returncode, res.stdout.decode() ) fail('%s failed.' % cmd) logger.info( 'Package generated and uploaded to live/production PyPI.') res = self.pypi_has_version(VERSION) while not res: logger.info( 'Waiting for new version to show up on PyPI...') sleep(10) res = self.pypi_has_version(VERSION) logger.info('Package is live on PyPI.')
def run(self): logger.info( 'Readme URL: <https://github.com/jantman/awslimitchecker/blob/%s/' 'README.rst>', self._current_branch ) if not prompt_user('Does the Readme at the above URL render properly?'): fail('Please fix the README and then re-run.')
def run(self): logger.info('Running dev/update_integration_iam_policy.py') IntegrationIamPolicyUpdater().run() self._ensure_committed() if not prompt_user( 'Are any IAM permission changes clearly documented in the ' 'changelog?'): fail('Please update CHANGES.rst with any new IAM permissions.')
def run(self): logger.info('Running dev/terraform.py') TerraformIAM().run() self._ensure_committed() if not prompt_user( 'Are any IAM permission changes clearly documented in the ' 'changelog?'): fail('Please update CHANGES.rst with any new IAM permissions.')
def run(self): logger.info('Running dev/update_integration_iam_policy.py') IntegrationIamPolicyUpdater().run() self._ensure_committed() if not prompt_user( 'Are any IAM permission changes clearly documented in the ' 'changelog?' ): fail('Please update CHANGES.rst with any new IAM permissions.')
def _push_docker(self, img_name, img_tag): cmd = ['docker', 'push', '%s:%s' % (img_name, img_tag)] logger.info('Running: %s', ' '.join(cmd)) res = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, timeout=1800) if res.returncode != 0: logger.error('ERROR: command exited %d:\n%s', res.returncode, res.stdout.decode()) fail('%s failed.' % ' '.join(cmd)) logger.info('Docker image pushed: %s:%s', img_name, img_tag)
def create_pr(self): branch = self._current_branch logger.debug('Creating PR for %s into master', branch) pull = self._gh._repo.create_pull( 'fixes #%s - %s release' % (self._release_issue_num, VERSION), 'master', 'jantman:%s' % branch, body='%s release' % VERSION ) if pull is None: fail('ERROR: Could not create PR for release') logger.info('Opened PR for %s into master; PR #%s', branch, pull.number) return pull.number
def run(self): logger.info('Running release Docker image build') tox_output = self._run_tox_env( 'docker', extra_env_vars={'DOCKER_BUILD_VER': VERSION}) logger.info('Tox output:\n%s', tox_output) m = re.search(r'Image "([^"]+)" built and tested\.', tox_output) if m is None: fail('Error: could not find build image tag in tox output.') tag = m.group(1) img_name = 'jantman/biweeklybudget' self._prompt_tag(img_name, tag, VERSION) self._prompt_tag(img_name, tag, 'latest') if not prompt_user('Push images to Docker Hub?'): fail('Do not push.') self._push_docker(img_name, VERSION) self._push_docker(img_name, 'latest')
def _prompt_tag(self, img_name, orig_tag, new_tag): if not prompt_user('Tag %s:%s as %s:%s ?' % (img_name, orig_tag, img_name, new_tag)): fail('Error.') cmd = [ 'docker', 'tag', '%s:%s' % (img_name, orig_tag), '%s:%s' % (img_name, new_tag) ] logger.info('Running: %s', ' '.join(cmd)) res = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, timeout=1800) if res.returncode != 0: logger.error('ERROR: command exited %d:\n%s', res.returncode, res.stdout.decode()) fail('%s failed.' % ' '.join(cmd)) logger.info('Docker image tagged as %s', new_tag)
def run(self): commit = self._current_commit logger.info('Polling for finished TravisCI build of %s', commit) build = self._travis.commit_latest_build_status(commit) while build is None or build.finished is False: sleep(10) build = self._travis.commit_latest_build_status(commit) logger.info('Travis build finished') if not build.passed: fail( 'Travis build %s (%s) did not pass. Please fix build failures ' 'and then re-run.' % (build.number, build.id)) logger.info('OK, Travis build passed.') logger.info( 'Build URL: <https://travis-ci.org/jantman/awslimitchecker/' 'builds/%s>', build.id) if not prompt_user( 'Is the test coverage at least as high as the last release, and ' 'are there acceptance tests for all non-trivial changes?'): fail('Test coverage!!!')
def run(self): commit = self._current_commit logger.info('Polling for finished TravisCI build of %s', commit) build = self._travis.commit_latest_build_status(commit) while build is None or build.finished is False: sleep(10) build = self._travis.commit_latest_build_status(commit) logger.info('Travis build finished') if not build.passed: fail('Travis build %s (%s) did not pass. Please fix build failures ' 'and then re-run.' % (build.number, build.id)) logger.info('OK, Travis build passed.') logger.info( 'Build URL: <https://travis-ci.org/jantman/awslimitchecker/' 'builds/%s>', build.id ) if not prompt_user( 'Is the test coverage at least as high as the last release, and ' 'are there acceptance tests for all non-trivial changes?' ): fail('Test coverage!!!')
def run(self): projdir = self.projdir env = deepcopy(os.environ) env['PATH'] = self._fixed_path(projdir) cmd = os.path.join(projdir, 'dev', 'terraform.py') logger.info('Running %s in cwd %s', cmd, projdir) res = subprocess.run( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=projdir ) logger.info('dev/terraform.py process exited %d', res.returncode) if res.returncode != 0: logger.error('ERROR: terraform exitcode %d', res.returncode) logger.error( 'dev/terraform.py output:\n%s', res.stdout.decode() ) res.check_returncode() self._ensure_committed() if not prompt_user( 'Are any IAM permission changes clearly documented in the ' 'changelog?' ): fail('Please update CHANGES.rst with any new IAM permissions.')
def run(self): projdir = self.projdir logger.info('Removing dist directory...') rmtree(os.path.join(projdir, 'dist')) env = deepcopy(os.environ) env['PATH'] = self._fixed_path(projdir) cmd = ['python', 'setup.py', 'sdist', 'bdist_wheel'] logger.info( 'Running: %s (cwd=%s)', ' '.join(cmd), projdir ) res = subprocess.run( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=projdir, timeout=1800, env=env ) if res.returncode != 0: logger.error( 'ERROR: command exited %d:\n%s', res.returncode, res.stdout.decode() ) fail('%s failed.' % ' '.join(cmd)) cmd = ' '.join(['twine', 'upload', '-r', 'test', 'dist/*']) logger.info( 'Running: %s (cwd=%s)', cmd, projdir ) res = subprocess.run( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=projdir, timeout=1800, env=env, shell=True ) if res.returncode != 0: logger.error( 'ERROR: command exited %d:\n%s', res.returncode, res.stdout.decode() ) fail('%s failed.' % ' '.join(cmd)) logger.info('Package generated and uploaded to Test PyPI.') res = self.pypi_has_version(VERSION, test=True) while not res: logger.info('Waiting for new version to show up on TestPyPI...') sleep(10) res = self.pypi_has_version(VERSION, test=True) logger.info( 'Package is live on Test PyPI. URL: <https://testpypi.python.org/' 'pypi/awslimitchecker>' ) if not prompt_user('Does the Readme at the above URL render properly?'): fail('Please fix the README and then re-run.')
def run(self): md = self._gh._get_markdown() print("Markdown:\n%s\n" % md) if not prompt_user('Does this look right?'): fail('Changelog apparently does not look right.') self._gh._release(md)
def run(self): b = self._current_branch if b == 'master': fail('release.py cannot be run from master for a new release') rbranch = 'issues/%d' % self._release_issue_num if b != rbranch: fail( 'You must run this script from a release branch called ' '"%s"' % rbranch ) if not prompt_user( 'Have you confirmed that there are CHANGES.rst entries for all ' 'major changes?' ): fail('Please check CHANGES.rst before releasing code.') if not prompt_user( 'Is the current version (%s) the version being released?' % VERSION ): fail( 'Please increment the version in awslimitchecker/version.py ' 'before running the release script.' ) # check for proper CHANGES.rst heading have_ver = False last_line = '' expected = '%s (%s)' % (VERSION, datetime.now().strftime('%Y-%m-%d')) with open(os.path.join(self.projdir, 'CHANGES.rst'), 'r') as fh: for line in fh.readlines(): line = line.strip() if ( line == '------------------' and last_line == expected ): have_ver = True break last_line = line if not have_ver: fail('Expected to find a "%s" heading in CHANGES.rst, but did not. ' 'Please ensure there is a changelog heading for this release.' '' % expected) if not prompt_user( 'Is the test coverage at least as high as the last release, and ' 'are there acceptance tests for all non-trivial changes?' ): fail('Test coverage!!!')
def run(self): b = self._current_branch if b == 'master': fail('release.py cannot be run from master for a new release') if not prompt_user( 'Is the current branch (%s) the release branch?' % b): fail('You must run this script from the release branch.') if not prompt_user( 'Have you verified whether or not DB migrations are needed, and ' 'if they are, ensure they’ve been created, tested and verified?' ): fail('You must verify migrations first.') if not prompt_user( 'Have you confirmed that there are CHANGES.rst entries for all ' 'major changes?'): fail('Please check CHANGES.rst before releasing code.') if not prompt_user( 'Is the current version (%s) the version being released?' % VERSION): fail('Please increment the version in biweeklybudget/version.py ' 'before running the release script.') # check for proper CHANGES.rst heading have_ver = False last_line = '' expected = '%s (%s)' % (VERSION, datetime.now().strftime('%Y-%m-%d')) with open(os.path.join(self.projdir, 'CHANGES.rst'), 'r') as fh: for line in fh.readlines(): line = line.strip() if (line == '------------------' and last_line == expected): have_ver = True break last_line = line if not have_ver: fail( 'Expected to find a "%s" heading in CHANGES.rst, but did not. ' 'Please ensure there is a changelog heading for this release.' '' % expected) if not prompt_user( 'Is the test coverage at least as high as the last release, and ' 'are there acceptance tests for all non-trivial changes?'): fail('Test coverage!!!')