Files
archtika/.github/workflows/test.yml

56 lines
1.4 KiB
YAML

name: Playwright tests
on:
push:
branches: [ devel, main ]
pull_request:
branches: [ devel, main ]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Nix
uses: cachix/install-nix-action@v27
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
- name: Run playwright tests
run: |
wait_for_postgres() {
echo "Waiting for PostgreSQL to be ready..."
while ! nix shell nixpkgs#postgresql_16 -c pg_isready -h localhost -p 15432 -U postgres; do
sleep 1
done
echo "PostgreSQL is ready."
}
wait_for_postgrest() {
echo "Waiting for PostgREST to be live and ready..."
while ! curl -s -I "http://localhost:3001/live" | grep "OK"; do
sleep 1
done
while ! curl -s -I "http://localhost:3001/ready" | grep "OK"; do
sleep 1
done
echo "PostgREST is live and ready."
}
sudo mkdir -p /var/www/archtika-websites
sudo chown $USER:$(id -gn) /var/www/archtika-websites
nix run .#dev-vm &
DEV_VM_PID=$!
wait_for_postgres
nix run .#api &
wait_for_postgrest
cd web-app
nix develop .#web --command bash -c 'npm install && npm run test'
pkill -e postgrest || echo "No api process found"
kill $DEV_VM_PID || echo "No dev-vm process found"