def main(): args = parse_args(sys.argv[1:]) if args.report_type == 'test-case-coverage': h = TestRailClient() h.data_pump(args.project.lower()) if args.report_type == 'test-run-counts': h = TestRailClient() if args.num_days: num_days = args.num_days else: num_days = '' h.testrail_run_counts_update(args.project, num_days) if args.report_type == 'issue-regression': h = GithubClient() h.github_issue_regression(args.project) h = GithubClient()
def get_conn(self) -> GithubClient: """ Function that initiates a new GitHub connection with token and hostname ( for GitHub Enterprise ) """ if self.client is not None: return self.client conn = self.get_connection(self.github_conn_id) access_token = conn.password host = conn.host if not host: self.client = GithubClient(login_or_token=access_token) else: self.client = GithubClient(login_or_token=access_token, base_url=host) return self.client
def run(self, ref): access_token = Secret("GITHUB_AUTH_TOKEN").get() github_client = GithubClient(access_token) repo = github_client.get_repo(ref) readme = repo.get_contents("README.md") b = base64.b64decode(readme.content) return b.decode("utf-8")
def get_conn(self) -> GithubClient: """Function that initiates a new GitHub connection with token and hostname (for GitHub Enterprise).""" if self.client is not None: return self.client conn = self.get_connection(self.github_conn_id) access_token = conn.password host = conn.host # Currently the only method of authenticating to GitHub in Airflow is via a token. This is not the # only means available, but raising an exception to enforce this method for now. # TODO: When/If other auth methods are implemented this exception should be removed/modified. if not access_token: raise AirflowException("An access token is required to authenticate to GitHub.") if not host: self.client = GithubClient(login_or_token=access_token) else: self.client = GithubClient(login_or_token=access_token, base_url=host) return self.client
def client(self): # noqa return GithubClient(self.credentials.get('username'), self.credentials.get('password'), client_id=self.credentials.client_id, client_secret=self.credentials.client_secret, timeout=60)