Skip to content

Actually, cargo doesn't "mostly just work"#444

Merged
hawkw merged 6 commits intomasterfrom
eliza/actually-cargo-doesnt-just-work
Feb 5, 2024
Merged

Actually, cargo doesn't "mostly just work"#444
hawkw merged 6 commits intomasterfrom
eliza/actually-cargo-doesnt-just-work

Conversation

@hawkw
Copy link
Copy Markdown
Member

@hawkw hawkw commented Jan 31, 2024

The DEVELOPING.mkdn file currently states that cargo build and
cargo test "mostly just works". Actually, when building Humility for
the first time, they may not just work, if the cargo readme cargo
subcommand or libudev headers are missing.

I've updated the DEVELOPING.mkdn file to state that pkg-config and
libudev are necessary to build Humility.

Additionally, I've changed the cargo xtask readme xtask and the
humility-cmd-doc build script to depend on cargo-readme as a library
crate and call into its generate_readme function, rather than using it
as an external binary that's invoked using std::process::Command. This
way, the cargo-readme binary no longer needs to be installed using
cargo install in order to build Humility instead, it's just a normal
Cargo package dependency.

In addition to making the first-time build experience a bit smoother by
reducing the number of external dependencies that need to be installed,
this also means our cargo-readme dependency is now a normal versioned
crate dependency. That ensures that everyone developing Humility gets
the cargo-readme version present in the lockfile, ensuring that
cargo-readme generates consistent output. Installing the binary using
cargo-install doesn't provide that guarantee, as it's not versioned,
so if upstream changed their output format, the generated docs might
change unnecessarily between different development systems with
different cargo-readme versions installed.

The `DEVELOPING.mkdn` file currently states that `cargo build` and `cargo
test` "mostly just works". Actually, when building Humility for the
first time, they may not just work, if the `cargo readme` cargo
subcommand or `libudev` headers are missing. I've updated the
`DEVELOPING.mkdn` file to state that these dependencies are necessary to
build Humility.
@hawkw hawkw requested a review from cbiffle January 31, 2024 21:56
This commit changes the `cargo xtask readme` xtask and the
`humility-cmd-doc` build script to depend on `cargo-readme` as a library
crate and call into its `generate_readme` function, rather than using it
as an external binary that's invoked using `std::process::Command`. This
way, the `cargo-readme` binary no longer needs to be installed using
`cargo install` in order to build Humility instead, it's just a normal
Cargo package dependency.

In addition to making the first-time build experience a bit smoother by
reducing the number of external dependencies that need to be installed,
this also means our `cargo-readme` dependency is now a normal versioned
crate dependency. That ensures that everyone developing Humility gets
the `cargo-readme` version present in the lockfile, ensuring that
`cargo-readme` generates consistent output. Installing the binary using
`cargo-install` doesn't provide that guarantee, as it's not versioned,
so if upstream changed their output format, the generated docs might
change unnecessarily between different development systems with
different `cargo-readme` versions installed.
@hawkw hawkw requested a review from bcantrill January 31, 2024 23:26
@cbiffle
Copy link
Copy Markdown
Contributor

cbiffle commented Feb 1, 2024

Oh, fantastic, the implicit reliance on cargo readme and lack of versioning have always bugged me.

Copy link
Copy Markdown
Contributor

@cbiffle cbiffle left a comment

Choose a reason for hiding this comment

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

I like it, fwiw... should get @bcantrill 's eyes on it

Comment thread Cargo.lock
Comment thread cmd/doc/build.rs Outdated
Copy link
Copy Markdown
Contributor

@bcantrill bcantrill left a comment

Choose a reason for hiding this comment

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

This looks great -- thank you!

@hawkw hawkw merged commit 64968ed into master Feb 5, 2024
@hawkw hawkw deleted the eliza/actually-cargo-doesnt-just-work branch February 5, 2024 23:39
hawkw added a commit that referenced this pull request Feb 27, 2024
Currently, the Humility CI workflow attempts to run `cargo install
cargo-readme`. Unfortunately, this is now broken on our MSRV, because
`cargo-readme` won't build with un-locked dependencies on our MSRV (e.g.
[this failed CI job][1]). Fortunately, however, we no longer actually
need to install `cargo-readme` using `cargo-install`; as of #444, our
build scripts now depend on it as a normal lib dep, instead. And because
we depend on it as a normal Cargo lib dep, it's in our lockfile, and the
version in the lockfile should (hopefully) build on MSRV.

This commit removes the `cargo install cargo-readme` step from CI.
Hopefully, this fixes the CI build...

[1]: https://github.com/oxidecomputer/humility/actions/runs/8072478131/job/22054313203?pr=449
hawkw added a commit that referenced this pull request Feb 28, 2024
Currently, the Humility CI workflow attempts to run `cargo install
cargo-readme`. Unfortunately, this is now broken on our MSRV, because
`cargo-readme` won't build with un-locked dependencies on our MSRV (e.g.
[this failed CI job][1]). Fortunately, however, we no longer actually
need to install `cargo-readme` using `cargo-install`; as of #444, our
build scripts now depend on it as a normal lib dep, instead. And because
we depend on it as a normal Cargo lib dep, it's in our lockfile, and the
version in the lockfile should (hopefully) build on MSRV.

This commit removes the `cargo install cargo-readme` step from CI.
Hopefully, this fixes the CI build...

[1]: https://github.com/oxidecomputer/humility/actions/runs/8072478131/job/22054313203?pr=449
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.

3 participants