Skip to content

Commit 4c4caab

Browse files
authored
Merge pull request ZigEmbeddedGroup#57 from ZigEmbeddedGroup/copilot/add-github-ci-setup-zig
Add GitHub CI with mlugg/setup-zig and Zig 0.16.0
2 parents b368b2e + 33f337d commit 4c4caab

2 files changed

Lines changed: 40 additions & 9 deletions

File tree

.github/workflows/ci.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: [master]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- uses: mlugg/setup-zig@v2
16+
with:
17+
version: "0.16.0"
18+
19+
- name: Build
20+
run: zig build
21+
22+
- name: Build examples
23+
run: zig build examples
24+
25+
- name: Build docs
26+
run: zig build docs
27+
28+
- name: Run tests
29+
run: zig build test

src/serial.zig

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,7 +1153,7 @@ extern "kernel32" fn GetCommState(hFile: std.os.windows.HANDLE, lpDCB: *DCB) cal
11531153
extern "kernel32" fn SetCommState(hFile: std.os.windows.HANDLE, lpDCB: *DCB) callconv(.winapi) std.os.windows.BOOL;
11541154

11551155
test "iterate ports" {
1156-
var it = try list();
1156+
var it = try list(std.testing.io);
11571157
while (try it.next()) |port| {
11581158
_ = port;
11591159
// std.debug.print("{s} (file: {s}, driver: {s})\n", .{ port.display_name, port.file_name, port.driver });
@@ -1178,10 +1178,11 @@ test "basic configuration test" {
11781178
else => unreachable,
11791179
}
11801180

1181-
var threaded = Io.Threaded.init_single_threaded;
1182-
const io = threaded.io();
1183-
var port = try std.Io.Dir.openFileAbsolute(io, tty, .{ .mode = .read_write });
1184-
defer port.close(io);
1181+
var port = std.Io.Dir.openFileAbsolute(std.testing.io, tty, .{ .mode = .read_write }) catch |err| switch(err) {
1182+
error.FileNotFound => return error.SkipZigTest,
1183+
else => |e| return e,
1184+
};
1185+
defer port.close(std.testing.io);
11851186

11861187
try configureSerialPort(port, cfg);
11871188
}
@@ -1195,10 +1196,11 @@ test "basic flush test" {
11951196
.macos => tty = "/dev/cu.usbmodem101",
11961197
else => unreachable,
11971198
}
1198-
var threaded = Io.Threaded.init_single_threaded;
1199-
const io = threaded.io();
1200-
var port = try std.Io.Dir.openFileAbsolute(io, tty, .{ .mode = .read_write });
1201-
defer port.close(io);
1199+
var port = std.Io.Dir.openFileAbsolute(std.testing.io, tty, .{ .mode = .read_write }) catch |err| switch(err) {
1200+
error.FileNotFound => return error.SkipZigTest,
1201+
else => |e| return e,
1202+
};
1203+
defer port.close(std.testing.io);
12021204

12031205
try flushSerialPort(port, .both);
12041206
try flushSerialPort(port, .input);

0 commit comments

Comments
 (0)