Skip to content

Add CI and fix test failures on Linux #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: CI

on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:

jobs:
build:
strategy:
fail-fast: false
matrix:
zig-version: ["0.14.0"]
os:
- ubuntu-latest
# - macos-latest # Does not build yet
# - windows-latest # Does not pass tests
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Zig
uses: mlugg/setup-zig@v1
with:
version: ${{ matrix.zig-version }}

- name: Check Formatting
run: zig fmt --ast-check --check .

- name: Build
run: zig build --summary all

- name: Test
run: zig build test --summary all
20 changes: 20 additions & 0 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,26 @@ pub fn build(b: *std.Build) !void {

const test_step = b.step("test", "Run core unit tests (requires python)");
{
// Fix the test fixture file permissions. This is necessary because Zig does
// not respect the execute permission on arbitrary files it extracts from dependencies.
// Since we need those files to have the execute permission set for tests to
// run successfully, we need to patch them before we bake them into the
// test executable. While modifying the global cache is hacky, it wont break
// hashes for the same reason above.
for ([_]std.Build.LazyPath{
libgit_root.path(b, "tests/resources/filemodes/exec_on"),
libgit_root.path(b, "tests/resources/filemodes/exec_off2on_staged"),
libgit_root.path(b, "tests/resources/filemodes/exec_off2on_workdir"),
libgit_root.path(b, "tests/resources/filemodes/exec_on_untracked"),
}) |lazy| {
const path = lazy.getPath2(b, null);
const file = try std.fs.cwd().openFile(path, .{
.mode = .read_write,
});
defer file.close();
try file.setPermissions(.{ .inner = .{ .mode = 0o755 } });
}

const gen_cmd = b.addSystemCommand(&.{"python"});
gen_cmd.addFileArg(libgit_src.path("tests/clar/generate.py"));
const clar_suite = gen_cmd.addPrefixedOutputDirectoryArg("-o", "clar_suite");
Expand Down