File tree Expand file tree Collapse file tree 4 files changed +75
-0
lines changed
Expand file tree Collapse file tree 4 files changed +75
-0
lines changed Original file line number Diff line number Diff line change 1+ name : CI 2025 Zig
2+
3+ on :
4+ push :
5+ branches :
6+ - master
7+ - " 2025-zig-*"
8+ paths :
9+ - " 2025/zig/**"
10+
11+ jobs :
12+ test :
13+ runs-on : ubuntu-latest
14+ name : Build and Test
15+ steps :
16+ - uses : actions/checkout@v3
17+
18+ - uses : mlugg/setup-zig@v2
19+ with :
20+ version : 0.15.1
21+
22+ - run : zig build test
23+ working-directory : ./2025/zig
Original file line number Diff line number Diff line change 1+ .zig-cache /
2+
3+ # Created by https://www.toptal.com/developers/gitignore/api/zig
4+ # Edit at https://www.toptal.com/developers/gitignore?templates=zig
5+
6+ # ## zig ###
7+ # Zig programming language
8+
9+ zig-cache /
10+ zig-out /
11+ build /
12+ build- * /
13+ docgen_tmp /
14+
15+ # End of https://www.toptal.com/developers/gitignore/api/zig
Original file line number Diff line number Diff line change 1+ const std = @import ("std" );
2+
3+ pub fn build (b : * std.Build ) void {
4+ const target = b .standardTargetOptions (.{});
5+ const optimize = b .standardOptimizeOption (.{});
6+ const day_filter = b .option (u8 , "day" , "Specific day to test (1-25)" );
7+
8+ const test_step = b .step ("test" , "Run all tests" );
9+
10+ for (1.. 26) | day | {
11+ if (day_filter ) | d | {
12+ if (d != day ) continue ;
13+ }
14+
15+ const path = b .fmt ("src/day{d:0>2}.zig" , .{day });
16+
17+ if (std .fs .cwd ().access (path , .{})) {
18+ const day_tests = b .addTest (.{
19+ .root_module = b .createModule (.{
20+ .root_source_file = b .path (path ),
21+ .target = target ,
22+ .optimize = optimize ,
23+ }),
24+ });
25+ test_step .dependOn (& b .addRunArtifact (day_tests ).step );
26+ } else | _ | {}
27+ }
28+ }
Original file line number Diff line number Diff line change 1+ const std = @import ("std" );
2+
3+ fn part1 () u64 {
4+ return 42 ;
5+ }
6+
7+ test "part 1" {
8+ try std .testing .expectEqual (42 , part1 ());
9+ }
You can’t perform that action at this time.
0 commit comments