Пример #1
0
    def check_pr_title():
        remote = git(["config", "--get", f"remote.{args.remote}.url"])
        user, repo = parse_remote(remote)

        if args.pr_title:
            title = args.pr_title
        else:
            github = GitHubRepo(token=os.environ["TOKEN"],
                                user=user,
                                repo=repo)
            pr = github.get(f"pulls/{args.pr}")
            title = pr["title"]
        print("pr title:", title)
        return title.startswith("[skip ci]")
Пример #2
0
    def check_pr_title():
        remote = git(["config", "--get", f"remote.{args.remote}.url"])
        user, repo = parse_remote(remote)

        if args.pr_title:
            title = args.pr_title
        else:
            github = GitHubRepo(token=os.environ["TOKEN"],
                                user=user,
                                repo=repo)
            pr = github.get(f"pulls/{args.pr}")
            title = pr["title"]
        logging.info(f"pr title: {title}")
        tags = tags_from_title(title)
        logging.info(f"Found title tags: {tags}")
        return "skip ci" in tags
Пример #3
0
        f"  dry run: {args.dry_run}\n"
        f"  user/repo: {user}/{repo}\n",
        end="",
    )

    # [slow rollout]
    # This code is here to gate this feature to a limited set of people before
    # deploying it for everyone to avoid spamming in the case of bugs or
    # ongoing development.
    if args.allowlist:
        author_allowlist = args.allowlist.split(",")
    else:
        github = GitHubRepo(token=os.environ["GITHUB_TOKEN"],
                            user=user,
                            repo=repo)
        allowlist_issue = github.get("issues/9983")
        author_allowlist = set(find_reviewers(allowlist_issue["body"]))

    if args.pr_json:
        r = json.loads(args.pr_json)
    else:
        q = prs_query(user, repo)
        r = github.graphql(q)

    now = datetime.datetime.utcnow()
    if args.now:
        now = datetime.datetime.strptime(args.now, GIT_DATE_FORMAT)

    # Loop until all PRs have been checked
    while True:
        prs = r["data"]["repository"]["pullRequests"]["nodes"]
Пример #4
0
    # Check if anything in the last commit's body message matches
    log_match, reason = check_match(log, SLOW_TEST_TRIGGERS)
    if log_match:
        print(f"Matched {reason} in commit message:\n{display(log)}, running slow tests")
        exit(1)

    print(
        f"Last commit:\n{display(log)}\ndid not have any of {SLOW_TEST_TRIGGERS}, checking PR body..."
    )

    if args.pr_body:
        body = args.pr_body
    else:
        remote = git(["config", "--get", f"remote.{args.remote}.url"])
        user, repo = parse_remote(remote)

        github = GitHubRepo(token=os.environ["GITHUB_TOKEN"], user=user, repo=repo)
        pr = github.get(f"pulls/{args.pr}")
        body = pr["body"]

    body_match, reason = check_match(body, SLOW_TEST_TRIGGERS)

    if body_match:
        print(f"Matched {reason} in PR body:\n{display(body)}, running slow tests")
        exit(1)

    print(
        f"PR Body:\n{display(body)}\ndid not have any of {SLOW_TEST_TRIGGERS}, skipping slow tests"
    )
    exit(0)
Пример #5
0
    target_url = os.environ["TARGET_URL"]
    pr_and_build = get_pr_and_build_numbers(target_url)

    commit_sha = os.environ["COMMIT_SHA"]

    docs_url = build_docs_url(args.base_url_docs, pr_and_build["pr_number"],
                              pr_and_build["build_number"])

    url = f'issues/{pr_and_build["pr_number"]}/comments'
    body = f"Built docs for commit [{commit_sha}]({commit_sha}) can be found [here]({docs_url})."
    if not args.dry_run:
        github = GitHubRepo(token=os.environ["GITHUB_TOKEN"],
                            user=user,
                            repo=repo)

        # For now, only comment for PRs open by driazati, gigiblender and areusch.
        get_pr_url = f'pulls/{pr_and_build["pr_number"]}'
        pull_request_body = github.get(get_pr_url)
        author = pull_request_body["user"]["login"]
        if author not in ["driazati", "gigiblender", "areusch"]:
            logging.info(f"Skipping this action for user {author}")
            sys.exit(0)

        try:
            github.post(url, {"body": body})
        except error.HTTPError as e:
            logging.exception(f"Failed to add docs comment {docs_url}: {e}")
    else:
        logging.info(f"Dry run, would have posted {url} with data {body}.")
Пример #6
0
    number = pr["number"]
    body = pr["body"]
    if body is None:
        body = ""

    new_reviewers = find_reviewers(body)
    print("Found these reviewers:", new_reviewers)

    if args.testing_reviews_json:
        existing_reviews = json.loads(args.testing_reviews_json)
    else:
        github = GitHubRepo(token=os.environ["GITHUB_TOKEN"],
                            user=user,
                            repo=repo)
        existing_reviews = github.get(f"pulls/{number}/reviews")

    existing_review_users = [
        review["user"]["login"] for review in existing_reviews
    ]
    print("PR has reviews from these users:", existing_review_users)
    existing_review_users = set(r.lower() for r in existing_review_users)

    existing_reviewers = [
        review["login"] for review in pr["requested_reviewers"]
    ]
    print("PR already had these reviewers requested:", existing_reviewers)

    existing_reviewers_lower = {
        existing_reviewer.lower()
        for existing_reviewer in existing_reviewers