Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 126 additions & 0 deletions .github/workflows/nix-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
name: Nix Build and Test

on:
push:
branches: [master, main]
pull_request:
branches: [master, main]

jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 60

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Free disk space
run: |
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc
df -h

- name: Install Nix
uses: cachix/install-nix-action@v30
with:
nix_path: nixpkgs=channel:nixos-unstable

- name: Build browservice
run: nix build .#browservice --print-build-logs
timeout-minutes: 45

- name: Test browservice starts and serves HTTP
timeout-minutes: 5
run: |
set -e

# Start browservice in background
# Note: --no-sandbox is required in CI because chrome-sandbox needs setuid root
echo "Starting browservice..."
./result/bin/browservice --use-dedicated-xvfb=yes --chromium-args=--no-sandbox > /tmp/browservice.log 2>&1 &
PID=$!

# Wait for HTTP server to start (increased timeout for CI)
echo "Waiting for HTTP server to start..."
for i in {1..60}; do
if curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:8080/ 2>/dev/null | grep -q "200"; then
echo "HTTP server is up after ${i}s!"
break
fi
if [ $i -eq 60 ]; then
echo "Timeout waiting for HTTP server after 60s"
echo "=== Browservice logs ==="
cat /tmp/browservice.log || true
echo "=== End logs ==="
kill -9 $PID 2>/dev/null || true
exit 1
fi
sleep 1
done

# Test the HTTP endpoint
echo "Testing HTTP endpoint..."
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:8080/)
echo "HTTP response code: $HTTP_CODE"

if [ "$HTTP_CODE" != "200" ]; then
echo "Expected HTTP 200, got $HTTP_CODE"
echo "=== Browservice logs ==="
cat /tmp/browservice.log || true
echo "=== End logs ==="
kill -9 $PID 2>/dev/null || true
exit 1
fi

# Verify HTML content
echo "Verifying HTML content..."
CONTENT=$(curl -s http://127.0.0.1:8080/)
if echo "$CONTENT" | grep -q "Browservice"; then
echo "HTML content verified!"
else
echo "Expected 'Browservice' in HTML content"
echo "Got: $CONTENT"
kill -9 $PID 2>/dev/null || true
exit 1
fi

# Cleanup - use SIGKILL to ensure process tree dies
echo "Cleaning up..."
kill -9 $PID 2>/dev/null || true
sleep 1

echo "All tests passed!"

- name: Check flake
run: nix flake check

- name: Test NixOS module evaluation
run: |
nix eval .#nixosModules.default --apply 'm: builtins.typeOf m'
echo "NixOS module exports correctly"

build-aarch64:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Nix
uses: cachix/install-nix-action@v30
with:
nix_path: nixpkgs=channel:nixos-unstable
extra_nix_config: |
extra-platforms = aarch64-linux

- name: Setup QEMU for aarch64
uses: docker/setup-qemu-action@v3
with:
platforms: arm64

- name: Build browservice for aarch64 (evaluation only)
run: |
# Just evaluate the derivation to check it's valid
# Full build would take too long on emulation
nix eval .#packages.aarch64-linux.browservice.drvPath
echo "aarch64-linux derivation evaluates successfully"
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,8 @@ debug
release
gen
GPUCache

# Nix
result
result-*
.direnv
Loading