Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't display too many PRs on deploy #4005

Merged
merged 2 commits into from
Jul 22, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 22 additions & 18 deletions src/commcare_cloud/fab/utils.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
from __future__ import absolute_import
from __future__ import print_function

import datetime
import os
import pickle
import re
import sys
import traceback
from fabric.operations import sudo
from fabric.context_managers import cd, settings
from fabric.api import local
import re
from collections import defaultdict
from getpass import getpass
from memoized import memoized_property, memoized

from github import Github, UnknownObjectException
from fabric.api import execute, env
from fabric.colors import magenta, red
from gevent.pool import Pool
from collections import defaultdict
from github import Github, UnknownObjectException
from memoized import memoized, memoized_property

from fabric.api import env, execute, local
from fabric.colors import blue, cyan, red, yellow
from fabric.context_managers import cd, settings
from fabric.operations import sudo

from .const import (
PROJECT_ROOT,
CACHED_DEPLOY_CHECKPOINT_FILENAME,
CACHED_DEPLOY_ENV_FILENAME,
DATE_FMT,
OFFLINE_STAGING_DIR,
PROJECT_ROOT,
RELEASE_RECORD,
)

Expand Down Expand Up @@ -264,14 +265,18 @@ def url(self):
return "{}/compare/{}...{}".format(self.repo.html_url, self.last_commit, self.deploy_commit)

def warn_of_migrations(self):
if not _github_auth_provided():
if not (_github_auth_provided() and self.last_commit and self.deploy_commit):
return

pr_numbers = self._get_pr_numbers()
if len(pr_numbers) > 500:
print(red("There are too many PRs to display"))
return

pool = Pool(5)
pr_infos = [_f for _f in pool.map(self._get_pr_info, pr_numbers) if _f]

print("List of PRs since last deploy:")
print(blue("\nList of PRs since last deploy:"))
self._print_prs_formatted(pr_infos)

prs_by_label = self._get_prs_by_label(pr_infos)
Expand Down Expand Up @@ -312,10 +317,9 @@ def _get_prs_by_label(self, pr_infos):
return dict(prs_by_label)

def _print_prs_formatted(self, pr_list):
i = 1
for pr in pr_list:
print("{0}. ".format(i), end="")
print("{title} {url} | ".format(**pr), end="")
print(" ".join(label for label in pr['labels']))
i += 1

print(
cyan(pr['title']),
yellow(pr['url']),
", ".join(label for label in pr['labels']),
)