Giter Club home page Giter Club logo

canonicalwebteam.launchpad's Introduction

canonicalwebteam.launchpad

Classes for triggering builds of snaps and Ubuntu images through the Launchpad API.

Usage

Local development

For local development, it's best to test this module with one of our website projects like ubuntu.com. For more information, follow this guide (internal only).

SnapBuilder

from canonicalwebteam.launchpad import SnapBuilder

snap_builder = SnapBuilder(
    username="build.snapcraft.io",
    token=os.getenv("SNAP_BUILDER_TOKEN"),
    secret=os.getenv("SNAP_BUILDER_SECRET"),
)

snap_name = "new-test-snap"
git_repo = "https://github.com/build-staging-snapcraft-io/test1"
snap_builder.create_snap(snap_name, git_repo)

new_snap = snap_builder.get_snap_by_store_name("new-test-snap")

ImageBuilder

from canonicalwebteam.launchpad import ImageBuilder

image_builder = ImageBuilder(
    username="image.build",
    token=os.getenv("IMAGE_BUILDER_TOKEN"),
    secret=os.getenv("IMAGE_BUILDER_SECRET"),
)

image_builder.build_image(
    board="cm3", system="core16", snaps=["code", "toto"]
)

Test fixtures

Tests check calls against fixtures representing the Launchpad API. These fixtures are generated using vcrpy, based on real calls to the API when the test was first run.

To new tests that rely on new API responses, or if we need to regenerate existing fixtures because the API has changed, the secrets need to be provided to authenticate with the API as follows:

export SNAP_BUILDER_TOKEN={token}
export SNAP_BUILDER_SECRET={secret}
export IMAGE_BUILDER_TOKEN={token}
export IMAGE_BUILDER_SECRET={secret}

rm tests/cassettes/...  # Remove any fixtures you need to regenerate

./setup.py test  # Run tests again to regenerate fixtures

canonicalwebteam.launchpad's People

Contributors

anthonydillon avatar cjwatson avatar jkfran avatar lukewh avatar nottrobin avatar petesfrench avatar renovate-bot avatar renovate[bot] avatar sil2100 avatar sowasred2012 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

canonicalwebteam.launchpad's Issues

Dependency Dashboard

This issue provides visibility into Renovate updates and their statuses. Learn more

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.


  • Check this box to trigger a request for Renovate to run again on this repository

requestBuilds parameters are incorrect for snap builds

Re-filing https://bugs.launchpad.net/launchpad/+bug/1867689 here.

Launchpad.build_snap passes incorrect parameters to Launchpad's snap.requestBuilds method. Here's the location of the incorrect code:

https://github.com/canonical-web-and-design/canonicalwebteam.launchpad/blob/master/canonicalwebteam/launchpad/models.py#L237-L244

The old code in build.snapcraft.io was correct, and looked like this instead:

https://github.com/canonical-web-and-design/build.snapcraft.io/blob/master/src/server/handlers/launchpad.js#L842-L848

canonicalwebteam.launchpad's logic should be replaced with the correct logic from build.snapcraft.io: it should copy auto_build_archive and auto_build_pocket from the snap to the archive and pocket parameters respectively, and if the snap has a non-null auto_build_channels property then it should pass that as the channels parameter. It should not pass "channels": "snapcraft,apt".

I'm happy to consult on anything else where you aren't sure what the correct parameters are - I wrote most of the relevant code in build.snapcraft.io and still help to maintain the Launchpad end of things.

Launchpad.get_collection_entries doesn't handle batching correctly

Collections larger than a certain size are split into multiple batches by Launchpad; but canonicalwebteam.launchpad.models.Launchpad.get_collection_entries ignores everything after the first batch. Anything that needs to iterate over a potentially-unbounded collection generally needs to work in an iterator/generator style, so the API probably needs to be changed in some way to avoid creating timeout problems.

My preference would be for this all to be refactored on top of launchpadlib (or at least on top of lazr.restfulclient) rather than reinventing the wheel, though it would also be possible to do it manually. Let us know if you need help with anything there (e.g. refactoring on top of launchpadlib might require asking us questions about how to arrange credentials handling).

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: Cannot find preset's package (github>whitesource/merge-confidence:beta)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.