def __init__(self, args, git): """ :type args: CommonConfig :type git: Git """ self.args = args try: self.branch = os.environ['BRANCH'] self.is_pr = os.environ['IS_PULL_REQUEST'] == 'true' self.is_tag = os.environ['IS_GIT_TAG'] == 'true' self.commit = os.environ['COMMIT'] self.project_id = os.environ['PROJECT_ID'] except KeyError as ex: raise MissingEnvironmentVariable(name=ex.args[0]) if self.is_tag: raise ChangeDetectionNotSupported( 'Change detection is not supported for tags.') if self.is_pr: self.paths = sorted(git.get_diff_names([self.branch])) else: merge_runs = self.get_merge_runs(self.project_id, self.branch) last_successful_commit = self.get_last_successful_commit( merge_runs) self.paths = sorted( git.get_diff_names([last_successful_commit, self.commit]))
def __init__(self, args, git): """ :type args: CommonConfig :type git: Git """ self.args = args try: self.branch = os.environ['BRANCH'] self.is_pr = os.environ['IS_PULL_REQUEST'] == 'true' self.is_tag = os.environ['IS_GIT_TAG'] == 'true' self.commit = os.environ['COMMIT'] self.project_id = os.environ['PROJECT_ID'] self.commit_range = os.environ['SHIPPABLE_COMMIT_RANGE'] except KeyError as ex: raise MissingEnvironmentVariable(name=ex.args[0]) if self.is_tag: raise ChangeDetectionNotSupported('Change detection is not supported for tags.') if self.is_pr: self.paths = sorted(git.get_diff_names([self.commit_range])) self.diff = git.get_diff([self.commit_range]) else: merge_runs = self.get_merge_runs(self.project_id, self.branch) last_successful_commit = self.get_last_successful_commit(git, merge_runs) if last_successful_commit: self.paths = sorted(git.get_diff_names([last_successful_commit, self.commit])) self.diff = git.get_diff([last_successful_commit, self.commit]) else: # first run for branch self.paths = None # act as though change detection not enabled, do not filter targets self.diff = []
def main(): """Main program function.""" try: args = parse_args() display.verbosity = args.verbosity display.color = args.color try: run_id = os.environ['SHIPPABLE_BUILD_ID'] except KeyError as ex: raise MissingEnvironmentVariable(ex.args[0]) client = HttpClient(args) response = client.get('https://api.shippable.com/jobs?runIds=%s' % run_id) jobs = response.json() if len(jobs) == 1: raise ApplicationError( 'Shippable run %s has only one job. Did you use the "Rebuild with SSH" option?' % run_id) except ApplicationWarning as ex: display.warning(str(ex)) exit(0) except ApplicationError as ex: display.error(str(ex)) exit(1) except KeyboardInterrupt: exit(2) except IOError as ex: if ex.errno == errno.EPIPE: exit(3) raise
def main(): """Main program function.""" try: args = parse_args() display.verbosity = args.verbosity display.color = args.color try: run_id = os.environ['SHIPPABLE_BUILD_ID'] except KeyError as ex: raise MissingEnvironmentVariable(ex.args[0])
def __init__(self, args): """ :type args: any """ super(SanityConfig, self).__init__(args, 'sanity') self.test = args.test # type: list [str] self.skip_test = args.skip_test # type: list [str] self.list_tests = args.list_tests # type: bool if args.base_branch: self.base_branch = args.base_branch # str elif is_shippable(): try: self.base_branch = os.environ['BASE_BRANCH'] # str except KeyError as ex: raise MissingEnvironmentVariable(name=ex.args[0]) else: self.base_branch = ''