diff --git a/.forgejo/workflows/ci.yml b/.forgejo/workflows/ci.yml index 8d10956..92d9b54 100644 --- a/.forgejo/workflows/ci.yml +++ b/.forgejo/workflows/ci.yml @@ -26,27 +26,33 @@ jobs: build-and-test: runs-on: debian-12 - services: - postgres: - image: postgres:17-alpine - env: - POSTGRES_DB: heimdall_test - POSTGRES_USER: heimdall - POSTGRES_PASSWORD: heimdall - ports: - - 5432:5432 - options: >- - --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 - + # LXC runner (auto-scaler) does NOT support Docker service containers. + # PostgreSQL is installed via apt and started directly on the runner. steps: - name: Checkout uses: https://forgejo.tordais.cc/actions/checkout@v4 with: fetch-depth: 0 + - name: Start PostgreSQL + run: | + apt-get -qq update + apt-get install -y -qq --no-install-recommends postgresql postgresql-client + # Allow password auth on localhost for the heimdall user + sed -ri 's/local\s+all\s+all\s+peer/local all all trust/' /etc/postgresql/*/main/pg_hba.conf + sed -ri 's/host\s+all\s+all\s+127\.0\.0\.1\/32\s+scram-sha-256/host all all 127.0.0.1\/32 md5/' /etc/postgresql/*/main/pg_hba.conf + sed -ri 's/host\s+all\s+all\s+::1\/128\s+scram-sha-256/host all all ::1\/128 md5/' /etc/postgresql/*/main/pg_hba.conf + # Listen on all interfaces (needed for localhost connections) + sed -ri "s/^#listen_addresses = 'localhost'/listen_addresses = 'localhost'/" /etc/postgresql/*/main/postgresql.conf + pg_ctlcluster $(pg_lsclusters -h | head -1 | awk '{print $1, $2}') start + # Create user and database + su - postgres -c "psql -c \"CREATE USER heimdall WITH PASSWORD 'heimdall';\"" 2>/dev/null || true + su - postgres -c "psql -c \"CREATE DATABASE heimdall_test OWNER heimdall;\"" 2>/dev/null || true + # Verify connectivity + PGPASSWORD=heimdall psql -U heimdall -d heimdall_test -h localhost -c "SELECT 1" > /dev/null 2>&1 || \ + (echo "ERROR: Cannot connect to PostgreSQL"; exit 1) + echo "PostgreSQL is ready" + - name: Setup .NET ${{ env.DOTNET_VERSION }} uses: https://forgejo.tordais.cc/actions/setup-dotnet@v4 with: