Skip to content

Commit 3ca3e87

Browse files
committed
nix based CI
1 parent 9329882 commit 3ca3e87

3 files changed

Lines changed: 64 additions & 61 deletions

File tree

.github/workflows/ci.yml

Lines changed: 45 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,21 @@ on:
66
pull_request:
77
branches: [main]
88

9+
# Cancel in-progress runs for the same branch/PR
10+
concurrency:
11+
group: ci-${{ github.ref }}
12+
cancel-in-progress: true
13+
914
jobs:
1015
fmt-check:
1116
name: Format Check
1217
runs-on: ubuntu-latest
1318
steps:
1419
- uses: actions/checkout@v4
15-
- uses: mlugg/setup-zig@v2
16-
with:
17-
version: 0.15.2
20+
- uses: DeterminateSystems/nix-installer-action@main
21+
- uses: DeterminateSystems/magic-nix-cache-action@main
1822
- name: Check formatting
19-
run: zig fmt --check src/ tests/ bench/ build.zig
23+
run: nix develop .#ci --command zig fmt --check src/ tests/ bench/ build.zig
2024

2125
unit-tests:
2226
name: Unit Tests (${{ matrix.os }})
@@ -27,66 +31,53 @@ jobs:
2731
os: [ubuntu-latest, macos-latest]
2832
steps:
2933
- uses: actions/checkout@v4
30-
- uses: mlugg/setup-zig@v2
31-
with:
32-
version: 0.15.2
34+
- uses: DeterminateSystems/nix-installer-action@main
35+
- uses: DeterminateSystems/magic-nix-cache-action@main
3336
- name: Run unit tests
34-
run: zig build test --summary all
37+
run: nix develop .#ci --command zig build test --summary all
3538

3639
smoke-tests:
37-
name: Smoke Tests
38-
runs-on: ubuntu-latest
39-
services:
40-
opensearch:
41-
image: opensearchproject/opensearch:2
42-
ports:
43-
- 9200:9200
44-
env:
45-
discovery.type: single-node
46-
plugins.security.disabled: "true"
47-
OPENSEARCH_INITIAL_ADMIN_PASSWORD: "Admin1234!"
48-
options: >-
49-
--health-cmd "curl -sf http://localhost:9200/_cluster/health || exit 1"
50-
--health-interval 10s
51-
--health-timeout 5s
52-
--health-retries 20
40+
name: Smoke Tests (${{ matrix.os }})
41+
runs-on: ${{ matrix.os }}
42+
strategy:
43+
fail-fast: false
44+
matrix:
45+
os: [ubuntu-latest, macos-latest]
5346
steps:
5447
- uses: actions/checkout@v4
55-
- uses: mlugg/setup-zig@v2
56-
with:
57-
version: 0.15.2
48+
- uses: DeterminateSystems/nix-installer-action@main
49+
- uses: DeterminateSystems/magic-nix-cache-action@main
50+
- name: Start OpenSearch
51+
run: nix develop .#ci --command es-start
5852
- name: Run smoke tests
59-
run: zig build test-smoke --summary all
53+
run: nix develop .#ci --command zig build test-smoke --summary all
6054
env:
6155
ES_URL: http://localhost:9200
56+
- name: Stop OpenSearch
57+
if: always()
58+
run: nix develop .#ci --command es-stop
6259

