libcnb.rs
libcnb.rs copied to clipboard
Test on Windows in CI
As found in #313, libcnb is not currently compilable on Windows.
In order to (a) find out what needs fixing, (b) ensure it doesn't regress when we do fix it, we should experiment with running adding Windows to the CI test matrix.
Supporting Windows can also mean a few different things:
- No compile errors for this repo (ie:
cargo check
succeeds). - The unit tests for this repo pass (ie:
cargo test
succeeds iff not using--ignored
). - Cross-compiling a libcnb buildpack to
x86_64-unknown-linux-musl
is possible on Windows (and is supported by the cross-compile assistance help). - Integration tests for linux libcnb buildpacks can be run on Windows (ie: in addition to (3),
libcnb-test
's Docker parts work etc) - libcnb can be used to create Windows buildpacks (upstream docs)
It seems (4) is not currently possible on GitHub actions (presuming nothing has changed since with the new Windows server 2022 images): https://github.com/actions/virtual-environments/issues/1143#issuecomment-651178811
And if we ever wanted to do (5), I think that should be tracked separately (any support is currently experimental upstream, so likely not worth worrying about for now).
As such, I see this GitHub issue as potentially covering 1-3.
- Cross-compiling a libcnb buildpack to
x86_64-unknown-linux-musl
is possible on Windows (and is supported by the cross-compile assistance help).
Hmm so it seems cross-compiling to x86_64-unknown-linux-musl
on Windows might be a pain if any dependencies rely on C. One such dependency is ring, which is a dependency of rustls and so pretty unavoidable.
Documentation is also pretty much non-existent. I found these: https://github.com/japaric/rust-cross/issues/33#issuecomment-500111581 https://github.com/briansmith/ring/issues/1244 https://github.com/briansmith/ring/issues/894
It does seem that for Windows users, using WSL2 might be a better option. In which case us testing natively on Windows in CI is somewhat pointless, unless:
- We end up having contributors that want to run check/clippy/unit tests (only) on Windows and don't want to use WSL2.
- We in the future end up supporting Windows buildpacks.
- We want to actively test on Windows to help prevent regressions with the slightly unusual libcnb usage outside of Pack use-cases (eg the use-case seen in #313)
Hmm so it seems cross-compiling to x86_64-unknown-linux-musl on Windows might be a pain if any dependencies rely on C. One such dependency is ring, which is a dependency of rustls and so pretty unavoidable.
You can give cargo-zigbuild a try, it should work on Windows. And it's also a library so you can integrate it into libcnb.rs pretty easily, for example https://github.com/calavera/cargo-lambda/pull/1 .