From 90fc362547605e00ae1147249e67ce5958b5e3d9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 26 Apr 2026 09:59:49 +0000 Subject: [PATCH 1/8] Add GitHub CI workflow with mlugg/setup-zig and Zig 0.16.0 Agent-Logs-Url: https://github.com/ZigEmbeddedGroup/serial/sessions/22581e77-ff94-4da4-b29a-c06ef3a4f836 Co-authored-by: ikskuh <3932972+ikskuh@users.noreply.github.com> --- .github/workflows/ci.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..0b5f42b --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,23 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: mlugg/setup-zig@v1 + with: + version: "0.16.0" + + - name: Build + run: zig build + + - name: Run tests + run: zig build test From e16bd9074006704c448580a297a595c993c576ff Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 26 Apr 2026 10:03:10 +0000 Subject: [PATCH 2/8] Add zig build examples and zig build docs steps to CI Agent-Logs-Url: https://github.com/ZigEmbeddedGroup/serial/sessions/781c088f-888e-48a1-b55c-f4a909d974dd Co-authored-by: ikskuh <3932972+ikskuh@users.noreply.github.com> --- .github/workflows/ci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0b5f42b..c15a9dc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,3 +21,9 @@ jobs: - name: Run tests run: zig build test + + - name: Build examples + run: zig build examples + + - name: Build docs + run: zig build docs From bccc41ab002d5a34393d15fe746e9360a05e0d2e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 26 Apr 2026 10:56:10 +0000 Subject: [PATCH 3/8] Fix CI workflow branch name from main to master Agent-Logs-Url: https://github.com/ZigEmbeddedGroup/serial/sessions/71a96434-70bb-4602-b08b-d4006916e4f4 Co-authored-by: ikskuh <3932972+ikskuh@users.noreply.github.com> --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c15a9dc..f041b14 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,9 +2,9 @@ name: CI on: push: - branches: [main] + branches: [master] pull_request: - branches: [main] + branches: [master] jobs: build: From 027dabedf2013613179ce6cb476ec447d0a9da5a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 26 Apr 2026 11:11:14 +0000 Subject: [PATCH 4/8] Update mlugg/setup-zig to v2 Agent-Logs-Url: https://github.com/ZigEmbeddedGroup/serial/sessions/baf58f80-d627-4db8-b32b-ab1d8b268c78 Co-authored-by: ikskuh <3932972+ikskuh@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f041b14..d0aa8dc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: mlugg/setup-zig@v1 + - uses: mlugg/setup-zig@v2 with: version: "0.16.0" From d0c1879085ab0d823c5bed6dfc4003ea2db8af3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Quei=C3=9Fner?= Date: Sun, 26 Apr 2026 13:43:17 +0200 Subject: [PATCH 5/8] Refactor serial port handling to use std.testing.io --- src/serial.zig | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/serial.zig b/src/serial.zig index 3277570..67c5c34 100644 --- a/src/serial.zig +++ b/src/serial.zig @@ -1153,7 +1153,7 @@ extern "kernel32" fn GetCommState(hFile: std.os.windows.HANDLE, lpDCB: *DCB) cal extern "kernel32" fn SetCommState(hFile: std.os.windows.HANDLE, lpDCB: *DCB) callconv(.winapi) std.os.windows.BOOL; test "iterate ports" { - var it = try list(); + var it = try list(std.testing.io); while (try it.next()) |port| { _ = port; // std.debug.print("{s} (file: {s}, driver: {s})\n", .{ port.display_name, port.file_name, port.driver }); @@ -1178,10 +1178,8 @@ test "basic configuration test" { else => unreachable, } - var threaded = Io.Threaded.init_single_threaded; - const io = threaded.io(); - var port = try std.Io.Dir.openFileAbsolute(io, tty, .{ .mode = .read_write }); - defer port.close(io); + var port = try std.Io.Dir.openFileAbsolute(std.testing.io, tty, .{ .mode = .read_write }); + defer port.close(std.testing.io); try configureSerialPort(port, cfg); } @@ -1195,10 +1193,8 @@ test "basic flush test" { .macos => tty = "/dev/cu.usbmodem101", else => unreachable, } - var threaded = Io.Threaded.init_single_threaded; - const io = threaded.io(); - var port = try std.Io.Dir.openFileAbsolute(io, tty, .{ .mode = .read_write }); - defer port.close(io); + var port = try std.Io.Dir.openFileAbsolute(std.testing.io, tty, .{ .mode = .read_write }); + defer port.close(std.testing.io); try flushSerialPort(port, .both); try flushSerialPort(port, .input); From 05fbe92bcc6f9c5b122c9b482ac96dea5fddf9c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Quei=C3=9Fner?= Date: Sun, 26 Apr 2026 13:46:12 +0200 Subject: [PATCH 6/8] Reorder CI steps to run tests after building docs --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d0aa8dc..4c59c22 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,11 +19,11 @@ jobs: - name: Build run: zig build - - name: Run tests - run: zig build test - - name: Build examples run: zig build examples - name: Build docs run: zig build docs + + - name: Run tests + run: zig build test From 23620da1ef11df53ab15cb6c1d6ce084e66622fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Quei=C3=9Fner?= Date: Sun, 26 Apr 2026 13:50:24 +0200 Subject: [PATCH 7/8] Add error handling for serial port opening Handle file not found error when opening serial port. --- src/serial.zig | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/serial.zig b/src/serial.zig index 67c5c34..5792b98 100644 --- a/src/serial.zig +++ b/src/serial.zig @@ -1178,7 +1178,10 @@ test "basic configuration test" { else => unreachable, } - var port = try std.Io.Dir.openFileAbsolute(std.testing.io, tty, .{ .mode = .read_write }); + var port = std.Io.Dir.openFileAbsolute(std.testing.io, tty, .{ .mode = .read_write }) catch |err| switch(err) { + error.FileNotFound => return error.ZigSkipTest, + else => |e| return e, + }; defer port.close(std.testing.io); try configureSerialPort(port, cfg); @@ -1193,7 +1196,10 @@ test "basic flush test" { .macos => tty = "/dev/cu.usbmodem101", else => unreachable, } - var port = try std.Io.Dir.openFileAbsolute(std.testing.io, tty, .{ .mode = .read_write }); + var port = std.Io.Dir.openFileAbsolute(std.testing.io, tty, .{ .mode = .read_write }) catch |err| switch(err) { + error.FileNotFound => return error.ZigSkipTest, + else => |e| return e, + }; defer port.close(std.testing.io); try flushSerialPort(port, .both); From 33f337d44523341c36c68969327d4d4e162ab2bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Quei=C3=9Fner?= Date: Sun, 26 Apr 2026 13:53:10 +0200 Subject: [PATCH 8/8] Update error handling for file not found --- src/serial.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/serial.zig b/src/serial.zig index 5792b98..cdd0e89 100644 --- a/src/serial.zig +++ b/src/serial.zig @@ -1179,7 +1179,7 @@ test "basic configuration test" { } var port = std.Io.Dir.openFileAbsolute(std.testing.io, tty, .{ .mode = .read_write }) catch |err| switch(err) { - error.FileNotFound => return error.ZigSkipTest, + error.FileNotFound => return error.SkipZigTest, else => |e| return e, }; defer port.close(std.testing.io); @@ -1197,7 +1197,7 @@ test "basic flush test" { else => unreachable, } var port = std.Io.Dir.openFileAbsolute(std.testing.io, tty, .{ .mode = .read_write }) catch |err| switch(err) { - error.FileNotFound => return error.ZigSkipTest, + error.FileNotFound => return error.SkipZigTest, else => |e| return e, }; defer port.close(std.testing.io);