Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add script for building rocks via lpci #8

Merged
merged 15 commits into from
Apr 4, 2024
Merged

Conversation

cjdcordeiro
Copy link
Collaborator

@cjdcordeiro cjdcordeiro commented Feb 5, 2024

In this PR there is a new standalone Python script that takes a rockcraft.yaml file from the current directory and offloads the corresponding builds to Launchpad, via lpci.

How does it work?

  1. the user provides a valid LP credential (or creates one during the first run of the script, interactively)
  2. a local Git repo is created in a temporary folder, and all the contents from the user's current directory are copied there
  3. a .launchpad.yaml configuration file is created in this temporary git repo. The yaml file is populated according to the rockcraft.yaml's build-base and platforms
  4. a brand new repo (with a time-based identifier) is created in Launchpad
  5. the local temporary git repo, with the .launchpad.yaml file, is pushed to the newly created LP repo
  6. the above step automatically triggers the CI builds in Launchpad
  7. the script keeps fetching those builds' statuses until they are all complete
  8. finally, for the successful builds, the rock artefacts (aka OCI archives) are downloaded into the current directory

Try it

To try it, you can simply

pip install -r requirements.txt
./requirements.sh
rockcraft init   # to get a demo rockfile to play with
./rockcraft_lpci_build.py --lp-credentials-file <path-to-where-you-want-to-save-your-creds> --allow-build-failures 

@cjdcordeiro cjdcordeiro requested a review from linostar February 5, 2024 17:06
@cjdcordeiro cjdcordeiro marked this pull request as draft February 5, 2024 17:06
@cjdcordeiro cjdcordeiro force-pushed the rockcraft-lpci branch 2 times, most recently from 31895f5 to 04e0f56 Compare February 5, 2024 17:28
@linostar
Copy link

Add a README with the following steps:

How to use:

1. Clone the repo and go to rockcraft_lpci repo. Optionally, create a virtualenv dir there and activate the virtualenv
2. Run: pip install -r requirements.txt
3. Run: ./requirements.sh
4. Create/move your rockcraft.yaml in the current dir
5. Run: python3 rockcraft_lcpi_build.py --allow-build-failures --lp-credentials-file <path-to-where-you-want-to-save-your-creds> 

@linostar
Copy link

Is the --lp-credentials-b64 argument necessary? It apparently requires the oauth token/secret encoded in base64, but it doesn't tell the user that explicitly, plus the user has to create the oauth token manually.

@linostar
Copy link

I am not sure if this is a desired effect, but I'll mentioned it here.
Whenever a build fails, launchpad sends an email notification containing a link to the build log. However, if you are not fast enough the build logs link will give 404 because the temporary repo will be deleted once all builds are done even if they fail.

@cjdcordeiro
Copy link
Collaborator Author

I am not sure if this is a desired effect, but I'll mentioned it here. Whenever a build fails, launchpad sends an email notification containing a link to the build log. However, if you are not fast enough the build logs link will give 404 because the temporary repo will be deleted once all builds are done even if they fail.

Y that's the case. I could add an option to "--keep-repo-alive". But since the script downloads the logs, I don't think there's a need for that.

@cjdcordeiro cjdcordeiro marked this pull request as ready for review March 13, 2024 13:56
@cjdcordeiro cjdcordeiro requested a review from linostar March 13, 2024 13:56
@cjdcordeiro cjdcordeiro self-assigned this Mar 13, 2024
Copy link

@linostar linostar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to go.

@cjdcordeiro
Copy link
Collaborator Author

@linostar this is ready for review. the unit tests are still very minimal, but we might just go ahead with them like this just to get something started for now

Copy link

@linostar linostar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A wholesome effort. Great work.

@cjdcordeiro cjdcordeiro merged commit 0fa2172 into main Apr 4, 2024
1 check passed
@cjdcordeiro cjdcordeiro deleted the rockcraft-lpci branch April 4, 2024 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants