Esempio n. 1
0
def add_release(body):
    session = g.db.session
    r = Release(product=body['product'],
                version=body['version'],
                branch=body['branch'],
                revision=body['revision'],
                build_number=body['build_number'],
                release_eta=body.get('release_eta'),
                status='scheduled',
                partial_updates=body.get('partial_updates'))
    try:
        r.generate_phases(
            partner_urls=current_app.config.get('PARTNERS_URL'),
            github_token=current_app.config.get('GITHUB_TOKEN'),
        )
        session.add(r)
        session.commit()
        release = r.json
    except UnsupportedFlavor as e:
        raise BadRequest(description=e.description)

    notify_via_irc(
        f'New release ({r.product} {r.version} build{r.build_number}) was just created.'
    )

    return release, 201
Esempio n. 2
0
def add_release(body):
    # we must require scope which depends on product
    required_permission = f'{SCOPE_PREFIX}/add_release/{body["product"]}'
    if not current_user.has_permissions(required_permission):
        user_permissions = ', '.join(current_user.get_permissions())
        abort(401, f'required permission: {required_permission}, user permissions: {user_permissions}')

    session = current_app.db.session
    product = body['product']
    r = Release(
        product=product,
        version=body['version'],
        branch=body['branch'],
        revision=body['revision'],
        build_number=body['build_number'],
        release_eta=body.get('release_eta'),
        status='scheduled',
        partial_updates=body.get('partial_updates'),
        product_key=body.get('product_key'),
    )
    try:
        r.generate_phases(
            partner_urls=current_app.config.get('PARTNERS_URL'),
            github_token=current_app.config.get('GITHUB_TOKEN'),
        )
        session.add(r)
        session.commit()
        release = r.json
    except UnsupportedFlavor as e:
        raise BadRequest(description=e.description)

    notify_via_irc(product, f'New release ({product} {r.version} build{r.build_number}) was just created.')

    return release, 201
Esempio n. 3
0
def sync_releases(releases):
    session = g.db.session
    for release in releases:
        try:
            session.query(Release).filter(
                Release.name == release['name']).one()
            # nothing todo
        except NoResultFound:
            status = 'shipped'
            if not release['shippedAt']:
                status = 'aborted'
            r = Release(
                product=release['product'],
                version=release['version'],
                branch=release['branch'],
                revision=release['mozillaRevision'],
                build_number=release['buildNumber'],
                release_eta=release.get('release_eta'),
                partial_updates=release.get('partials'),
                status=status,
            )
            r.created = release['submittedAt']
            r.completed = release['shippedAt']
            session.add(r)
            session.commit()
    return jsonify({'ok': 'ok'})
Esempio n. 4
0
def add_release(body):
    # we must require scope which depends on product
    required_permission = f'{SCOPE_PREFIX}/add_release/{body["product"]}'
    if not current_user.has_permissions(required_permission):
        user_permissions = ", ".join(current_user.get_permissions())
        abort(
            401,
            f"required permission: {required_permission}, user permissions: {user_permissions}"
        )

    product = body["product"]
    branch = body["branch"]

    product_disabled = branch in get_disabled_products().get(product, [])
    if current_user.type == AuthType.TASKCLUSTER and product_disabled:
        abort(401, "Taskcluster based submissions are disabled")

    session = current_app.db.session
    partial_updates = body.get("partial_updates")
    if partial_updates == "auto":
        if product not in [
                Product.FIREFOX.value, Product.DEVEDITION.value
        ] or branch not in ["try", "releases/mozilla-beta", "projects/maple"]:
            abort(400, "Partial suggestion works for automated betas only")

        partial_updates = _suggest_partials(product=product, branch=branch)
    release = Release(
        branch=branch,
        build_number=body["build_number"],
        partial_updates=partial_updates,
        product_key=body.get("product_key"),
        product=product,
        release_eta=body.get("release_eta"),
        repo_url=body.get("repo_url", ""),
        revision=body["revision"],
        status="scheduled",
        version=body["version"],
    )
    try:
        release.generate_phases()
        session.add(release)
        session.commit()
    except UnsupportedFlavor as e:
        raise BadRequest(description=e.description)
    except TaskclusterRestFailure as e:
        # Report back Taskcluster failure for better visibility of the actual
        # issue. Usually it happens when we cannot find the indexed task.
        abort(400, str(e))

    logger.info("New release of %s", release.name)
    notify_via_irc(product, f"New release of {release.name}")

    return release.json, 201
