Skip to content

Commit 0f1d30e

Browse files
Merge pull request #6 from blurrycat/feat/ci
Add CI and fix test failures on Linux
2 parents ef7eba4 + 302aaee commit 0f1d30e

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

.github/workflows/build.yml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
workflow_dispatch:
11+
12+
jobs:
13+
build:
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
zig-version: ["0.14.0"]
18+
os:
19+
- ubuntu-latest
20+
# - macos-latest # Does not build yet
21+
# - windows-latest # Does not pass tests
22+
runs-on: ${{ matrix.os }}
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
27+
- name: Setup Zig
28+
uses: mlugg/setup-zig@v1
29+
with:
30+
version: ${{ matrix.zig-version }}
31+
32+
- name: Check Formatting
33+
run: zig fmt --ast-check --check .
34+
35+
- name: Build
36+
run: zig build --summary all
37+
38+
- name: Test
39+
run: zig build test --summary all

build.zig

+20
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,26 @@ pub fn build(b: *std.Build) !void {
389389

390390
const test_step = b.step("test", "Run core unit tests (requires python)");
391391
{
392+
// Fix the test fixture file permissions. This is necessary because Zig does
393+
// not respect the execute permission on arbitrary files it extracts from dependencies.
394+
// Since we need those files to have the execute permission set for tests to
395+
// run successfully, we need to patch them before we bake them into the
396+
// test executable. While modifying the global cache is hacky, it wont break
397+
// hashes for the same reason above.
398+
for ([_]std.Build.LazyPath{
399+
libgit_root.path(b, "tests/resources/filemodes/exec_on"),
400+
libgit_root.path(b, "tests/resources/filemodes/exec_off2on_staged"),
401+
libgit_root.path(b, "tests/resources/filemodes/exec_off2on_workdir"),
402+
libgit_root.path(b, "tests/resources/filemodes/exec_on_untracked"),
403+
}) |lazy| {
404+
const path = lazy.getPath2(b, null);
405+
const file = try std.fs.cwd().openFile(path, .{
406+
.mode = .read_write,
407+
});
408+
defer file.close();
409+
try file.setPermissions(.{ .inner = .{ .mode = 0o755 } });
410+
}
411+
392412
const gen_cmd = b.addSystemCommand(&.{"python"});
393413
gen_cmd.addFileArg(libgit_src.path("tests/clar/generate.py"));
394414
const clar_suite = gen_cmd.addPrefixedOutputDirectoryArg("-o", "clar_suite");

0 commit comments

Comments
 (0)