Skip to content

Commit e4b9e6c

Browse files
committed
fix flake and add caching.
1 parent db31a55 commit e4b9e6c

3 files changed

Lines changed: 76 additions & 42 deletions

File tree

.github/workflows/ci.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ jobs:
3333
- uses: actions/checkout@v4
3434
- uses: DeterminateSystems/nix-installer-action@main
3535
- uses: DeterminateSystems/magic-nix-cache-action@main
36+
- name: Cache Zig build artifacts
37+
uses: actions/cache@v4
38+
with:
39+
path: |
40+
.zig-cache
41+
~/.cache/zig
42+
key: zig-unit-${{ matrix.os }}-${{ hashFiles('build.zig', 'build.zig.zon', 'src/**') }}
43+
restore-keys: |
44+
zig-unit-${{ matrix.os }}-
3645
- name: Run unit tests
3746
run: nix develop .#ci --command zig build test --summary all
3847

@@ -47,6 +56,15 @@ jobs:
4756
- uses: actions/checkout@v4
4857
- uses: DeterminateSystems/nix-installer-action@main
4958
- uses: DeterminateSystems/magic-nix-cache-action@main
59+
- name: Cache Zig build artifacts
60+
uses: actions/cache@v4
61+
with:
62+
path: |
63+
.zig-cache
64+
~/.cache/zig
65+
key: zig-smoke-${{ matrix.os }}-${{ hashFiles('build.zig', 'build.zig.zon', 'src/**') }}
66+
restore-keys: |
67+
zig-smoke-${{ matrix.os }}-
5068
- name: Start OpenSearch
5169
run: nix develop .#ci --command es-start
5270
- name: Run smoke tests
@@ -69,6 +87,15 @@ jobs:
6987
- uses: actions/checkout@v4
7088
- uses: DeterminateSystems/nix-installer-action@main
7189
- uses: DeterminateSystems/magic-nix-cache-action@main
90+
- name: Cache Zig build artifacts
91+
uses: actions/cache@v4
92+
with:
93+
path: |
94+
.zig-cache
95+
~/.cache/zig
96+
key: zig-integration-${{ matrix.os }}-${{ hashFiles('build.zig', 'build.zig.zon', 'src/**', 'tests/**') }}
97+
restore-keys: |
98+
zig-integration-${{ matrix.os }}-
7299
- name: Start OpenSearch
73100
run: nix develop .#ci --command es-start
74101
- name: Run integration tests

.github/workflows/release.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,16 @@ jobs:
4040
- name: Nix cache
4141
uses: DeterminateSystems/magic-nix-cache-action@main
4242

43+
- name: Cache Zig build artifacts
44+
uses: actions/cache@v4
45+
with:
46+
path: |
47+
.zig-cache
48+
~/.cache/zig
49+
key: zig-release-${{ matrix.target }}-${{ hashFiles('build.zig', 'build.zig.zon', 'src/**') }}
50+
restore-keys: |
51+
zig-release-${{ matrix.target }}-
52+
4353
- name: Build
4454
run: nix develop .#ci --command zig build -Doptimize=ReleaseSafe -Dtarget=${{ matrix.target }}
4555

flake.nix

Lines changed: 39 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,15 @@
77
zig.url = "github:mitchellh/zig-overlay";
88
};
99

10-
outputs =
11-
{
12-
self,
13-
nixpkgs,
14-
flake-utils,
15-
zig,
16-
...
17-
}:
10+
outputs = {
11+
self,
12+
nixpkgs,
13+
flake-utils,
14+
zig,
15+
...
16+
}:
1817
flake-utils.lib.eachDefaultSystem (
19-
system:
20-
let
18+
system: let
2119
pkgs = nixpkgs.legacyPackages.${system};
2220
zigpkgs = zig.packages.${system};
2321

@@ -129,25 +127,23 @@
129127
];
130128

131129
# Common build inputs
132-
buildInputs = [ ];
130+
buildInputs = [];
133131

134-
nativeBuildInputs =
135-
with pkgs;
136-
[ pkg-config ]
132+
nativeBuildInputs = with pkgs;
133+
[pkg-config]
137134
++ pkgs.lib.optionals pkgs.stdenv.isLinux [
138135
gdb
139136
valgrind
140137
]
141-
++ pkgs.lib.optionals pkgs.stdenv.isDarwin [ lldb ];
138+
++ pkgs.lib.optionals pkgs.stdenv.isDarwin [lldb];
142139

143140
# Library derivation
144-
elaztic =
145-
zigCompiler:
141+
elaztic = zigCompiler:
146142
pkgs.stdenv.mkDerivation {
147143
pname = "elaztic";
148144
version = "0.0.0";
149145
src = ./.;
150-
nativeBuildInputs = [ zigCompiler ] ++ nativeBuildInputs;
146+
nativeBuildInputs = [zigCompiler] ++ nativeBuildInputs;
151147
inherit buildInputs;
152148
buildPhase = ''
153149
export HOME=$TMPDIR
@@ -165,19 +161,18 @@
165161
platforms = platforms.all;
166162
};
167163
};
168-
169-
in
170-
{
164+
in {
171165
# Dev shells
172166
devShells = {
173167
default = pkgs.mkShell {
174-
buildInputs = [
175-
zigStable
176-
pkgs.opensearch
177-
pkgs.jdk21
178-
]
179-
++ buildInputs
180-
++ testHelpers;
168+
buildInputs =
169+
[
170+
zigStable
171+
pkgs.opensearch
172+
pkgs.jdk21
173+
]
174+
++ buildInputs
175+
++ testHelpers;
181176
nativeBuildInputs =
182177
nativeBuildInputs
183178
++ (with pkgs; [
@@ -214,13 +209,14 @@
214209
};
215210

216211
nightly = pkgs.mkShell {
217-
buildInputs = [
218-
zigMaster
219-
pkgs.opensearch
220-
pkgs.jdk21
221-
]
222-
++ buildInputs
223-
++ testHelpers;
212+
buildInputs =
213+
[
214+
zigMaster
215+
pkgs.opensearch
216+
pkgs.jdk21
217+
]
218+
++ buildInputs
219+
++ testHelpers;
224220
nativeBuildInputs =
225221
nativeBuildInputs
226222
++ (with pkgs; [
@@ -239,12 +235,13 @@
239235
};
240236

241237
ci = pkgs.mkShell {
242-
buildInputs = [
243-
zigStable
244-
pkgs.opensearch
245-
pkgs.jdk21
246-
]
247-
++ testHelpers;
238+
buildInputs =
239+
[
240+
zigStable
241+
pkgs.opensearch
242+
pkgs.jdk21
243+
]
244+
++ testHelpers;
248245
nativeBuildInputs = with pkgs; [
249246
git
250247
curl
@@ -280,7 +277,7 @@
280277

281278
checks = {
282279
build = self.packages.${system}.default;
283-
format = pkgs.runCommand "format-check" { nativeBuildInputs = [ pkgs.alejandra ]; } ''
280+
format = pkgs.runCommand "format-check" {nativeBuildInputs = [pkgs.alejandra];} ''
284281
alejandra --check ${./.}
285282
touch $out
286283
'';

0 commit comments

Comments
 (0)