Esempio n. 5
0
def add_release(body):
    # we must require scope which depends on product
    required_permission = f'{SCOPE_PREFIX}/add_release/{body["product"]}'
    if not current_user.has_permissions(required_permission):
        user_permissions = ", ".join(current_user.get_permissions())
        abort(
            401,
            f"required permission: {required_permission}, user permissions: {user_permissions}"
        )

    product = body["product"]
    branch = body["branch"]

    product_disabled = branch in get_disabled_products().get(product, [])
    if current_user.type == AuthType.TASKCLUSTER and product_disabled:
        abort(401, "Taskcluster based submissions are disabled")

    session = current_app.db.session
    partial_updates = body.get("partial_updates")
    if partial_updates == "auto":
        if product not in [
                Product.FIREFOX.value, Product.DEVEDITION.value
        ] or branch not in ["try", "releases/mozilla-beta", "projects/maple"]:
            abort(400, "Partial suggestion works for automated betas only")

        partial_updates = _suggest_partials(product=product, branch=branch)
    r = Release(
        product=product,
        version=body["version"],
        branch=branch,
        revision=body["revision"],
        build_number=body["build_number"],
        release_eta=body.get("release_eta"),
        status="scheduled",
        partial_updates=partial_updates,
        product_key=body.get("product_key"),
    )
    try:
        r.generate_phases(partner_urls=current_app.config.get("PARTNERS_URL"),
                          github_token=current_app.config.get("GITHUB_TOKEN"))
        session.add(r)
        session.commit()
        release = r.json
    except UnsupportedFlavor as e:
        raise BadRequest(description=e.description)

    notify_via_irc(
        product,
        f"New release ({product} {r.version} build{r.build_number}) was just created."
    )

    return release, 201
Esempio n. 6
0
async def test_fetch_l10n_data():
    release = Release(
        product="firefox",
        branch="releases/mozilla-beta",
        version="62.0b16",
        revision="812b11ed03e02e7d5ec9f23c6abcbc46d7859740",
        build_number=1,
        release_eta=None,
        status="shipped",
        partial_updates=None,
    )
    session = aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(total=1))
    url = re.compile(r"^https://hg\.mozilla\.org/")
    with aioresponses() as m:
        m.get(url, status=200, payload=dict(a="a"))
        (_, changesets) = await fetch_l10n_data(session,
                                                release,
                                                raise_on_failure=True,
                                                use_cache=False)
        assert changesets == {"a": "a"}

        # simulate HTTP errors.
        # Fail first time
        m.get(url, status=500)
        # Return proper result second time
        m.get(url, status=200, payload=dict(a="a"))
        (_, changesets) = await fetch_l10n_data(session,
                                                release,
                                                raise_on_failure=True,
                                                use_cache=False)
        assert changesets == {"a": "a"}

        # simulate timeout
        # Fail first time
        m.get(url, timeout=True)
        # Return proper result second time
        m.get(url, status=200, payload=dict(a="a"))
        (_, changesets) = await fetch_l10n_data(session,
                                                release,
                                                raise_on_failure=True,
                                                use_cache=False)
        assert changesets == {"a": "a"}
Esempio n. 7
0
def add_release(body):
    session = flask.g.db.session
    r = Release(product=body['product'],
                version=body['version'],
                branch=body['branch'],
                revision=body['revision'],
                build_number=body['build_number'],
                release_eta=body.get('release_eta'),
                status='scheduled',
                partial_updates=body.get('partial_updates'))
    try:
        r.generate_phases(
            partner_urls=flask.current_app.config.get('PARTNERS_URL'),
            github_token=flask.current_app.config.get('GITHUB_TOKEN'),
        )
        session.add(r)
        session.commit()
        return r.json, 201
    except UnsupportedFlavor as e:
        raise BadRequest(description=e.description)
Esempio n. 8
0
def shipit_import(api_from):
    session = flask.current_app.db.session

    click.echo('Fetching release list...', nl=False)
    req = requests.get(f'{api_from}/releases?status=shipped,aborted,scheduled')
    req.raise_for_status()
    releases = req.json()

    for release in releases:
        r = Release(
            product=release['product'],
            version=release['version'],
            branch=release['branch'],
            revision=release['revision'],
            build_number=release['build_number'],
            release_eta=release.get('release_eta'),
            partial_updates=release.get('partials'),
            status=release['status'],
        )
        r.created = release['created']
        r.completed = release['completed'] or release['created']
        session.add(r)
        session.commit()
Esempio n. 9
0
def shipit_import(api_from):
    session = flask.current_app.db.session

    click.echo("Fetching release list...", nl=False)
    req = requests.get(f"{api_from}/releases?status=shipped,aborted,scheduled")
    req.raise_for_status()
    releases = req.json()

    for release in releases:
        r = Release(
            product=release["product"],
            version=release["version"],
            branch=release["branch"],
            revision=release["revision"],
            build_number=release["build_number"],
            release_eta=release.get("release_eta"),
            partial_updates=release.get("partials"),
            status=release["status"],
        )
        r.created = release["created"]
        r.completed = release["completed"] or release["created"]
        session.add(r)
        session.commit()