Some checks failed
Test Suite / test (push) Failing after 16s
- Changed the CI workflow to run tests inside a NixOS virtual machine instead of directly on the runner. - Updated the NixOS VM configuration to include necessary dependencies and services for testing. - Added a script to handle test execution within the VM, including setup for Python and Node.js environments. - Implemented SSH access to the VM for remote operations and streamlined the process of starting and stopping the VM during tests. - Enhanced the workflow to build the VM and copy the codebase for testing, ensuring a more isolated and consistent testing environment.
65 lines
1.5 KiB
Bash
Executable File
65 lines
1.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Helper script to run tests inside the VM
|
|
# This script is executed inside the VM
|
|
|
|
set -e
|
|
|
|
cd /tmp/moviemap
|
|
|
|
echo "=== Setting up test environment ==="
|
|
|
|
# Setup Python
|
|
cd backend
|
|
export PATH="/root/.local/bin:$PATH"
|
|
python3 -m pip install --user --upgrade pip
|
|
python3 -m pip install --user -r requirements.txt
|
|
|
|
# Setup Node.js
|
|
cd ../frontend
|
|
npm ci
|
|
|
|
echo "=== Waiting for PostgreSQL ==="
|
|
# Wait for PostgreSQL to be ready
|
|
for i in {1..30}; do
|
|
if sudo -u postgres psql -c "SELECT 1;" > /dev/null 2>&1; then
|
|
echo "PostgreSQL is ready"
|
|
break
|
|
fi
|
|
if [ $i -eq 30 ]; then
|
|
echo "PostgreSQL failed to start"
|
|
exit 1
|
|
fi
|
|
sleep 1
|
|
done
|
|
|
|
echo "=== Running database migrations ==="
|
|
cd ../backend
|
|
export POSTGRES_SOCKET_PATH=/var/run/postgresql
|
|
export POSTGRES_DB=moviemap_test
|
|
export POSTGRES_USER=moviemap
|
|
export PATH="/root/.local/bin:$PATH"
|
|
alembic upgrade head
|
|
|
|
echo "=== Running backend tests ==="
|
|
export TEST_POSTGRES_DB=moviemap_test
|
|
export TEST_POSTGRES_USER=moviemap
|
|
export TEST_POSTGRES_SOCKET_PATH=/var/run/postgresql
|
|
export RADARR_URL=http://localhost:7878
|
|
export SONARR_URL=http://localhost:8989
|
|
export LIDARR_URL=http://localhost:8686
|
|
export RADARR_API_KEY=test-key
|
|
export SONARR_API_KEY=test-key
|
|
export LIDARR_API_KEY=test-key
|
|
export PATH="/root/.local/bin:$PATH"
|
|
pytest tests/ -v --cov=app --cov-report=term-missing
|
|
|
|
echo "=== Building frontend ==="
|
|
cd ../frontend
|
|
npm run build
|
|
|
|
echo "=== Running frontend tests ==="
|
|
npm test -- --run
|
|
|
|
echo "=== All tests completed successfully ==="
|
|
|