From bd7b473a19e8c9f9ec169e808853c4077c7a07ac Mon Sep 17 00:00:00 2001 From: Hanaasagi Date: Thu, 5 Dec 2024 21:30:15 +0800 Subject: [PATCH] chore: compact zig 0.13.0 (#4) Close https://github.com/Hanaasagi/struct-env/issues/3 --- .github/workflows/ci.yaml | 14 ++++-------- .gitignore | 1 + README.md | 47 +-------------------------------------- build.zig | 4 ++-- build.zig.zon | 2 +- 5 files changed, 9 insertions(+), 59 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d998db9..fe40703 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -5,8 +5,6 @@ on: branches: ["master"] pull_request: branches: ["master"] - schedule: - - cron: "0 0 * * 0" workflow_dispatch: jobs: @@ -16,14 +14,10 @@ jobs: steps: - uses: actions/checkout@v3 - uses: goto-bus-stop/setup-zig@v2 - # - uses: Hanaasagi/zig-action-cache@v1.1.1 - # with: - # cache-on-failure: false + with: + version: 0.13.0 - run: zig version - run: zig env - - run: ls - - run: ls zig-cache || echo 'no zig-cache' - - run: rm -rf zig-cache/o/*/test - name: Build run: zig build --verbose - name: Run Tests @@ -31,9 +25,9 @@ jobs: - name: Install kcov run: sudo apt-get install -y kcov - name: Generate coverage - run: kcov $PWD/kcov-out ./zig-cache/o/*/test + run: kcov $PWD/kcov-out ./.zig-cache/o/*/test - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v5 with: token: ${{ secrets.CODECOV_TOKEN }} directory: ./kcov-out/test diff --git a/.gitignore b/.gitignore index f53a20d..84d32f7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ **/zig-out/ **/zig-cache/ **/kcov-out/ +.zig-cache/ diff --git a/README.md b/README.md index 20d3cea..9acf56f 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![codecov](https://codecov.io/gh/Hanaasagi/struct-env/branch/master/graph/badge.svg?token=DQQZETSCW3)](https://codecov.io/gh/Hanaasagi/struct-env) ![](https://img.shields.io/badge/language-zig-%23ec915c) -**NOTE: Minimum Supported Zig Version is 0.12.0-dev.2058+04ac028a2** +**NOTE: Supported Zig Version is 0.13.0** ## What is `struct-env` @@ -88,51 +88,6 @@ defer struct_env.free(allocator, env); - Optional types, such as `?u32` - Slice types, such as `[][]const u8` -## Installation - -Add `struct-env` as dependency in `build.zig.zon`: - -``` -.{ - .name = "my-project", - .version = "0.1.0", - .dependencies = .{ - .struct_env= .{ - .url = "https://github.com/Hanaasagi/struct-env/archive/refs/tags/v0.2.0.tar.gz", - .hash = "1220224c50ca0178c6061fb96721fc331ed1136641ebb8a86cff55cc74481d66a4b9", - }, - }, -} -``` - -Expose `struct-env` as a module in `build.zig`: - -```diff -diff --git a/build.zig b/build.zig -index 60fb4c2..0255ef3 100644 ---- a/build.zig -+++ b/build.zig -@@ -15,6 +15,9 @@ pub fn build(b: *std.Build) void { - // set a preferred release mode, allowing the user to decide how to optimize. - const optimize = b.standardOptimizeOption(.{}); - -+ const opts = .{ .target = target, .optimize = optimize }; -+ const struct_env_module = b.dependency("struct_env", opts).module("struct-env"); -+ - const exe = b.addExecutable(.{ - .name = "m", - // In this case the main source file is merely a path, however, in more -@@ -23,6 +26,7 @@ pub fn build(b: *std.Build) void { - .target = target, - .optimize = optimize, - }); -+ exe.addModule("struct-env", struct_env_module); - - // This declares intent for the executable to be installed into the - // standard location when the user invokes the "install" step (the default - -``` - ## License MIT diff --git a/build.zig b/build.zig index 2ab0e74..0d830fe 100644 --- a/build.zig +++ b/build.zig @@ -20,7 +20,7 @@ pub fn build(b: *std.Build) void { _ = dep_opts; _ = b.addModule("struct-env", .{ - .root_source_file = .{ .path = "src/lib.zig" }, + .root_source_file = b.path("src/lib.zig"), .imports = &.{}, }); @@ -44,7 +44,7 @@ pub fn build(b: *std.Build) void { // Creates a step for unit testing. This only builds the test executable // but does not run it. const lib_tests = b.addTest(.{ - .root_source_file = .{ .path = "src/lib.zig" }, + .root_source_file = b.path("src/lib.zig"), .target = target, .optimize = optimize, }); diff --git a/build.zig.zon b/build.zig.zon index f82fc51..0774224 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,6 +1,6 @@ .{ .name = "struct-env", - .version = "0.1.0", + .version = "0.1.1", .dependencies = .{}, .paths = .{""}, }