Beispiel #1
0
def check_services_on_branch(versions_block):
    """
    Returns the list of all services that are on a branch.
    """
    services_on_branch = []
    for service in versions_block:
        version = versions_block.get(service)
        if "quay.io/cdis" not in version or len(version.split(":")) < 2:
            # ignore non-CTDS repos.
            # version without ":" is not usable.
            continue
        version = version.split(":")[1]
        if version_is_branch(version, release_tag_are_branches=False):
            services_on_branch.append(service)
    return services_on_branch
def test_release_tag():
    versions_block = {"arborist": "quay.io/cdis/arborist:2020.02"}
    assert get_manifest_version(versions_block, "arborist") == "2020.02"
    assert version_is_branch("2020.02")
    assert not version_is_branch("2020.02", release_tag_are_branches=False)
Beispiel #3
0
def get_important_changes(versions_dict, token, is_nde_portal):
    """
    Uses the gen3git utility to get the release notes between the old and new
    versions for each service, and returns the deployment changes and breaking
    changes only.

    Args:
        versions_dict (dict):
            {
                <service name>: { "old": <version>, "new": <version> }
            }
        token (string): token with read and write access to the repo

    Return:
        (dict, dict) tuple:
            (
                {<service>: [<deployment change 1>, <deployment change 2>]},
                {<service>: [<breaking change 1>, <breaking change 2>]}
            )
    """
    class Gen3GitArgs(object):
        def __init__(self, repo, from_tag, to_tag):
            self.github_access_token = token
            self.repo = repo
            self.from_tag = from_tag
            self.to_tag = to_tag

    deployment_changes = {}
    breaking_changes = {}
    for service, versions in versions_dict.items():
        # only get the deployment changes if the new version is more
        # recent than the old version. ignore services on a branch
        if not version_is_branch(
                versions["old"],
                release_tag_are_branches=False) and not version_is_branch(
                    versions["new"], release_tag_are_branches=False):
            # by default, assume the code lives in repo uc-cdis/<service name>
            repo_name = SERVICE_TO_REPO.get(service, service)

            # repo names special cases
            if service == "portal" and is_nde_portal:
                repo_name = "data-ecosystem-portal"

            repo_name = "uc-cdis/" + repo_name
            args = Gen3GitArgs(repo_name, versions["old"], versions["new"])
            try:
                release_notes = gen3git.main(args)
                if not release_notes:
                    raise Exception("gen3git did not return release notes")
            except Exception:
                logger.error(
                    "While checking service '{}', repo '{}', unable to get release notes with gen3git:"
                    .format(service, repo_name))
                raise
            notes = release_notes.get("deployment changes")
            if notes:
                deployment_changes[service] = update_pr_links(repo_name, notes)
            notes = release_notes.get("breaking changes")
            if notes:
                breaking_changes[service] = update_pr_links(repo_name, notes)
    return deployment_changes, breaking_changes
def test_service_is_on_branch():
    assert version_is_branch("master")
    assert version_is_branch("feat_new-thing")
    assert not version_is_branch("1.2.14.8")