-
Notifications
You must be signed in to change notification settings - Fork 8
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
Add Cargo command for cross-compiling and packaging buildpacks #199
Conversation
e2b0bd2
to
5ae27b4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much for working on this! Also love the new guide in README.
Here's an interim review (mainly on docs) whilst I work on the rest :-)
Co-authored-by: Ed Morley <501702+edmorley@users.noreply.github.com>
Co-authored-by: Ed Morley <501702+edmorley@users.noreply.github.com>
Co-authored-by: Ed Morley <501702+edmorley@users.noreply.github.com>
Co-authored-by: Ed Morley <501702+edmorley@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much for this! I've reviewed most things so far, apart from assemble_buildpack_tarball()
(and also how that might interact with meta-buildpacks). I'll finish the rest by Monday.
Some general comments:
- there are no tests, what do you think should be tested now vs in the future?
- the cargo-make and bash implementations run
strip
on the release binary on Linux (can't run on OS X since only gnu strip can read the cross-compiled binary), whereascargo libcnb package
does not. This is likely fine to skip for now, given that Cargo is about to stabilise support for stripping viaCargo.toml
(Stabilize thestrip
profile option, now that rustc has stable-C strip
rust-lang/cargo#10088; due on stable 2022-01-13), so likely not worth us implementing in the meantime, but mentioning here for completeness. - I presume we may want to publish compiled binaries for at least Linux to speed up CI - not something to worry about for this PR, but could you file a GitHub issue for this?
For the comments left below, feel free to defer (via filing a GitHub issue) or wontfix as you feel appropriate. I just wanted to mention everything I spotted up-front rather than try and guess what should be a GitHub issue vs not.
Marking requested changes since (a) I still have assemble_buildpack_tarball
to review, (b) I'd like a glance at the rest post changes (though I don't imagine any issues).
Co-authored-by: Ed Morley <501702+edmorley@users.noreply.github.com>
I was referring to having it for local dev debugging/execution. I trust my tests and all, but sometimes I just want to exercise things manually. That command you've provided doesn't work in the libcnb dev directory:
|
@schneems That's because this repository is using the Cargo workspaces feature (there are multiple crates here). The command to use is still Using the method from the error message, gives:
In addition, these alternatives work too:
These alternatives also work for any other cargo command, for example when you want to run There is more on this here: The first chapter of the Rust book also covers using |
1085ea5
to
31ddae8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! :-)
@Malax this is really a net new project/crate. With my other PR and some other suggestions I feel more blocked as it stands now without it being merged. Let's get this in and open PRs against this existing code base IMO. |
Exactly the approach I was thinking too:
Thanks for the approve! |
I tried running as:
It needs:
Which makes sense. But it's still nice to not make people guess/hunt. My comment is less about me being able to figure it out, and more about being in the mind space that whoever is dev-ing will be tired/forgetful/new/whatever to one or more of those concepts. Where I'm coming from: I appreciate that this might be common expected knowledge from rust devs. In Ruby where every project ever has a I'm in the mind space where if I have to look something up once, it's almost always worth asking "why", then retracing my steps to finding somewhere to make the next time easier (if not eliminating the need altogether). I wanted to run the CLI, couldn't immediately figure it out...so I wanted to document it. Which has the added bonus (for me) of a knowledge share showing more canonical/less-hacky ways to get to it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀⛴🛳🚢🛸
Since: - The `target/` entry was causing leftover nested target dire ctories to be hidden and not cleaned up. - The `cargo-target/` entry is redundant as of #199.
Since: - The `target/` entry was causing leftover nested target dire ctories to be hidden and not cleaned up. - The `cargo-target/` entry is redundant as of #199.
This PR adds a Cargo command binary crate to build and package
libcnb.rs
based buildpacks.Previously, every buildpack author had to come up with a way to package their buildpack that conformed both to the CNB spec as well as the assumptions
libcnb.rs
makes about how it's packaged. Some used cargo-make, others bash scripts. Writing a proper build script and setting up the project is hard since it's common that a buildpack must be cross-compiled to another platform. Our own Ruby example shipped with aMakefile.toml
forcargo-make
, but did not document how to use it. All of the above made getting started withlibcnb.rs
very hard, especially since there were no docs around this either.With this new Cargo command,
libcnb.rs
users can use a centrally managed packaging tool for their buildpacks and can fully concentrate on writing their buildpack instead of build logic. It tries to make cross-compiling easier by providing useful hints.The README has been updated to transform the existing "Hello World Buildpack" section into an end-to-end quickstart guide that includes packaging and running the buildpack.
Installation
Users will install it via
cargo install libcnb-cargo
, to try it out before the release on crates.io run:Usage
Example Output
What's next
I consider this an MVP, there are many improvements that could be made and it could have more features. We'll implement these features and fixes along the way.
This new
libcnb-cargo
crate is, besides a binary crate, also a library crate that exposes the building blocks for the packaging process. The intent is to use these building blocks in an integration test solution, ensuring parity between command line packaging and integration testing.GUS-W-10229113.