diff --git a/Dockerfile b/Dockerfile index 25c8af7..39b7e84 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,36 +1,63 @@ -FROM rust:1.95-slim AS base - -WORKDIR /analyzer - +############################# START SHARED LAYERS ############################# + +# IMPORTANT: This part of the build is shared between the test-runner and +# analyzer. It takes a relatively large amount of space: 850 MB for the Rust +# toolchain and 40 MB for the local cargo registry. Therefore, it's important +# to keep this in sync between the two images. A slight mismatch in these layers +# would lead to douple the storage requirement on Exercism's servers. + +FROM rust:1.95.0 AS build-local-registry + +WORKDIR /work +COPY local-registry/Cargo.toml . + +RUN <> $CARGO_HOME/config.toml +EOF + +############################## END SHARED LAYERS ############################## + + +FROM rust:1.95.0 AS build + +WORKDIR /work COPY . . - RUN cargo build --release -# cargo-local-registry stuff is copied from the test runner -FROM rust:1.95 AS build-cargo-local-registry - -# install cargo-local-registry -RUN cargo install --locked cargo-local-registry -# download popular crates to local registry -WORKDIR /local-registry -COPY local-registry/* ./ -RUN cargo generate-lockfile && cargo local-registry --sync Cargo.lock . -FROM rust:1.95-slim - -WORKDIR /opt/analyzer +FROM rust-nightly-with-local-registry RUN rustup component add clippy -COPY ./bin/run.sh ./bin/ -COPY --from=base /analyzer/target/release/rust-analyzer ./bin/rust-analyzer -COPY --from=build-cargo-local-registry /local-registry local-registry/ -# configure local-registry -RUN echo '[source.crates-io]\n\ - registry = "https://github.com/rust-lang/crates.io-index"\n\ - replace-with = "local-registry"\n\ - \n\ - [source.local-registry]\n\ - local-registry = "/opt/analyzer/local-registry/"\n' >> $CARGO_HOME/config.toml - +WORKDIR /opt/analyzer +COPY --from=build /work/target/release/rust-analyzer bin/ +COPY bin/run.sh bin/ ENTRYPOINT ["bin/run.sh"] diff --git a/local-registry/Cargo.toml b/local-registry/Cargo.toml index b133a70..40a3070 100644 --- a/local-registry/Cargo.toml +++ b/local-registry/Cargo.toml @@ -1,19 +1,11 @@ -[package] -name = "dummy_package" -version = "0.1.0" -edition = "2021" - -[lib] -path = "dummy.rs" - # IMPORTANT: These dependencies should be kept in sync with the ones at -# https://github.com/exercism/rust-test-runner/blob/main/local-registry/Cargo.toml +# https://github.com/exercism/rust-analyzer/blob/main/local-registry/Cargo.toml # # Some crates are used by a large number of solutions. For example, when a crate # is required or already included in the exercise skeleton. For those crates, -# we should *never* drop support for a given major version. We can continue to -# support old and new versions by giving the old ones an alias. The downside is -# an increase in the size of the local registry. +# we should NEVER drop support for a given major version. They have been marked +# with a "# pin" comment. We can continue to support old and new versions by +# giving the old ones an alias. An example is the rand_09 crate below. # [dependencies] anyhow = "1.0.102" # pin @@ -119,3 +111,13 @@ unzip-n = "0.1.4" uuid = "1.23.1" voca_rs = "1.15.2" xvii = "0.4.0" + +# The following is only needed so the Cargo.toml defines a valid package. + +[package] +name = "dummy_package" +version = "0.1.0" +edition = "2024" + +[lib] +path = "/dev/null" diff --git a/local-registry/dummy.rs b/local-registry/dummy.rs deleted file mode 100644 index e69de29..0000000 diff --git a/snippets/two_comments/expected_analysis.json b/snippets/two_comments/expected_analysis.json index f63003f..73b3c7a 100644 --- a/snippets/two_comments/expected_analysis.json +++ b/snippets/two_comments/expected_analysis.json @@ -10,7 +10,7 @@ { "comment": "rust.general.clippy", "params": { - "clippy_msg": "warning: unneeded `return` statement\n --> src/lib.rs:2:5\n |\n2 | return --x;\n | ^^^^^^^^^^\n |\n = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.95.0/index.html#needless_return\n = note: `#[warn(clippy::needless_return)]` on by default\nhelp: remove `return`\n |\n2 - return --x;\n2 + --x\n |" + "clippy_msg": "warning: unneeded `return` statement\n --> src/lib.rs:2:5\n |\n2 | return --x;\n | ^^^^^^^^^^\n |\n = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return\n = note: `#[warn(clippy::needless_return)]` on by default\nhelp: remove `return`\n |\n2 - return --x;\n2 + --x\n |" }, "type": "informative" }