From d6eac772862074f0f88ca4a19ced4292c2b472b7 Mon Sep 17 00:00:00 2001 From: Chris Turner Date: Fri, 7 Mar 2025 14:40:05 -0800 Subject: [PATCH] update to zig 0.14 --- compiled_starters/zig/README.md | 2 +- compiled_starters/zig/build.zig.zon | 18 +++++++++++++-- compiled_starters/zig/codecrafters.yml | 4 ++-- dockerfiles/zig-0.14.Dockerfile | 27 ++++++++++++++++++++++ solutions/zig/01-jm1/code/README.md | 2 +- solutions/zig/01-jm1/code/build.zig.zon | 18 +++++++++++++-- solutions/zig/01-jm1/code/codecrafters.yml | 4 ++-- starter_templates/zig/code/build.zig.zon | 18 +++++++++++++-- starter_templates/zig/config.yml | 2 +- 9 files changed, 82 insertions(+), 13 deletions(-) create mode 100644 dockerfiles/zig-0.14.Dockerfile diff --git a/compiled_starters/zig/README.md b/compiled_starters/zig/README.md index 8a5ac351..6c5607e6 100644 --- a/compiled_starters/zig/README.md +++ b/compiled_starters/zig/README.md @@ -26,7 +26,7 @@ That's all! Note: This section is for stages 2 and beyond. -1. Ensure you have `zig (0.13+)` installed locally +1. Ensure you have `zig (0.14)` installed locally 1. Run `./your_program.sh` to run your Redis server, which is implemented in `src/main.zig`. 1. Commit your changes and run `git push origin master` to submit your solution diff --git a/compiled_starters/zig/build.zig.zon b/compiled_starters/zig/build.zig.zon index 1baccdc7..26cb4b9c 100644 --- a/compiled_starters/zig/build.zig.zon +++ b/compiled_starters/zig/build.zig.zon @@ -1,5 +1,5 @@ .{ - .name = "codecrafters-redis", + .name = .codecrafters_redis, // This is a [Semantic Version](https://semver.org/). // In a future version of Zig it will be used for package deduplication. @@ -8,7 +8,21 @@ // This field is optional. // This is currently advisory only; Zig does not yet do anything // with this value. - //.minimum_zig_version = "0.11.0", + //.minimum_zig_version = "0.14.0", + + // Together with name, this represents a globally unique package + // identifier. This field is generated by the Zig toolchain when the + // package is first created, and then *never changes*. This allows + // unambiguous detection of one package being an updated version of + // another. + // + // When forking a Zig project, this id should be regenerated (delete the + // field and run `zig build`) if the upstream project is still maintained. + // Otherwise, the fork is *hostile*, attempting to take control over the + // original project's identity. Thus it is recommended to leave the comment + // on the following line intact, so that it shows up in code reviews that + // modify the field. + .fingerprint = 0xf806bb9796d9353a, // Changing this has security and trust implications. // This field is optional. // Each dependency must either provide a `url` and `hash`, or a `path`. diff --git a/compiled_starters/zig/codecrafters.yml b/compiled_starters/zig/codecrafters.yml index be2c6fc4..90490e3e 100644 --- a/compiled_starters/zig/codecrafters.yml +++ b/compiled_starters/zig/codecrafters.yml @@ -7,5 +7,5 @@ debug: false # Use this to change the Zig version used to run your code # on Codecrafters. # -# Available versions: zig-0.13 -language_pack: zig-0.13 +# Available versions: zig-0.14 +language_pack: zig-0.14 diff --git a/dockerfiles/zig-0.14.Dockerfile b/dockerfiles/zig-0.14.Dockerfile new file mode 100644 index 00000000..d866e1e1 --- /dev/null +++ b/dockerfiles/zig-0.14.Dockerfile @@ -0,0 +1,27 @@ +# syntax=docker/dockerfile:1.7-labs +FROM alpine:3.20 + +RUN apk add --no-cache 'xz>=5.6' 'curl>=8.9' + +# Download and install Zig +RUN curl -O https://ziglang.org/builds/zig-linux-x86_64-0.14.0.tar.xz \ + && tar -xf zig-linux-x86_64-0.14.0.tar.xz \ + && mv zig-linux-x86_64-0.14.0 /usr/local/zig \ + && rm zig-linux-x86_64-0.14.0.tar.xz + +# Add Zig to PATH +ENV PATH="/usr/local/zig:${PATH}" + +ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="build.zig,build.zig.zon" + +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 zig build +RUN .codecrafters/compile.sh + +# Cache build directory +RUN mkdir -p /app-cached +RUN mv /app/.zig-cache /app-cached/.zig-cache || true diff --git a/solutions/zig/01-jm1/code/README.md b/solutions/zig/01-jm1/code/README.md index 8a5ac351..6c5607e6 100644 --- a/solutions/zig/01-jm1/code/README.md +++ b/solutions/zig/01-jm1/code/README.md @@ -26,7 +26,7 @@ That's all! Note: This section is for stages 2 and beyond. -1. Ensure you have `zig (0.13+)` installed locally +1. Ensure you have `zig (0.14)` installed locally 1. Run `./your_program.sh` to run your Redis server, which is implemented in `src/main.zig`. 1. Commit your changes and run `git push origin master` to submit your solution diff --git a/solutions/zig/01-jm1/code/build.zig.zon b/solutions/zig/01-jm1/code/build.zig.zon index 1baccdc7..26cb4b9c 100644 --- a/solutions/zig/01-jm1/code/build.zig.zon +++ b/solutions/zig/01-jm1/code/build.zig.zon @@ -1,5 +1,5 @@ .{ - .name = "codecrafters-redis", + .name = .codecrafters_redis, // This is a [Semantic Version](https://semver.org/). // In a future version of Zig it will be used for package deduplication. @@ -8,7 +8,21 @@ // This field is optional. // This is currently advisory only; Zig does not yet do anything // with this value. - //.minimum_zig_version = "0.11.0", + //.minimum_zig_version = "0.14.0", + + // Together with name, this represents a globally unique package + // identifier. This field is generated by the Zig toolchain when the + // package is first created, and then *never changes*. This allows + // unambiguous detection of one package being an updated version of + // another. + // + // When forking a Zig project, this id should be regenerated (delete the + // field and run `zig build`) if the upstream project is still maintained. + // Otherwise, the fork is *hostile*, attempting to take control over the + // original project's identity. Thus it is recommended to leave the comment + // on the following line intact, so that it shows up in code reviews that + // modify the field. + .fingerprint = 0xf806bb9796d9353a, // Changing this has security and trust implications. // This field is optional. // Each dependency must either provide a `url` and `hash`, or a `path`. diff --git a/solutions/zig/01-jm1/code/codecrafters.yml b/solutions/zig/01-jm1/code/codecrafters.yml index be2c6fc4..90490e3e 100644 --- a/solutions/zig/01-jm1/code/codecrafters.yml +++ b/solutions/zig/01-jm1/code/codecrafters.yml @@ -7,5 +7,5 @@ debug: false # Use this to change the Zig version used to run your code # on Codecrafters. # -# Available versions: zig-0.13 -language_pack: zig-0.13 +# Available versions: zig-0.14 +language_pack: zig-0.14 diff --git a/starter_templates/zig/code/build.zig.zon b/starter_templates/zig/code/build.zig.zon index 1baccdc7..26cb4b9c 100644 --- a/starter_templates/zig/code/build.zig.zon +++ b/starter_templates/zig/code/build.zig.zon @@ -1,5 +1,5 @@ .{ - .name = "codecrafters-redis", + .name = .codecrafters_redis, // This is a [Semantic Version](https://semver.org/). // In a future version of Zig it will be used for package deduplication. @@ -8,7 +8,21 @@ // This field is optional. // This is currently advisory only; Zig does not yet do anything // with this value. - //.minimum_zig_version = "0.11.0", + //.minimum_zig_version = "0.14.0", + + // Together with name, this represents a globally unique package + // identifier. This field is generated by the Zig toolchain when the + // package is first created, and then *never changes*. This allows + // unambiguous detection of one package being an updated version of + // another. + // + // When forking a Zig project, this id should be regenerated (delete the + // field and run `zig build`) if the upstream project is still maintained. + // Otherwise, the fork is *hostile*, attempting to take control over the + // original project's identity. Thus it is recommended to leave the comment + // on the following line intact, so that it shows up in code reviews that + // modify the field. + .fingerprint = 0xf806bb9796d9353a, // Changing this has security and trust implications. // This field is optional. // Each dependency must either provide a `url` and `hash`, or a `path`. diff --git a/starter_templates/zig/config.yml b/starter_templates/zig/config.yml index 36066dfb..a113b983 100644 --- a/starter_templates/zig/config.yml +++ b/starter_templates/zig/config.yml @@ -1,3 +1,3 @@ attributes: - required_executable: zig (0.13+) + required_executable: zig (0.14) user_editable_file: src/main.zig