Skip to content

Commit 2da9dce

Browse files
authored
Make github action for running driver unit tests (ZigEmbeddedGroup#467)
1 parent 8199630 commit 2da9dce

2 files changed

Lines changed: 36 additions & 5 deletions

File tree

.github/workflows/drivers.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: drivers
2+
on:
3+
push:
4+
branches: [main]
5+
pull_request:
6+
branches: [main]
7+
8+
jobs:
9+
test:
10+
name: Unit Test
11+
runs-on: ${{ matrix.os }}
12+
13+
strategy:
14+
matrix:
15+
os: [ubuntu-latest, windows-latest, macos-latest]
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
20+
- name: Setup Zig
21+
uses: mlugg/setup-zig@v1
22+
with:
23+
version: 0.14.0
24+
25+
- name: Run Test Suite
26+
working-directory: drivers
27+
run: zig build test

drivers/build.zig

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
const std = @import("std");
22

33
pub fn build(b: *std.Build) void {
4+
const target = b.standardTargetOptions(.{});
5+
const optimize = b.standardOptimizeOption(.{});
6+
47
const drivers_mod = b.addModule("drivers", .{
58
.root_source_file = b.path("framework.zig"),
9+
.target = target,
10+
.optimize = optimize,
611
});
712

8-
_ = drivers_mod;
9-
1013
const test_suite = b.addTest(.{
11-
.root_source_file = b.path("framework.zig"),
14+
.root_module = drivers_mod,
1215
.target = b.graph.host,
13-
.optimize = .Debug,
1416
});
1517

16-
b.getInstallStep().dependOn(&b.addRunArtifact(test_suite).step);
18+
const run_tests = b.addRunArtifact(test_suite);
19+
const test_step = b.step("test", "Run unit tests");
20+
test_step.dependOn(&run_tests.step);
1721
}

0 commit comments

Comments
 (0)