Server E2E Tests #17
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Server E2E Tests | |
on: | |
push: | |
branches: [main] | |
paths: | |
- 'server/**' | |
- 'compile_server_os/**' | |
- '.github/workflows/server-e2e-tests.yml' | |
pull_request: | |
branches: [main] | |
paths: | |
- 'server/**' | |
- 'compile_server_os/**' | |
- '.github/workflows/server-e2e-tests.yml' | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Install Nix | |
uses: DeterminateSystems/nix-installer-action@v9 | |
- name: Restore and Cache Nix Store | |
uses: nix-community/cache-nix-action@v5 | |
with: | |
primary-key: nix-${{ runner.os }}-${{ hashFiles('**/*.nix') }} | |
restore-prefixes-first-match: nix-${{ runner.os }}- | |
save-always: true | |
- name: Install QEMU | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y qemu-system-x86 curl | |
- name: Build VM | |
working-directory: compile_server_os | |
run: | | |
nix build .#nixosConfigurations.test-system.config.system.build.vm | |
sudo mv result/bin/run-*-vm vm-run | |
- name: Start VM | |
working-directory: compile_server_os | |
run: sudo ./vm-run --no-reboot -nographic -nic user,model=virtio,hostfwd=tcp::3000-:3000 & | |
- name: Wait for Boot | |
timeout-minutes: 5 | |
run: | | |
while true; do | |
curl http://localhost:3000 && break | |
echo "Waiting for server..." | |
sleep 5 | |
done | |
- name: Run Tests | |
run: | | |
curl --fail http://localhost:3000 || (echo "Server not reachable!" && exit 1) |