6360
integration-tests:
64-
name: Integration Tests
65-
runs-on: ubuntu-latest
61+
name: Integration Tests (${{ matrix.os }})
62+
runs-on: ${{ matrix.os }}
6663
needs: [unit-tests]
67-
services:
68-
opensearch:
69-
image: opensearchproject/opensearch:2
70-
ports:
71-
- 9200:9200
72-
env:
73-
discovery.type: single-node
74-
plugins.security.disabled: "true"
75-
OPENSEARCH_INITIAL_ADMIN_PASSWORD: "Admin1234!"
76-
options: >-
77-
--health-cmd "curl -sf http://localhost:9200/_cluster/health || exit 1"
78-
--health-interval 10s
79-
--health-timeout 5s
80-
--health-retries 20
64+
strategy:
65+
fail-fast: false
66+
matrix:
67+
os: [ubuntu-latest, macos-latest]
8168
steps:
8269
- uses: actions/checkout@v4
83-
- uses: mlugg/setup-zig@v2
84-
with:
85-
version: 0.15.2
70+
- uses: DeterminateSystems/nix-installer-action@main
71+
- uses: DeterminateSystems/magic-nix-cache-action@main
72+
- name: Start OpenSearch
73+
run: nix develop .#ci --command es-start
8674
- name: Run integration tests
87-
run: zig build test-integration --summary all
75+
run: nix develop .#ci --command zig build test-integration --summary all
8876
env:
8977
ES_URL: http://localhost:9200
78+
- name: Stop OpenSearch
79+
if: always()
80+
run: nix develop .#ci --command es-stop
9081

9182
build-check:
9283
name: Build Check (${{ matrix.os }})
@@ -97,8 +88,9 @@ jobs:
9788
os: [ubuntu-latest, macos-latest]
9889
steps:
9990
- uses: actions/checkout@v4
100-
- uses: mlugg/setup-zig@v2
101-
with:
102-
version: 0.15.2
103-
- name: Build (ReleaseSafe)
104-
run: zig build -Doptimize=ReleaseSafe
91+
- uses: DeterminateSystems/nix-installer-action@main
92+
- uses: DeterminateSystems/magic-nix-cache-action@main
93+
- name: Nix build (reproducible)
94+
run: nix build
95+
- name: Nix flake check
96+
run: nix flake check

.github/workflows/release.yml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ on:
88
permissions:
99
contents: write
1010

11+
# Cancel in-progress runs for the same tag
12+
concurrency:
13+
group: release-${{ github.ref }}
14+
cancel-in-progress: true
15+
1116
jobs:
1217
build:
1318
name: Build (${{ matrix.target }})
@@ -29,13 +34,14 @@ jobs:
2934
- name: Checkout
3035
uses: actions/checkout@v4
3136

32-
- name: Setup Zig
33-
uses: mlugg/setup-zig@v2
34-
with:
35-
version: 0.15.2
37+
- name: Install Nix
38+
uses: DeterminateSystems/nix-installer-action@main
39+
40+
- name: Nix cache
41+
uses: DeterminateSystems/magic-nix-cache-action@main
3642

3743
- name: Build
38-
run: zig build -Doptimize=ReleaseSafe -Dtarget=${{ matrix.target }}
44+
run: nix develop .#ci --command zig build -Doptimize=ReleaseSafe -Dtarget=${{ matrix.target }}
3945

4046
- name: Create tarball
4147
run: tar -czf elaztic-${{ github.ref_name }}-${{ matrix.target }}.tar.gz -C zig-out/bin elaztic
@@ -47,14 +53,14 @@ jobs:
4753
path: elaztic-${{ github.ref_name }}-${{ matrix.target }}.tar.gz
4854

4955
release:
50-
name: Release
56+
name: Create Release
5157
needs: build
5258
runs-on: ubuntu-latest
5359
permissions:
5460
contents: write
5561

5662
steps:
57-
- name: Download artifacts
63+
- name: Download all artifacts
5864
uses: actions/download-artifact@v4
5965
with:
6066
pattern: elaztic-*

flake.nix

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,12 @@
239239
};
240240

241241
ci = pkgs.mkShell {
242-
buildInputs = [ zigStable ] ++ testHelpers;
242+
buildInputs = [
243+
zigStable
244+
pkgs.opensearch
245+
pkgs.jdk21
246+
]
247+
++ testHelpers;
243248
nativeBuildInputs = with pkgs; [
244249
git
245250
curl

0 commit comments

Comments
 (0)