Skip to content

Commit

Permalink
fix(rust): Remove test statements and fully remove rust-toolchain fro…
Browse files Browse the repository at this point in the history
…m CI.
  • Loading branch information
stevenj committed May 7, 2024
1 parent 59f2a7f commit 0bca57d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ We will not use the `rust-version` feature of `cargo.toml` during initial bring
We have not defined a maximum range of valid Rust versions, and always build ONLY with the version defined in `rust-toolchain.toml`.

Currently the ONLY supported rust version is the one specified by `rust-toolchain.toml`.
However `rust-toolchain.toml` breaks CI when it is used, so this file is ONLY used for local development and MUST
be synchronized with the toolchain version used in CI.

If at a later time, a range of rust versions is decided to be supported then:

Expand Down
8 changes: 1 addition & 7 deletions docs/src/guides/languages/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,7 @@ Clippy linter, LLVM tools for generating code coverage, and nightly toolchain ar
2. Next step is to copy source code of the project.
Note that you need to copy only needed files for Rust build process,
any other irrelevant stuff should omitted.
3. And finally finalize the build with `+SETUP` FUNCTION.
The `+SETUP` FUNCTION requires `rust-toolchain.toml` file,
with the specified `channel` option in it.
This `rust-toolchain.toml` file could be specified
via the `toolchain` argument of the `+SETUP` target like this
with defining the specific location of this file with the specific name.
By default `toolchain` setup to `rust-toolchain.toml`.
3. And finally finalize the build with `+SETUP` FUNCTION which takes no arguments.

### Running checks

Expand Down
32 changes: 7 additions & 25 deletions earthly/rust/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ IMPORT ../../utilities/scripts AS scripts
# cspell: words TARGETPLATFORM TARGETOS TARGETARCH TARGETVARIANT USERPLATFORM USEROS USERARCH USERVARIANT
# cspell: words findutils fileset

# Base Rustup build container.
# Parameters:
# * toolchain : The `rust-toolchain` toml file.
# rust-base : Base Rustup build container.
rust-base:
ARG TARGETPLATFORM
ARG TARGETOS
Expand All @@ -28,9 +26,8 @@ rust-base:
ARG USERVARIANT

# This is our base Host toolset, and rustup.
# The ACTUAL version of rust that will be used, and available targets
# is controlled by a `rust-toolchain.toml` file when the `SETUP` FUNCTION is run.
# HOWEVER, It is enforced that the rust version in `rust-toolchain.toml` MUST match this version.
# Never use `rust-toolchain.toml` in CI as it breaks builds.
# The only toolchain supported is the one installed here.
FROM rust:1.78-alpine3.19

WORKDIR /root
Expand Down Expand Up @@ -112,19 +109,14 @@ rust-base-plus-tools:
installer:
FROM +rust-base-plus-tools

RUN rustup show

# Call +INIT before copying the source file to avoid installing dependencies every time source code changes.
# This parametrization will be used in future calls to functions of the library
# Init using the common cat-ci cache prefix.
DO rust+INIT --keep_fingerprints=true

RUN rustup show

# Set the mount cache env vars
DO rust+SET_CACHE_MOUNTS_ENV

RUN rustup show

# Install the default cargo config, and ensure its in the cached CARGO_HOME as well.
COPY stdcfgs/cargo_config.toml $CARGO_INSTALL_ROOT/config.toml
DO +EXECUTE --cmd="cp $CARGO_INSTALL_ROOT/config.toml $CARGO_HOME/config.toml"
Expand All @@ -140,8 +132,6 @@ installer:
# This is to enforce consistent compiler and tool configuration on local setup and CI builds.
COPY --dir stdcfgs /stdcfgs

RUN rustup show

# Builds all the rust-base targets for each supported DOCKER architecture.
# Currently only used for multi-platform cross build testing.
# This will ONLY work if you have `qemu` properly setup on linux and `rosetta` for
Expand Down Expand Up @@ -278,14 +268,6 @@ SETUP:
FUNCTION
FROM +installer

RUN rustup show

#ARG toolchain=./rust-toolchain.toml

# Copy our toolchain dependency.
#COPY $toolchain ./rust-toolchain.toml

RUN rustup show

# Toolchain MUST be the same as vendored, and if it is the toolchain is
# already installed.
# The ONLY toolchain we support is the one in the installer.
# DO NOT copy the `rust-toolchain.toml` file into CI as it breaks
# the toolchain on some targets and leads to build failure.
7 changes: 1 addition & 6 deletions earthly/rust/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,13 @@ This repo defines common rust targets and UDCs for use with rust.

This FUNCTION sets up a rust build environment.

Rust build environments are locked to the `rust-toolchain.toml` file in the repo.
This ensures that the version of the toolchain used is locked with the dependencies.

#### Invocation

In an `Earthfile` in your source repository add:

```Earthfile
example_rust_builder:
FROM +rustup
DO +RUST_SETUP --toolchain=./rust-toolchain.toml
DO +SETUP
```

This builder can then be used to build the projects source.

0 comments on commit 0bca57d

Please sign in to comment.