Exemple #1
0
async def buildhub(product, version):
    if 'build' in version:
        version = version.replace('build', 'rc')

    try:
        build_ids = await get_build_ids_for_version(product, version)
        status = True
    except TaskError:
        status = False

    channel = get_version_channel(product, strip_candidate_info(version))
    exists_message = 'Build IDs for this release: {}'
    missing_message = 'Buildhub does not contain any information about this release yet.'

    if status:
        if channel is Channel.NIGHTLY:
            last_expected_nightly = yesterday(formating='%Y%m%d')
            if build_ids[0][:8] < last_expected_nightly:
                status = Status.INCOMPLETE
                build_ids = build_ids[:3]
            else:
                build_ids = [
                    bid for bid in build_ids if bid > last_expected_nightly
                ]

        exists_message = exists_message.format(', '.join(build_ids))

    url = get_buildhub_url(product, version, channel)
    return build_task_response(status, url, exists_message, missing_message)
Exemple #2
0
async def partner_repacks(product, version):
    channel = get_version_channel(product, version)
    async with get_session() as session:
        if channel is Channel.CANDIDATE:
            url = build_version_url(product, version)
            version = strip_candidate_info(version)
        else:
            base_url = 'https://archive.mozilla.org/pub/{}/candidates/{}-candidates/'.format(
                product, version)
            success = False
            async with session.get(base_url, headers=JSON_HEADERS) as resp:
                if resp.status != 200:
                    url = base_url
                    message = "No candidates found for that version."
                    return build_task_response(success, url, message)

                body = await resp.json()
                builds = sorted([
                    p.strip('/')
                    for p in body['prefixes'] if p.startswith('build')
                ],
                                reverse=True)
                url = '{}{}/'.format(base_url, builds[0])

        # Look for partner-repacks
        async with session.get(url, headers=JSON_HEADERS) as resp:
            body = await resp.json()
            dirs = sorted([p.strip('/') for p in body['prefixes']])
            if 'partner-repacks' in dirs:
                success = True
                message = "Partner-repacks found in {}".format(url)
            else:
                message = "No partner-repacks in {}".format(url)
            return build_task_response(success, url, message)
Exemple #3
0
async def get_releases(product):
    RELEASE_CHANNEL = {
        'devedition': 'aurora',
        'firefox': 'release',
    }

    query = {
        "aggs": {
            "by_version": {
                "terms": {
                    "field": "target.version",
                    "size": 1000,
                    "order": {
                        "_term": "desc"
                    }
                }
            }
        },
        "query": {
            "bool": {
                "filter": [{
                    "term": {
                        "source.product": product
                    }
                }, {
                    "term": {
                        "target.channel": RELEASE_CHANNEL[product]
                    }
                }]
            }
        },
        "size": 0
    }
    async with get_session() as session:
        url = '{}/buckets/build-hub/collections/releases/search'
        url = url.format(BUILDHUB_SERVER)
        async with session.post(url, data=json.dumps(query)) as response:
            if response.status != 200:
                message = "Buildhub is not available ({})".format(
                    response.status)
                url = "https://mozilla-services.github.io/buildhub/?products[0]={}".format(
                    product)
                raise TaskError(message, url=url)

            data = await response.json()
        versions = sorted([
            r['key'] for r in data['aggregations']['by_version']['buckets']
            if strip_candidate_info(r['key']) == r['key']
        ],
                          key=lambda version: build_version_id(version))

        if not versions:
            message = "Couldn't find any version matching."
            url = "https://mozilla-services.github.io/buildhub/?products[0]={}".format(
                product)
            raise TaskError(message, url=url)

        return versions
Exemple #4
0
async def get_build_ids_for_version(product, version, *, size=10):
    channel = get_version_channel(product, strip_candidate_info(version))
    channel_value = channel.value.lower()
    if product == "devedition":
        channel_value = "aurora"

    query = {
        "aggs": {
            "by_version": {
                "terms": {
                    "field": "build.id",
                    "size": size,
                    "order": {
                        "_term": "desc"
                    }
                }
            }
        },
        "query": {
            "bool": {
                "filter": [{
                    "term": {
                        "target.channel": channel_value
                    }
                }, {
                    "term": {
                        "source.product": product
                    }
                }, {
                    "term": {
                        "target.version": version
                    }
                }]
            }
        },
        "size": 0
    }
    async with get_session() as session:
        url = '{}/buckets/build-hub/collections/releases/search'
        url = url.format(BUILDHUB_SERVER)
        async with session.post(url, data=json.dumps(query)) as response:
            data = await response.json()
        build_ids = [
            r['key'] for r in data['aggregations']['by_version']['buckets']
        ]

        if not build_ids:
            message = "Couldn't find any build matching."
            raise TaskError(message,
                            url=get_buildhub_url(product, version, channel))

        return build_ids