Skip to content

Commit

Permalink
Merge pull request #48 from kivikakk/nix-in-ci
Browse files Browse the repository at this point in the history
workflows: use Nix in CI.
  • Loading branch information
charlottia authored Aug 28, 2023
2 parents ce3d36f + 16a1152 commit 2fa2ba2
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 27 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: recursive
- uses: goto-bus-stop/setup-zig@v1
with:
version: 0.11.0
- run: make spec
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v4
- name: Run the Magic Nix Cache
uses: DeterminateSystems/magic-nix-cache-action@v2
- run: nix build '.?submodules=1#specs' -L
38 changes: 15 additions & 23 deletions .github/workflows/zig.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,20 @@ on:
pull_request:

jobs:
test-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- uses: goto-bus-stop/setup-zig@v1
with:
version: 0.11.0
- run: zig build
- run: zig build test
test-macos:
runs-on: macos-latest
test-nix:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- uses: goto-bus-stop/setup-zig@v1
with:
version: 0.11.0
- run: brew install pcre
- run: zig build
- run: zig build test
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v4
- name: Run the Magic Nix Cache
uses: DeterminateSystems/magic-nix-cache-action@v2
- run: nix build '.?submodules=1' -L
test-windows:
runs-on: windows-latest
steps:
Expand All @@ -48,7 +39,8 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: recursive
- uses: goto-bus-stop/setup-zig@v1
with:
version: 0.11.0
- run: zig fmt --check src/*.zig
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v4
- name: Run the Magic Nix Cache
uses: DeterminateSystems/magic-nix-cache-action@v2
- run: nix develop --command zig fmt --check src/*.zig
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/zig-*
koino.code-workspace
/result*
58 changes: 58 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
outputs = {
self,
nixpkgs,
flake-utils,
...
}:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = nixpkgs.legacyPackages.${system};
inherit (pkgs) lib;
in rec {
packages.default = pkgs.stdenv.mkDerivation {
name = "koino-build";

src = ./.;

nativeBuildInputs = [pkgs.zig pkgs.pcre pkgs.python311];

buildPhase = ''
export ZIG_GLOBAL_CACHE_DIR="$TMPDIR/zig"
zig build test
touch $out
'';

dontInstall = true;
};

packages.specs = packages.default.overrideAttrs {
buildPhase = ''
export ZIG_GLOBAL_CACHE_DIR="$TMPDIR/zig"
make spec
touch $out
'';
};

formatter = pkgs.alejandra;
});
}

0 comments on commit 2fa2ba2

Please sign in to comment.