router
router copied to clipboard
Have CI use rust-toolchain.toml and not install another redudant toolchain
CI is configured like this:
https://github.com/apollographql/router/blob/ef62de020970e87dd77572fbb1b1c2b72542b575/.circleci/config.yml#L8-L9 https://github.com/apollographql/router/blob/ef62de020970e87dd77572fbb1b1c2b72542b575/.circleci/config.yml#L183-L186
to run this script:
https://github.com/CircleCI-Public/rust-orb/blob/70397fd8c966134d9a2045a176a62ea99a4d3e76/src/scripts/install.sh#L3-L10
Note that if the version parameter was set to a string that is not stable, then rustup.sh would first install stable (its default), then the script will run rustup toolchain install "$RUST_VERSION" to install a second toolchain and make it the default.
Later when first running cargo, that default toolchain is ignored since we have a rust-toolchain.toml file in the repository that specifies channel = "1.61.0". rustup proceeds to download and install 1.61.0 automatically. (It doesn’t matter that stable happens to be 1.61.0 today, rustup considers them different update channels.)
As a result:
- CI spends unnecessary time to download and extract two toolchains
- We have YAML configuration that looks meaningful but isn’t.
We should have CI only download one Rust toolchain and only have a single location that determines which (or look like it does).
I think rust-toolchain.toml is better than .circleci/config.yml since it is more standard and also applies to local development. A way to do that is to install rustup with ./rustup.sh --default-toolchain none and let it download the toolchain specified in rust-toolchain.toml the first time it is needed. If we want that to be a separate CI job from cargo build, I think running cargo fetch is a good candidate, putting the download of a Rust toolchain together with that of Rust crate dependencies.
I’m not sure what this means for the rust orb. Does it do much more than have another layer of YAML indirection to run Cargo?