Skip to content

Commit 90d19a8

Browse files
authored
Upgrade to Zig version 0.16.0 (#2)
1 parent 8e44fc9 commit 90d19a8

20 files changed

Lines changed: 191 additions & 111 deletions

.editorconfig

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,12 @@ indent_size = 4
1010
insert_final_newline = true
1111
trim_trailing_whitespace = true
1212

13-
[*.zig]
13+
[*.{zig,py}]
1414
max_line_length = 100
1515

1616
[*.md]
17-
max_line_length = 120
17+
max_line_length = 150
1818
trim_trailing_whitespace = false
1919

2020
[*.{yml,yaml}]
2121
indent_size = 2
22-
23-
[*.sh]
24-
indent_size = 2
25-
26-
[*.py]
27-
max_line_length = 100

.github/workflows/docs.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Publish API Documentation
1+
name: Publish API documentation
22

33
on:
44
workflow_dispatch:
@@ -17,23 +17,23 @@ jobs:
1717
deploy-docs:
1818
runs-on: ubuntu-latest
1919
steps:
20-
- name: Checkout Repository
20+
- name: Checkout repository
2121
uses: actions/checkout@v4
2222

23-
- name: Install Zig
24-
uses: goto-bus-stop/setup-zig@v2
25-
with:
26-
version: '0.15.2'
23+
- name: Install Zig 0.16.0
24+
run: |
25+
curl -sSfL https://ziglang.org/download/0.16.0/zig-x86_64-linux-0.16.0.tar.xz | tar -xJ
26+
echo "$PWD/zig-x86_64-linux-0.16.0" >> "$GITHUB_PATH"
2727
28-
- name: Install System Dependencies
28+
- name: Install dependencies
2929
run: |
3030
sudo apt-get update
3131
sudo apt-get install -y make
3232
33-
- name: Generate Documentation
33+
- name: Generate documentation
3434
run: make docs
3535

36-
- name: Deploy to GitHub Pages
36+
- name: Deploy to GitHub pages
3737
uses: peaceiris/actions-gh-pages@v4
3838
with:
3939
github_token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/lints.yml

Lines changed: 0 additions & 38 deletions
This file was deleted.

.github/workflows/tests.yml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
name: Run Tests
1+
name: Run tests
22

33
on:
44
workflow_dispatch:
55
workflow_call:
66
push:
7+
branches:
8+
- develop
79
tags:
810
- 'v*'
911
pull_request:
@@ -22,18 +24,18 @@ jobs:
2224
runs-on: ubuntu-latest
2325

2426
steps:
25-
- name: Checkout Repository
27+
- name: Checkout repository
2628
uses: actions/checkout@v4
2729

28-
- name: Install Zig
29-
uses: goto-bus-stop/setup-zig@v2
30-
with:
31-
version: '0.15.2'
30+
- name: Install Zig 0.16.0
31+
run: |
32+
curl -sSfL https://ziglang.org/download/0.16.0/zig-x86_64-linux-0.16.0.tar.xz | tar -xJ
33+
echo "$PWD/zig-x86_64-linux-0.16.0" >> "$GITHUB_PATH"
3234
33-
- name: Install Dependencies
35+
- name: Install dependencies
3436
run: |
3537
sudo apt-get update
3638
sudo apt-get install -y make
3739
38-
- name: Run Tests
40+
- name: Run tests
3941
run: make test

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# ################################################################################
22
# # Configuration
33
# ################################################################################
4-
ZIG ?= $(shell which zig || echo ~/.local/share/zig/0.15.2/zig)
4+
ZIG_LOCAL := $(HOME)/.local/share/zig/0.16.0/zig
5+
ZIG ?= $(shell test -x $(ZIG_LOCAL) && echo $(ZIG_LOCAL) || which zig)
56
BUILD_TYPE ?= Debug
67
BUILD_OPTS ?= -Doptimize=$(BUILD_TYPE)
78
JOBS ?= $(shell nproc || echo 2)
@@ -10,7 +11,7 @@ JOBS ?= $(shell nproc || echo 2)
1011
check_zig = \
1112
if [ ! -x "$(ZIG)" ]; then \
1213
echo "ERROR: Zig compiler not found at '$(ZIG)'."; \
13-
echo " Install Zig 0.15.2 and/or set ZIG=/path/to/zig."; \
14+
echo " Install Zig 0.16.0 and/or set ZIG=/path/to/zig."; \
1415
echo " See: https://ziglang.org/download/"; \
1516
exit 1; \
1617
fi

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
[![License](https://img.shields.io/badge/license-Apache--2.0-007ec6?label=license&style=flat&labelColor=282c34&logo=open-source-initiative)](https://github.com/CogitatorTech/minish/blob/main/LICENSE)
1111
[![Examples](https://img.shields.io/badge/examples-view-green?style=flat&labelColor=282c34&logo=zig)](https://github.com/CogitatorTech/minish/tree/main/examples)
1212
[![Docs](https://img.shields.io/badge/docs-read-blue?style=flat&labelColor=282c34&logo=read-the-docs)](https://CogitatorTech.github.io/minish/)
13-
[![Zig Version](https://img.shields.io/badge/Zig-0.15.2-orange?logo=zig&labelColor=282c34)](https://ziglang.org/download/)
13+
[![Zig Version](https://img.shields.io/badge/Zig-0.16.0-orange?logo=zig&labelColor=282c34)](https://ziglang.org/download/)
1414
[![Release](https://img.shields.io/github/release/CogitatorTech/minish.svg?label=release&style=flat&labelColor=282c34&logo=github)](https://github.com/CogitatorTech/minish/releases/latest)
1515

1616
A property-based testing framework for Zig
@@ -87,7 +87,7 @@ Replace `<branch_or_tag>` with the desired branch or release tag, like `main` (f
8787
This command will download Minish and add it to Zig's global cache and update your project's `build.zig.zon` file.
8888

8989
> [!NOTE]
90-
> Minsih is developed and tested with Zig version 0.15.2.
90+
> Minish is developed and tested with Zig version 0.16.0.
9191
9292
#### Adding to Build Script
9393

@@ -123,7 +123,7 @@ fn reverse(allocator: std.mem.Allocator, s: []const u8) ![]u8 {
123123
124124
// Property: reversing a string twice returns the original
125125
fn reverse_twice_is_identity(s: []const u8) !void {
126-
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
126+
var gpa: std.heap.DebugAllocator(.{}) = .init;
127127
defer _ = gpa.deinit();
128128
const allocator = gpa.allocator();
129129
@@ -137,7 +137,7 @@ fn reverse_twice_is_identity(s: []const u8) !void {
137137
}
138138
139139
pub fn main() !void {
140-
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
140+
var gpa: std.heap.DebugAllocator(.{}) = .init;
141141
defer _ = gpa.deinit();
142142
const allocator = gpa.allocator();
143143

build.zig

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@ pub fn build(b: *std.Build) void {
1212
});
1313

1414
// Unit tests
15-
const tests = b.addExecutable(.{
16-
.name = "minish-tests",
17-
.root_module = minish_mod,
15+
const test_mod = b.createModule(.{
16+
.root_source_file = b.path("src/lib.zig"),
17+
.target = target,
18+
.optimize = optimize,
19+
});
20+
const tests = b.addTest(.{
21+
.root_module = test_mod,
1822
});
19-
tests.kind = .@"test";
2023

2124
const run_tests = b.addRunArtifact(tests);
2225
b.step("test", "Run unit tests").dependOn(&run_tests.step);
@@ -25,8 +28,7 @@ pub fn build(b: *std.Build) void {
2528
const docs_step = b.step("docs", "Generate API documentation");
2629
const doc_path = "docs/api";
2730

28-
// Create docs directory if it doesn't exist
29-
std.fs.cwd().makePath("docs") catch {};
31+
const io = b.graph.io;
3032

3133
const gen_docs_cmd = b.addSystemCommand(&[_][]const u8{
3234
b.graph.zig_exe,
@@ -38,12 +40,13 @@ pub fn build(b: *std.Build) void {
3840
docs_step.dependOn(&gen_docs_cmd.step);
3941

4042
// Examples (only when developing minish itself, not when used as a dependency)
41-
if (std.fs.cwd().openDir("examples", .{ .iterate = true })) |examples_dir| {
43+
if (b.build_root.handle.openDir(io, "examples", .{ .iterate = true })) |examples_dir| {
4244
var dir = examples_dir;
45+
defer dir.close(io);
4346
const run_all_step = b.step("run-all", "Run all examples");
4447

4548
var it = dir.iterate();
46-
while (it.next() catch null) |entry| {
49+
while (it.next(io) catch null) |entry| {
4750
if (entry.kind != .file) continue;
4851
if (!std.mem.endsWith(u8, entry.name, ".zig")) continue;
4952

build.zig.zon

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
.{
22
.name = .minish,
3-
.version = "0.1.0",
3+
.version = "0.2.0",
44
.fingerprint = 0x4a0e1bdb4d520b49, // Changing this has security and trust implications.
5-
.minimum_zig_version = "0.15.2",
6-
.dependencies = .{ .chilli = .{
7-
.url = "https://github.com/CogitatorTech/chilli/archive/v0.2.2.tar.gz",
8-
.hash = "chilli-0.2.2-c19PrvIyAQAgsL0VkYCKq0DuxU7rZUpRuH991zsyOkYQ",
9-
} },
5+
.minimum_zig_version = "0.16.0",
106
.paths = .{ "build.zig", "build.zig.zon", "src", "LICENSE", "README.md" },
117
}

examples/README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22

33
#### List of Examples
44

5-
| # | File | Description |
6-
|---|----------------------------------------------------------------|-----------------------------------|
7-
| 1 | [e1_simple_example.zig](e1_simple_example.zig) | Basic tuple generator |
8-
| 2 | [e2_string_example.zig](e2_string_example.zig) | String property testing |
9-
| 3 | [e3_list_example.zig](e3_list_example.zig) | List property testing (sorting) |
10-
| 4 | [e4_advanced_generators.zig](e4_advanced_generators.zig) | Multiple generator types |
11-
| 5 | [e5_struct_and_combinators.zig](e5_struct_and_combinators.zig) | Struct generation and combinators |
12-
| 6 | [e6_shrinking_demo.zig](e6_shrinking_demo.zig) | Shrinking demonstration |
13-
| 7 | [e7_hashmap_example.zig](e7_hashmap_example.zig) | HashMap property testing |
5+
| # | File | Description |
6+
|---|----------------------------------------------------------------|--------------------------------------------------------|
7+
| 1 | [e1_simple_example.zig](e1_simple_example.zig) | Basic tuple generator |
8+
| 2 | [e2_string_example.zig](e2_string_example.zig) | String property testing |
9+
| 3 | [e3_list_example.zig](e3_list_example.zig) | List property testing (sorting) |
10+
| 4 | [e4_advanced_generators.zig](e4_advanced_generators.zig) | Multiple generator types |
11+
| 5 | [e5_struct_and_combinators.zig](e5_struct_and_combinators.zig) | Struct generation and combinators |
12+
| 6 | [e6_shrinking_demo.zig](e6_shrinking_demo.zig) | Shrinking demonstration |
13+
| 7 | [e7_hashmap_example.zig](e7_hashmap_example.zig) | HashMap property testing |
14+
| 8 | [e8_misc_features.zig](e8_misc_features.zig) | Show cases for oneOf, dependent, timestamps, and enums |
1415

1516
#### Running Examples
1617

examples/e1_simple_example.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ fn sum_is_less_than_1500(tuple: struct { i32, i32 }) !void {
1717
}
1818

1919
pub fn main() !void {
20-
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
20+
var gpa: std.heap.DebugAllocator(.{}) = .init;
2121
defer _ = gpa.deinit();
2222
const allocator = gpa.allocator();
2323

0 commit comments

Comments
 (0)