Page MenuHomePhabricator

Support Rust repositories in CI
Open, Needs TriagePublic

Description

There is a slowly growing group of Wikimedia developers migrating to using Rust for its various performance and memory safety features (c.f. T194953, Tools using Rust). Personally I'm starting to switch some of my Toolforge tools (hosted in Gerrit) to use it.

I imagine we'd have the following jobs as a starting point:

  • rust-test, runs the following:
    • cargo fmt -- --check # code formatting check
    • cargo clippy --all-features -- -D warnings # linter/static analysis
    • cargo test --all-features --verbose # build and run tests
  • rust-coverage, (coverage and postmerge)
    • cargo install cargo-tarpaulin
    • cargo tarpaulin --all-features --out=Xml --out=Html --output-dir=coverage
      • Note that this is in cobertura format, we need to convert it to clover using the script we already have
  • rust-rustdoc (publish/postmerge)
    • cargo rustdoc (using nightly) # publish local docs similar to https://docs.rs

We might also have a rust-binary postmerge job that builds the binary in release mode and provides the binary as a jenkins artifact. For each job we also need a variant for the nightly version of rust, which I'll explain in a bit.

The main non-standard thing we have to do is how we install rust/cargo itself. The version packaged in Debian Buster is already dated and doesn't support our need to support nightly (see upstream's explanation at https://doc.rust-lang.org/stable/book/appendix-07-nightly-rust.html). Upstream's solution for distributing the language is to use rustup, a Rust program that downloads and manages pre-built versions or rustc, cargo, etc..

I think we should take the same approach that rust's own docker images use: https://github.com/rust-lang/docker-rust/blob/master/Dockerfile-debian.template. We download rustup-init, use it to bootstrap rustup, which is then in turn used to install rustc/cargo/clippy/rustdoc/etc. We would want to update the image every 6 weeks or so based on the release schedule.

For caching, we need to set the $CARGO_HOME env variable to /cache. We also want to cache ~/src/target to avoid rebuilding everything from scratch, so we might want some cp/mv helpers to put that directory into /cache before and after jobs.

Event Timeline

Legoktm created this task.Jun 30 2020, 11:55 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJun 30 2020, 11:55 PM

Change 620284 had a related patch set uploaded (by Legoktm; owner: Legoktm):
[integration/config@master] docker: Add Rust image

https://gerrit.wikimedia.org/r/620284

Change 620284 merged by jenkins-bot:
[integration/config@master] docker: Add Rust image

https://gerrit.wikimedia.org/r/620284

Mentioned in SAL (#wikimedia-releng) [2020-08-14T13:06:03Z] <hashar> Successfully tagged docker-registry.discovery.wmnet/releng/rust:1.45.2-1 # T256827