Exemple #1
0
def merge_build_group(build_group):
    if len(build_group) == 1:
        build = build_group[0]
        build.original = [build]
        return build

    providers = groupby(build_group, lambda build: build.provider)
    latest_builds = [
        max(build, key=lambda build: build.number) for _, build in providers
    ]

    if len(latest_builds) == 1:
        build = latest_builds[0]
        build.original = [build]
        return build

    build = Build()
    build.original = []
    return reduce(merge_builds, latest_builds, build)
Exemple #2
0
def merge_build_group(
    build_group: Tuple[Any, List[Build]], required_hook_ids: List[str] = None
) -> Build:
    # XXX(dcramer): required_hook_ids is still dirty here, but its our simplest way
    # to get it into place
    grouped_builds = groupby(
        build_group, lambda build: (str(build.hook_id), build.provider)
    )
    latest_builds = [
        max(build, key=lambda build: build.number) for _, build in grouped_builds
    ]

    build = Build()
    build.original = []
    if set(required_hook_ids or ()).difference(
        set(str(b.hook_id) for b in build_group)
    ):
        build.result = Result.failed

    return reduce(merge_builds, latest_builds, build)