diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index 509a889..deea11e 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -23,7 +23,6 @@ jobs: - run: tar x -C /usr/local -f zig-linux-${ARCH}-${ZIG_VERSION}.tar.xz - run: ln -s /usr/local/zig-linux-${ARCH}-${ZIG_VERSION}/zig /usr/local/bin/zig - run: apt update && apt install --no-install-recommends git - - run: (cd codegen && zig build test) - run: zig build test - run: zig build -Dtarget=arm-linux - run: zig build -Dtarget=x86_64-windows diff --git a/build.zig b/build.zig index 57447c9..627dfae 100644 --- a/build.zig +++ b/build.zig @@ -58,6 +58,22 @@ pub fn build(b: *Builder) !void { const run_step = b.step("run", "Run the app"); run_step.dependOn(&run_cmd.step); + // Creates a step for unit testing. This only builds the test executable + // but does not run it. + const unit_tests = b.addTest(.{ + .root_source_file = .{ .path = "src/main.zig" }, + .target = target, + .optimize = optimize, + }); + + const run_unit_tests = b.addRunArtifact(unit_tests); + + // Similar to creating the run step earlier, this exposes a `test` step to + // the `zig build --help` menu, providing a way for the user to request + // running the unit tests. + const test_step = b.step("test", "Run unit tests"); + test_step.dependOn(&run_unit_tests.step); + { const cg = b.step("gen", "Generate zig service code from smithy models"); @@ -101,6 +117,7 @@ pub fn build(b: *Builder) !void { cg.dependOn(&cg_cmd.step); exe.step.dependOn(cg); + unit_tests.step.dependOn(cg); } b.installArtifact(exe);