diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index e55c60c..769affa 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -7,11 +7,16 @@ on: - 'v*' permissions: - contents: write + contents: read + pages: write + id-token: write jobs: deploy-docs: runs-on: ubuntu-latest + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} steps: - name: Checkout repository uses: actions/checkout@v4 @@ -19,7 +24,7 @@ jobs: - name: Install Zig uses: goto-bus-stop/setup-zig@v2 with: - version: '0.16.0' + version: '0.17.0' - name: Install system dependencies run: | @@ -29,12 +34,14 @@ jobs: - name: Generate documentation run: make docs - - name: Deploy to GitHub Pages - uses: peaceiris/actions-gh-pages@v4 + - name: Configure GitHub Pages + uses: actions/configure-pages@v5 + + - name: Upload GitHub Pages artifact + uses: actions/upload-pages-artifact@v3 with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./docs/api - publish_branch: gh-pages - user_name: 'github-actions[bot]' - user_email: 'github-actions[bot]@users.noreply.github.com' - commit_message: "docs: Deploy documentation from ${{ github.sha }}" + path: ./docs/api + + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 05ee6e2..47dd06c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,4 +1,4 @@ -name: Run tests +name: Run Tests on: workflow_dispatch: @@ -27,26 +27,26 @@ jobs: matrix: include: - os: ubuntu-latest - zig-url: https://ziglang.org/download/0.16.0/zig-x86_64-linux-0.16.0.tar.xz - zig-dir: zig-x86_64-linux-0.16.0 + zig-url: https://ziglang.org/download/0.17.0/zig-x86_64-linux-0.17.0.tar.xz + zig-dir: zig-x86_64-linux-0.17.0 - os: macos-latest - zig-url: https://ziglang.org/download/0.16.0/zig-aarch64-macos-0.16.0.tar.xz - zig-dir: zig-aarch64-macos-0.16.0 + zig-url: https://ziglang.org/download/0.17.0/zig-aarch64-macos-0.17.0.tar.xz + zig-dir: zig-aarch64-macos-0.17.0 - os: windows-latest - zig-url: https://ziglang.org/download/0.16.0/zig-x86_64-windows-0.16.0.zip - zig-dir: zig-x86_64-windows-0.16.0 + zig-url: https://ziglang.org/download/0.17.0/zig-x86_64-windows-0.17.0.zip + zig-dir: zig-x86_64-windows-0.17.0 steps: - name: Checkout repository uses: actions/checkout@v4 - - name: Install Zig 0.16.0 (Unix) + - name: Install Zig 0.17.0 (Unix) if: runner.os != 'Windows' run: | curl -sSfL ${{ matrix.zig-url }} | tar -xJ echo "$PWD/${{ matrix.zig-dir }}" >> "$GITHUB_PATH" - - name: Install Zig 0.16.0 (Windows) + - name: Install Zig 0.17.0 (Windows) if: runner.os == 'Windows' shell: pwsh run: | diff --git a/AGENTS.md b/AGENTS.md index a7fa334..46b9137 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -89,7 +89,7 @@ Please do not add dependencies without prior discussion. ## Zig Conventions -- Zig version: 0.16.0 (as declared in `build.zig.zon` and the Makefile's `ZIG_LOCAL` path). +- Zig version: 0.17.0 (as declared in `build.zig.zon` and the Makefile's `ZIG_LOCAL` path). - Formatting is enforced by `zig fmt`. Run `make format` before committing. - Naming follows Zig standard-library conventions: `camelCase` for functions (e.g. `addFlag`, `getFlag`, `parseBool`), `snake_case` for local variables and struct fields, `PascalCase` for types and structs, and `SCREAMING_SNAKE_CASE` for top-level compile-time constants. diff --git a/Makefile b/Makefile index fdfce62..b6e5677 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ # ################################################################################ # # Configuration and Variables # ################################################################################ -ZIG_LOCAL := $(HOME)/.local/share/zig/0.16.0/zig +ZIG_LOCAL := $(HOME)/.local/share/zig/0.17.0/zig ZIG ?= $(shell test -x $(ZIG_LOCAL) && echo $(ZIG_LOCAL) || which zig) BUILD_TYPE ?= Debug BUILD_OPTS = -Doptimize=$(BUILD_TYPE) diff --git a/README.md b/README.md index 151f910..a09e675 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@

Chilli

