-
Notifications
You must be signed in to change notification settings - Fork 3
242 lines (236 loc) · 9.21 KB
/
Copy pathci.yaml
File metadata and controls
242 lines (236 loc) · 9.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
# SPDX-License-Identifier: MIT
on:
pull_request:
push:
branches:
- '*'
- '!cidev'
tags:
- 'v*'
workflow_dispatch:
env:
REPO_USERNAME: ${{ github.actor }}
REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}
permissions:
contents: write
packages: write
actions: write
jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@main
- name: Setup Nix environment
uses: ./.github/actions/setup-nix
with:
nixbuild_key: ${{ secrets.NIXBUILD_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
cache_key: check
- name: Run type checker
run: nix-shell --run "pyright pkgs/nixkube/src"
- name: Check formatting
run: |
nix run --file . treefmt
git diff --exit-code
build-amd64:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@main
- name: Setup Nix environment
uses: ./.github/actions/setup-nix
with:
nixbuild_key: ${{ secrets.NIXBUILD_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
cache_key: build-amd64
- name: Build and push environments
run: |
unlink nix-envs || true
nix build --show-trace --file . push --out-link nix-envs
./nix-envs/bin/push
- name: Build and push amd64 nix image
run: |
unlink nix-nix || true
nix build --show-trace --file . nixImage.pushArch.x86_64-linux --out-link nix-nix
./nix-nix/bin/push-nix-x86_64-linux
build-arm64:
runs-on: ubuntu-24.04-arm
steps:
- name: Checkout
uses: actions/checkout@main
- name: Setup Nix environment
uses: ./.github/actions/setup-nix
with:
nixbuild_key: ${{ secrets.NIXBUILD_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
cache_key: build-arm64
- name: Build and push environments
run: |
unlink nix-envs || true
nix build --show-trace --file . push --out-link nix-envs
./nix-envs/bin/push
- name: Build and push arm64 nix image
run: |
unlink nix-nix || true
nix build --show-trace --file . nixImage.pushArch.aarch64-linux --out-link nix-nix
./nix-nix/bin/push-nix-aarch64-linux
build-manifests:
needs: [build-amd64, build-arm64]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@main
- name: Setup Nix environment
uses: ./.github/actions/setup-nix
with:
nixbuild_key: ${{ secrets.NIXBUILD_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
cache_key: build-manifests
- name: Create nix multi-arch manifest
run: |
unlink nix-manifest || true
nix build --show-trace --file . nixImage.pushManifest --out-link nix-manifest
./nix-manifest/bin/push-nix-manifest
- name: Build and push scratch image
run: |
unlink nix-scratches || true
nix build --show-trace --file . scratchImage.push --out-link nix-scratches
./nix-scratches/bin/push
test-kind-cache:
needs: build-manifests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@main
- name: Setup Nix environment
uses: ./.github/actions/setup-nix
with:
nixbuild_key: ${{ secrets.NIXBUILD_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
cache_key: test-kind-cache
- name: Create Kind cluster
uses: helm/kind-action@main
- name: Clean runner
run: |
# Remove cache because permissions can get fucked up preventing kluctl from creating it's cache directory
sudo rm --recursive --force /home/runner/.cache
- name: Deploy nix-csi
run: |
nix build --show-trace --file . kubenixCI1.deploymentScript
./result/bin/kubenixDeploy --yes
- name: Wait for nix-csi node daemonset
run: |
kubectl rollout status daemonset -l app.kubernetes.io/component=node -n nixkube --timeout=180s
- name: Wait for nix-csi cache pod
run: |
kubectl wait --for=condition=ready pod -l app.kubernetes.io/component=pynixd -n nixkube --timeout=180s
- name: Wait for test workload
run: |
kubectl wait --for=condition=complete job/flake-hello job/expr-hello job/path-hello job/nri-hello-ro job/nri-hello-rw -n nixkube --timeout=300s
- name: Validate success events
run: |
echo "=== Checking NixVolumeMount events ==="
EVENTS=$(kubectl get events -n nixkube -o json)
MOUNT_EVENTS=$(echo "$EVENTS" | jq '[.items[] |
select(.reason == "NixVolumeMount" and .type == "Normal")] | length')
echo "Found $MOUNT_EVENTS successful NixVolumeMount events"
# Show event details: pod name and message with timing
echo "$EVENTS" | jq -r '.items[] |
select(.reason == "NixVolumeMount" and .type == "Normal") |
" - \(.involvedObject.name): \(.message)"'
if [ "$MOUNT_EVENTS" -lt 3 ]; then
echo "ERROR: Expected at least 3 mount events, found $MOUNT_EVENTS"
exit 1
fi
- name: Delete jobs and verify CSI cleanup
run: |
kubectl delete job flake-hello expr-hello path-hello invalid-storepath-hello invalid-flake-hello invalid-expr-hello nri-hello-ro nri-hello-rw -n nixkube
kubectl wait --for=delete pod -l "job-name in (flake-hello,expr-hello,path-hello,invalid-storepath-hello,invalid-flake-hello,invalid-expr-hello,nri-hello-ro,nri-hello-rw)" -n nixkube --timeout=120s
- name: Validate error events
run: |
echo "=== Checking error events ==="
EVENTS=$(kubectl get events -n nixkube -o json)
# Check for the three expected error reasons (with Nix prefix)
for reason in "NixPathBuild" "NixFlakeBuild" "NixExprBuild"; do
count=$(echo "$EVENTS" | jq --arg r "$reason" '[.items[] |
select(.reason == $r and .type == "Warning")] | length')
echo "Found $count '$reason' error event(s)"
# Show details of the errors
echo "$EVENTS" | jq --arg r "$reason" -r '.items[] |
select(.reason == $r and .type == "Warning") |
" - \(.involvedObject.name): \(.message)"' || true
done
- name: Print node logs
run: |
echo "=== Node pod logs ==="
kubectl logs -l app.kubernetes.io/component=node -n nixkube --tail=50 --timestamps
- name: Debug on failure
if: failure()
env:
DS_API: ${{ secrets.DS_API }}
run: nix run --file . ci-debug || true
test-kind-nocache:
needs: build-manifests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@main
- name: Setup Nix environment
uses: ./.github/actions/setup-nix
with:
nixbuild_key: ${{ secrets.NIXBUILD_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
cache_key: test-kind-nocache
- name: Create Kind cluster
uses: helm/kind-action@main
- name: Clean runner
run: |
sudo rm --recursive --force /home/runner/.cache
- name: Deploy nix-csi
run: |
nix build --show-trace --file . kubenixCI2.deploymentScript
./result/bin/kubenixDeploy --yes
- name: Wait for nix-csi node daemonset
run: |
kubectl rollout status daemonset -l app.kubernetes.io/component=node -n nixkube --timeout=180s
- name: Wait for test workload
run: |
kubectl wait --for=condition=complete job/flake-hello job/expr-hello job/path-hello job/nri-hello-ro job/nri-hello-rw -n nixkube --timeout=300s
- name: Delete jobs and verify CSI cleanup
run: |
kubectl delete job flake-hello expr-hello path-hello nri-hello-ro nri-hello-rw -n nixkube
kubectl wait --for=delete pod -l "job-name in (flake-hello,expr-hello,path-hello,nri-hello-ro,nri-hello-rw)" -n nixkube --timeout=120s
- name: Print node logs
run: |
echo "=== Node pod logs ==="
kubectl logs -l app.kubernetes.io/component=node -n nixkube --tail=50 --timestamps
- name: Debug on failure
if: failure()
env:
DS_API: ${{ secrets.DS_API }}
run: nix run --file . ci-debug || true
release:
needs: [check, build-manifests, test-kind-cache, test-kind-nocache]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Checkout
uses: actions/checkout@main
- name: Setup Nix environment
uses: ./.github/actions/setup-nix
with:
nixbuild_key: ${{ secrets.NIXBUILD_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
cache_key: release
- name: Render deployment manifest
run: |
nix build --show-trace --file . kubenixApply.manifestYAMLFile
cp result nix-csi-deployment.yaml
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
files: nix-csi-deployment.yaml
draft: false
prerelease: false