From 0b4ee7ab5d4cef4c109b356335d259efd5923b6c Mon Sep 17 00:00:00 2001 From: Paul Kuruvilla Date: Thu, 22 Aug 2024 20:01:10 +0100 Subject: [PATCH 1/2] Upgrade Rust --- dockerfiles/rust-1.80.Dockerfile | 13 +++++++++++++ .../rust/code/.codecrafters/compile.sh | 2 +- .../rust/code/.codecrafters/run.sh | 4 +--- starter_templates/rust/code/Cargo.lock | 2 +- starter_templates/rust/code/Cargo.toml | 17 ++--------------- starter_templates/rust/config.yml | 4 ++-- 6 files changed, 20 insertions(+), 22 deletions(-) create mode 100644 dockerfiles/rust-1.80.Dockerfile diff --git a/dockerfiles/rust-1.80.Dockerfile b/dockerfiles/rust-1.80.Dockerfile new file mode 100644 index 0000000..5839222 --- /dev/null +++ b/dockerfiles/rust-1.80.Dockerfile @@ -0,0 +1,13 @@ +# syntax=docker/dockerfile:1.7-labs +FROM rust:1.80-bookworm + +# Rebuild the container if these files change +ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="Cargo.toml,Cargo.lock" + +WORKDIR /app + +# .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses +COPY --exclude=.git --exclude=README.md . /app + +# This runs cargo build +RUN .codecrafters/compile.sh diff --git a/starter_templates/rust/code/.codecrafters/compile.sh b/starter_templates/rust/code/.codecrafters/compile.sh index 2bac4e7..e0f590d 100755 --- a/starter_templates/rust/code/.codecrafters/compile.sh +++ b/starter_templates/rust/code/.codecrafters/compile.sh @@ -8,4 +8,4 @@ set -e # Exit on failure -cargo build --release --target-dir=/tmp/codecrafters-grep-target --manifest-path Cargo.toml +cargo build --release --target-dir=/tmp/codecrafters-build-grep-rust --manifest-path Cargo.toml diff --git a/starter_templates/rust/code/.codecrafters/run.sh b/starter_templates/rust/code/.codecrafters/run.sh index b56170f..4010fd3 100755 --- a/starter_templates/rust/code/.codecrafters/run.sh +++ b/starter_templates/rust/code/.codecrafters/run.sh @@ -6,6 +6,4 @@ # # Learn more: https://codecrafters.io/program-interface -set -e # Exit on failure - -exec /tmp/codecrafters-grep-target/release/grep-starter-rust "$@" \ No newline at end of file +exec /tmp/codecrafters-build-grep-rust/release/codecrafters-grep "$@" diff --git a/starter_templates/rust/code/Cargo.lock b/starter_templates/rust/code/Cargo.lock index 99196a8..3a1237f 100644 --- a/starter_templates/rust/code/Cargo.lock +++ b/starter_templates/rust/code/Cargo.lock @@ -15,7 +15,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dfb24e866b15a1af2a1b663f10c6b6b8f397a84aadb828f12e5b289ec23a3a3c" [[package]] -name = "grep-starter-rust" +name = "codecrafters-grep" version = "0.1.0" dependencies = [ "anyhow", diff --git a/starter_templates/rust/code/Cargo.toml b/starter_templates/rust/code/Cargo.toml index aef0127..0015efa 100644 --- a/starter_templates/rust/code/Cargo.toml +++ b/starter_templates/rust/code/Cargo.toml @@ -1,23 +1,10 @@ -# DON'T EDIT THIS! -# -# Codecrafters relies on this file being intact to run tests successfully. Any changes -# here will not reflect when CodeCrafters tests your code, and might even cause build -# failures. -# -# DON'T EDIT THIS! [package] -name = "grep-starter-rust" +name = "codecrafters-grep" version = "0.1.0" authors = ["Codecrafters "] edition = "2021" +rust-version = "1.80" -# DON'T EDIT THIS! -# -# Codecrafters relies on this file being intact to run tests successfully. Any changes -# here will not reflect when CodeCrafters tests your code, and might even cause build -# failures. -# -# DON'T EDIT THIS! [dependencies] anyhow = "1.0.68" # error handling bytes = "1.3.0" # helps manage buffers diff --git a/starter_templates/rust/config.yml b/starter_templates/rust/config.yml index c19c080..1c6c697 100644 --- a/starter_templates/rust/config.yml +++ b/starter_templates/rust/config.yml @@ -1,3 +1,3 @@ attributes: - required_executable: cargo (1.62) - user_editable_file: src/main.rs + required_executable: cargo (1.80) + user_editable_file: src/main.rs \ No newline at end of file From a869ecb33892eb4e8a9f6107af575f3cc67ce656 Mon Sep 17 00:00:00 2001 From: Paul Kuruvilla Date: Thu, 22 Aug 2024 20:02:53 +0100 Subject: [PATCH 2/2] Upgrade Rust --- compiled_starters/rust/.codecrafters/compile.sh | 2 +- compiled_starters/rust/.codecrafters/run.sh | 4 +--- compiled_starters/rust/Cargo.lock | 2 +- compiled_starters/rust/Cargo.toml | 17 ++--------------- compiled_starters/rust/README.md | 2 +- compiled_starters/rust/codecrafters.yml | 4 ++-- compiled_starters/rust/your_program.sh | 4 ++-- .../rust/01-cq2/code/.codecrafters/compile.sh | 2 +- solutions/rust/01-cq2/code/.codecrafters/run.sh | 4 +--- solutions/rust/01-cq2/code/Cargo.lock | 2 +- solutions/rust/01-cq2/code/Cargo.toml | 17 ++--------------- solutions/rust/01-cq2/code/README.md | 2 +- solutions/rust/01-cq2/code/codecrafters.yml | 4 ++-- solutions/rust/01-cq2/code/your_program.sh | 4 ++-- 14 files changed, 20 insertions(+), 50 deletions(-) diff --git a/compiled_starters/rust/.codecrafters/compile.sh b/compiled_starters/rust/.codecrafters/compile.sh index 2bac4e7..e0f590d 100755 --- a/compiled_starters/rust/.codecrafters/compile.sh +++ b/compiled_starters/rust/.codecrafters/compile.sh @@ -8,4 +8,4 @@ set -e # Exit on failure -cargo build --release --target-dir=/tmp/codecrafters-grep-target --manifest-path Cargo.toml +cargo build --release --target-dir=/tmp/codecrafters-build-grep-rust --manifest-path Cargo.toml diff --git a/compiled_starters/rust/.codecrafters/run.sh b/compiled_starters/rust/.codecrafters/run.sh index b56170f..4010fd3 100755 --- a/compiled_starters/rust/.codecrafters/run.sh +++ b/compiled_starters/rust/.codecrafters/run.sh @@ -6,6 +6,4 @@ # # Learn more: https://codecrafters.io/program-interface -set -e # Exit on failure - -exec /tmp/codecrafters-grep-target/release/grep-starter-rust "$@" \ No newline at end of file +exec /tmp/codecrafters-build-grep-rust/release/codecrafters-grep "$@" diff --git a/compiled_starters/rust/Cargo.lock b/compiled_starters/rust/Cargo.lock index 99196a8..3a1237f 100644 --- a/compiled_starters/rust/Cargo.lock +++ b/compiled_starters/rust/Cargo.lock @@ -15,7 +15,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dfb24e866b15a1af2a1b663f10c6b6b8f397a84aadb828f12e5b289ec23a3a3c" [[package]] -name = "grep-starter-rust" +name = "codecrafters-grep" version = "0.1.0" dependencies = [ "anyhow", diff --git a/compiled_starters/rust/Cargo.toml b/compiled_starters/rust/Cargo.toml index aef0127..0015efa 100644 --- a/compiled_starters/rust/Cargo.toml +++ b/compiled_starters/rust/Cargo.toml @@ -1,23 +1,10 @@ -# DON'T EDIT THIS! -# -# Codecrafters relies on this file being intact to run tests successfully. Any changes -# here will not reflect when CodeCrafters tests your code, and might even cause build -# failures. -# -# DON'T EDIT THIS! [package] -name = "grep-starter-rust" +name = "codecrafters-grep" version = "0.1.0" authors = ["Codecrafters "] edition = "2021" +rust-version = "1.80" -# DON'T EDIT THIS! -# -# Codecrafters relies on this file being intact to run tests successfully. Any changes -# here will not reflect when CodeCrafters tests your code, and might even cause build -# failures. -# -# DON'T EDIT THIS! [dependencies] anyhow = "1.0.68" # error handling bytes = "1.3.0" # helps manage buffers diff --git a/compiled_starters/rust/README.md b/compiled_starters/rust/README.md index 3646f69..f8990b6 100644 --- a/compiled_starters/rust/README.md +++ b/compiled_starters/rust/README.md @@ -32,7 +32,7 @@ Time to move on to the next stage! Note: This section is for stages 2 and beyond. -1. Ensure you have `cargo (1.62)` installed locally +1. Ensure you have `cargo (1.80)` installed locally 1. Run `./your_program.sh` to run your program, which is implemented in `src/main.rs`. This command compiles your Rust project, so it might be slow the first time you run it. Subsequent runs will be fast. diff --git a/compiled_starters/rust/codecrafters.yml b/compiled_starters/rust/codecrafters.yml index 92afff5..ee00289 100644 --- a/compiled_starters/rust/codecrafters.yml +++ b/compiled_starters/rust/codecrafters.yml @@ -7,5 +7,5 @@ debug: false # Use this to change the Rust version used to run your code # on Codecrafters. # -# Available versions: rust-1.77 -language_pack: rust-1.77 +# Available versions: rust-1.80 +language_pack: rust-1.80 diff --git a/compiled_starters/rust/your_program.sh b/compiled_starters/rust/your_program.sh index 1c6d73e..1112e2d 100755 --- a/compiled_starters/rust/your_program.sh +++ b/compiled_starters/rust/your_program.sh @@ -14,11 +14,11 @@ set -e # Exit early if any commands fail # - Edit .codecrafters/compile.sh to change how your program compiles remotely ( cd "$(dirname "$0")" # Ensure compile steps are run within the repository directory - cargo build --release --target-dir=/tmp/codecrafters-grep-target --manifest-path Cargo.toml + cargo build --release --target-dir=/tmp/codecrafters-build-grep-rust --manifest-path Cargo.toml ) # Copied from .codecrafters/run.sh # # - Edit this to change how your program runs locally # - Edit .codecrafters/run.sh to change how your program runs remotely -exec /tmp/codecrafters-grep-target/release/grep-starter-rust "$@" +exec /tmp/codecrafters-build-grep-rust/release/codecrafters-grep "$@" diff --git a/solutions/rust/01-cq2/code/.codecrafters/compile.sh b/solutions/rust/01-cq2/code/.codecrafters/compile.sh index 2bac4e7..e0f590d 100755 --- a/solutions/rust/01-cq2/code/.codecrafters/compile.sh +++ b/solutions/rust/01-cq2/code/.codecrafters/compile.sh @@ -8,4 +8,4 @@ set -e # Exit on failure -cargo build --release --target-dir=/tmp/codecrafters-grep-target --manifest-path Cargo.toml +cargo build --release --target-dir=/tmp/codecrafters-build-grep-rust --manifest-path Cargo.toml diff --git a/solutions/rust/01-cq2/code/.codecrafters/run.sh b/solutions/rust/01-cq2/code/.codecrafters/run.sh index b56170f..4010fd3 100755 --- a/solutions/rust/01-cq2/code/.codecrafters/run.sh +++ b/solutions/rust/01-cq2/code/.codecrafters/run.sh @@ -6,6 +6,4 @@ # # Learn more: https://codecrafters.io/program-interface -set -e # Exit on failure - -exec /tmp/codecrafters-grep-target/release/grep-starter-rust "$@" \ No newline at end of file +exec /tmp/codecrafters-build-grep-rust/release/codecrafters-grep "$@" diff --git a/solutions/rust/01-cq2/code/Cargo.lock b/solutions/rust/01-cq2/code/Cargo.lock index 99196a8..3a1237f 100644 --- a/solutions/rust/01-cq2/code/Cargo.lock +++ b/solutions/rust/01-cq2/code/Cargo.lock @@ -15,7 +15,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dfb24e866b15a1af2a1b663f10c6b6b8f397a84aadb828f12e5b289ec23a3a3c" [[package]] -name = "grep-starter-rust" +name = "codecrafters-grep" version = "0.1.0" dependencies = [ "anyhow", diff --git a/solutions/rust/01-cq2/code/Cargo.toml b/solutions/rust/01-cq2/code/Cargo.toml index aef0127..0015efa 100644 --- a/solutions/rust/01-cq2/code/Cargo.toml +++ b/solutions/rust/01-cq2/code/Cargo.toml @@ -1,23 +1,10 @@ -# DON'T EDIT THIS! -# -# Codecrafters relies on this file being intact to run tests successfully. Any changes -# here will not reflect when CodeCrafters tests your code, and might even cause build -# failures. -# -# DON'T EDIT THIS! [package] -name = "grep-starter-rust" +name = "codecrafters-grep" version = "0.1.0" authors = ["Codecrafters "] edition = "2021" +rust-version = "1.80" -# DON'T EDIT THIS! -# -# Codecrafters relies on this file being intact to run tests successfully. Any changes -# here will not reflect when CodeCrafters tests your code, and might even cause build -# failures. -# -# DON'T EDIT THIS! [dependencies] anyhow = "1.0.68" # error handling bytes = "1.3.0" # helps manage buffers diff --git a/solutions/rust/01-cq2/code/README.md b/solutions/rust/01-cq2/code/README.md index 3646f69..f8990b6 100644 --- a/solutions/rust/01-cq2/code/README.md +++ b/solutions/rust/01-cq2/code/README.md @@ -32,7 +32,7 @@ Time to move on to the next stage! Note: This section is for stages 2 and beyond. -1. Ensure you have `cargo (1.62)` installed locally +1. Ensure you have `cargo (1.80)` installed locally 1. Run `./your_program.sh` to run your program, which is implemented in `src/main.rs`. This command compiles your Rust project, so it might be slow the first time you run it. Subsequent runs will be fast. diff --git a/solutions/rust/01-cq2/code/codecrafters.yml b/solutions/rust/01-cq2/code/codecrafters.yml index 92afff5..ee00289 100644 --- a/solutions/rust/01-cq2/code/codecrafters.yml +++ b/solutions/rust/01-cq2/code/codecrafters.yml @@ -7,5 +7,5 @@ debug: false # Use this to change the Rust version used to run your code # on Codecrafters. # -# Available versions: rust-1.77 -language_pack: rust-1.77 +# Available versions: rust-1.80 +language_pack: rust-1.80 diff --git a/solutions/rust/01-cq2/code/your_program.sh b/solutions/rust/01-cq2/code/your_program.sh index 1c6d73e..1112e2d 100755 --- a/solutions/rust/01-cq2/code/your_program.sh +++ b/solutions/rust/01-cq2/code/your_program.sh @@ -14,11 +14,11 @@ set -e # Exit early if any commands fail # - Edit .codecrafters/compile.sh to change how your program compiles remotely ( cd "$(dirname "$0")" # Ensure compile steps are run within the repository directory - cargo build --release --target-dir=/tmp/codecrafters-grep-target --manifest-path Cargo.toml + cargo build --release --target-dir=/tmp/codecrafters-build-grep-rust --manifest-path Cargo.toml ) # Copied from .codecrafters/run.sh # # - Edit this to change how your program runs locally # - Edit .codecrafters/run.sh to change how your program runs remotely -exec /tmp/codecrafters-grep-target/release/grep-starter-rust "$@" +exec /tmp/codecrafters-build-grep-rust/release/codecrafters-grep "$@"