[![Tests](https://img.shields.io/github/actions/workflow/status/CogitatorTech/chilli/tests.yml?label=tests&style=flat&labelColor=282c34&logo=github)](https://github.com/CogitatorTech/chilli/actions/workflows/tests.yml) -[![Zig](https://img.shields.io/badge/zig-0.16.0-F7A41D?style=flat&labelColor=282c34&logo=zig)](https://ziglang.org/download/) +[![Zig](https://img.shields.io/badge/zig-0.17.0-F7A41D?style=flat&labelColor=282c34&logo=zig)](https://ziglang.org/download/) [![Docs](https://img.shields.io/badge/docs-read-blue?style=flat&labelColor=282c34&logo=read-the-docs)](https://CogitatorTech.github.io/chilli) [![Examples](https://img.shields.io/badge/examples-view-green?style=flat&labelColor=282c34&logo=zig)](https://github.com/CogitatorTech/chilli/tree/main/examples) [![Release](https://img.shields.io/github/release/CogitatorTech/chilli.svg?label=release&style=flat&labelColor=282c34&logo=github)](https://github.com/CogitatorTech/chilli/releases/latest) @@ -62,10 +62,11 @@ Zig version supported by the main releases of Chilli: | Zig | Chilli Tags | |----------|-------------| +| `0.17.0` | `v0.4.x` | | `0.16.0` | `v0.3.x` | | `0.15.x` | `v0.2.x` | -The `main` branch normally is developed and build using the latest (non-developmental) Zig release. +The `main` branch normally is developed and built using the latest (non-developmental) Zig release. #### Adding to Build Script diff --git a/build.zig b/build.zig index 756b13f..a850893 100644 --- a/build.zig +++ b/build.zig @@ -29,22 +29,12 @@ pub fn build(b: *std.Build) void { // --- Docs Setup --- const docs_step = b.step("docs", "Generate API documentation"); - const doc_install_path = "docs/api"; - - // Zig's `-femit-docs=` writes the leaf dir but does not create - // intermediate parents, and git does not track empty directories, so a - // fresh checkout may have no `docs/` at all. Create it portably here - // (idempotent: createDirPath is a no-op when the directory already exists). - const ensure_docs_dir = EnsureDirStep.create(b, "docs"); - const gen_docs_cmd = b.addSystemCommand(&[_][]const u8{ - b.graph.zig_exe, // Use the same zig that is running the build - "build-lib", - "src/lib.zig", - "-femit-docs=" ++ doc_install_path, + const install_docs = b.addInstallDirectory(.{ + .source_dir = lib.getEmittedDocs(), + .install_dir = .{ .custom = "../docs" }, + .install_subdir = "api", }); - gen_docs_cmd.step.dependOn(&ensure_docs_dir.step); - - docs_step.dependOn(&gen_docs_cmd.step); + docs_step.dependOn(&install_docs.step); // --- Test Setup --- const test_module = b.createModule(.{ @@ -67,11 +57,15 @@ pub fn build(b: *std.Build) void { examples_blk: { // If the examples directory isn't present (common when used as a dependency), // skip setting up example artifacts instead of panicking. - var examples_dir = b.build_root.handle.openDir(io, examples_path, .{ .iterate = true }) catch |err| { - if (err == error.FileNotFound or err == error.NotDir) break :examples_blk; + var examples_dir = b.root.openDir(io, examples_path, .{ .iterate = true }) catch |err| { + if (err == error.FileNotFound or err == error.NotDir) { + b.graph.poisonCache(); + break :examples_blk; + } @panic("Can't open 'examples' directory"); }; defer examples_dir.close(io); + b.dependOnDirectoryContents(b.path(examples_path)); var dir_iter = examples_dir.iterate(); while (dir_iter.next(io) catch @panic("Failed to iterate examples")) |entry| { @@ -101,32 +95,3 @@ pub fn build(b: *std.Build) void { } } } - -/// Build step that ensures a directory (relative to the build root) exists. -/// Runs `std.fs.Dir.createDirPath` at make-time, so it only fires when a -/// step that depends on it is actually being built. Portable across Linux, -/// macOS, and Windows. -const EnsureDirStep = struct { - step: std.Build.Step, - sub_path: []const u8, - - fn create(b: *std.Build, sub_path: []const u8) *EnsureDirStep { - const self = b.allocator.create(EnsureDirStep) catch @panic("OOM"); - self.* = .{ - .step = std.Build.Step.init(.{ - .id = .custom, - .name = b.fmt("ensure {s}/", .{sub_path}), - .owner = b, - .makeFn = make, - }), - .sub_path = sub_path, - }; - return self; - } - - fn make(step: *std.Build.Step, options: std.Build.Step.MakeOptions) anyerror!void { - _ = options; - const self: *EnsureDirStep = @fieldParentPtr("step", step); - try step.owner.build_root.handle.createDirPath(step.owner.graph.io, self.sub_path); - } -}; diff --git a/build.zig.zon b/build.zig.zon index 86eb23d..4c73c6d 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,8 +1,8 @@ .{ .name = .chilli, - .version = "0.3.2", + .version = "0.4.0", .fingerprint = 0x6c259741ae4f5f73, // Changing this has security and trust implications. - .minimum_zig_version = "0.16.0", + .minimum_zig_version = "0.17.0", .paths = .{ "build.zig", "build.zig.zon", diff --git a/examples/e6_file_downloader.zig b/examples/e6_file_downloader.zig index afac6f5..36d5581 100644 --- a/examples/e6_file_downloader.zig +++ b/examples/e6_file_downloader.zig @@ -41,7 +41,7 @@ fn downloadExec(ctx: chilli.CommandContext) !void { var response = try req.receiveHead(&redirect_buf); if (response.head.status != .ok) { - std.debug.print("Error: HTTP {d} - {s}\n", .{ @intFromEnum(response.head.status), @tagName(response.head.status) }); + std.debug.print("Error: HTTP {d} - {s}\n", .{ @backingInt(response.head.status), @tagName(response.head.status) }); return error.HttpRequestFailed; }