Compare commits

...

2 Commits

Author SHA1 Message Date
cbb6116a61
add test step
Some checks failed
AWS-Zig Build / build-zig-0.11.0-amd64-host (push) Failing after 2m49s
2023-08-14 22:45:46 -07:00
b603822679
make codegen releasesafe 2023-08-14 22:41:09 -07:00
2 changed files with 18 additions and 2 deletions

View File

@ -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

View File

@ -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");
@ -66,7 +82,7 @@ pub fn build(b: *Builder) !void {
.root_source_file = .{ .path = "codegen/src/main.zig" },
// We need this generated for the host, not the real target
// .target = target,
// .optimize = optimize,
.optimize = .ReleaseSafe,
});
cg_exe.addModule("smithy", smithy_dep.module("smithy"));
var cg_cmd = b.addRunArtifact(cg_exe);
@ -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);