Skip to content

Commit

Permalink
fix CI: ignore certain examples when appropriate
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack-Ji committed Nov 17, 2024
1 parent 7da246d commit b4e223a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- name: Build and run tests
run: zig build test
- name: Build examples
run: zig build examples
run: zig build -Dskipexamples=particle_life,intersection_2d examples

build-macos:
runs-on: macos-latest
Expand Down Expand Up @@ -170,7 +170,7 @@ jobs:
}
write-mode: overwrite
- name: Build examples
run: zig build -Dtarget=x86_64-windows-gnu examples
run: zig build -Dtarget=x86_64-windows-gnu -Dskipexamples=particle_life examples

build-cross-linux:
strategy:
Expand All @@ -192,4 +192,4 @@ jobs:
with:
version: ${{ steps.zigversion.outputs.content }}
- name: Build examples
run: zig build -Dtarget=${{matrix.target}} examples
run: zig build -Dtarget=${{matrix.target}} -Dskipexamples=particle_life examples
19 changes: 16 additions & 3 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ pub fn build(b: *Build) void {
if (skip) return;
}

// Get skipped examples' names
var skipexamples = std.StringHashMap(bool).init(b.allocator);
if (b.option(
[]const u8,
"skipexamples",
"skip given examples when building all. e.g. \"particle_life,intersection_2d\"",
)) |s| {
var it = std.mem.splitScalar(u8, s, ',');
while (it.next()) |name| skipexamples.put(name, true) catch unreachable;
}

const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});

Expand All @@ -25,7 +36,7 @@ pub fn build(b: *Build) void {
.install_dir = .bin,
.install_subdir = "assets",
});
const examples = [_]struct { name: []const u8, opt: BuildOptions, add_example: bool = true }{
const examples = [_]struct { name: []const u8, opt: BuildOptions }{
.{ .name = "hello", .opt = .{ .dep_name = null } },
.{ .name = "imgui_demo", .opt = .{ .dep_name = null } },
.{ .name = "sprite_benchmark", .opt = .{ .dep_name = null } },
Expand All @@ -42,7 +53,7 @@ pub fn build(b: *Build) void {
.{ .name = "solar_system", .opt = .{ .dep_name = null } },
.{ .name = "font_demo", .opt = .{ .dep_name = null } },
.{ .name = "skybox", .opt = .{ .dep_name = null } },
.{ .name = "particle_life", .opt = .{ .dep_name = null, .use_nfd = true }, .add_example = false },
.{ .name = "particle_life", .opt = .{ .dep_name = null, .use_nfd = true } },
.{ .name = "audio_demo", .opt = .{ .dep_name = null } },
.{ .name = "easing", .opt = .{ .dep_name = null } },
.{ .name = "svg", .opt = .{ .dep_name = null } },
Expand Down Expand Up @@ -79,7 +90,9 @@ pub fn build(b: *Build) void {
"compile & run example " ++ demo.name,
);
run_step.dependOn(&run_cmd.step);
if (demo.add_example) build_examples.dependOn(&install_cmd.step);
if (skipexamples.get(demo.name) == null) {
build_examples.dependOn(&install_cmd.step);
}
}
}

Expand Down

0 comments on commit b4e223a

Please sign in to comment.