Skip to content

Add NixVolumeMount event validation to integration tests @claude #312

Add NixVolumeMount event validation to integration tests @claude

Add NixVolumeMount event validation to integration tests @claude #312

Workflow file for this run

on:
pull_request:
push:
branches:
- main
- develop
workflow_dispatch:
env:
REPO_USERNAME: ${{ github.actor }}
REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}
permissions:
contents: read
packages: write
actions: write
jobs:
# Build and push all components
build:
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
- name: Build and push environments
run: |
unlink nix-envs || true
nix build --show-trace --file . push --out-link nix-envs
./nix-envs/bin/push
# Build and push all components sequentially to reuse Nix store
- name: Build and push Lix image
run: |
unlink nix-images || true
nix build --show-trace --file . lixImage.push --out-link nix-images
./nix-images/bin/push
- 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
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/nix-node -n nix-csi --timeout=60s
- name: Wait for nix-csi cache pod
run: |
kubectl wait --for=condition=ready pod -l app.kubernetes.io/name=cache -n nix-csi --timeout=60s
- name: Wait for test workload
run: |
kubectl wait --for=condition=complete job/flake-hello job/expr-hello job/path-hello -n nix-csi --timeout=60s
- name: Validate success events
run: |
echo "=== Checking NixVolumeMount events ==="
EVENTS=$(kubectl get events -n nix-csi -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
echo "$EVENTS" | jq '.items[] |
select(.reason == "NixVolumeMount" and .type == "Normal") |
{pod: .regarding.name, message: .note}'
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 -n nix-csi
kubectl wait --for=delete pod -l "job-name in (flake-hello,expr-hello,path-hello)" -n nix-csi --timeout=60s
- name: Print node logs
run: |
echo "=== Node pod logs ==="
kubectl logs -l app.kubernetes.io/name=csi -n nix-csi --tail -1
- name: Cluster state all
if: failure()
run: |
echo "=== Cluster state all ==="
kubectl get all -A || true
- name: Cluster state configmaps
if: failure()
run: |
echo "=== Cluster configmaps ==="
kubectl get configmaps -A || true
- name: Cluster state secrets
if: failure()
run: |
kubectl get secrets -A || true
- name: Cache
if: failure()
run: |
kubectl logs -l app.kubernetes.io/name=cache -n nix-csi --tail -1 || true
kubectl describe pod -l app.kubernetes.io/name=cache-n nix-csi || true
- name: Node
if: failure()
run: |
kubectl logs -l app.kubernetes.io/name=csi -n nix-csi --tail -1 || true
kubectl describe pod -l app.kubernetes.io/name=csi -n nix-csi || true
- name: Init
if: failure()
run: |
kubectl logs -l app.kubernetes.io/name=init -n nix-csi --tail -1 || true
- name: Events
if: failure()
run: |
kubectl get events -n nix-csi --sort-by='.lastTimestamp'
- name: Troubleshoot with upterm
if: failure()
uses: owenthereal/action-upterm@main
with:
limit-access-to-actor: true
wait-timeout-minutes: 5
test-kind-nocache:
needs: build
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/nix-node -n nix-csi --timeout=60s
- name: Wait for test workload
run: |
kubectl wait --for=condition=complete job/flake-hello job/expr-hello job/path-hello -n nix-csi --timeout=60s
- name: Delete jobs and verify CSI cleanup
run: |
kubectl delete job flake-hello expr-hello path-hello -n nix-csi
kubectl wait --for=delete pod -l "job-name in (flake-hello,expr-hello,path-hello)" -n nix-csi --timeout=60s
- name: Print node logs
run: |
echo "=== Node pod logs ==="
kubectl logs -l app.kubernetes.io/name=csi -n nix-csi --tail -1
- name: Debug on failure
if: failure()
run: |
echo "=== Cluster state ==="
kubectl get all -A
echo "=== Cache pod logs ==="
kubectl logs -l app.kubernetes.io/name=cache -n nix-csi --tail -1 || true
echo "=== Node pod logs ==="
kubectl logs -l app.kubernetes.io/name=csi -n nix-csi --tail -1 || true
echo "=== Init pod logs ==="
kubectl logs -l app.kubernetes.io/name=init -n nix-csi --tail -1 || true
echo "=== Events ==="
kubectl get events -n nix-csi --sort-by='.lastTimestamp'
- name: Troubleshoot with upterm
if: failure()
uses: owenthereal/action-upterm@main
with:
limit-access-to-actor: true
wait-timeout-minutes: 5