fix(ci): replace postgres service with apt-get for LXC runner
The Forgejo runner uses a Debian 12 LXC auto-scaler that does not support Docker service containers. PostgreSQL was defined as a services container in ci.yml but never started, causing all DB-dependent tests to fail with "Connection refused to 127.0.0.1:5432". Remove the services section and add a Start PostgreSQL step that installs PostgreSQL via apt-get, configures pg_hba.conf for password auth, starts the cluster, creates the heimdall user and database, and verifies connectivity with pg_isready.
This commit is contained in:
1 parent
0ef4642f6d
commit
4d79f416a7
1 file changed
+21
-15
+21
-15
@@ -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:
|
||||
|
||||
Reference in new issue
Block a user