Merge pull request 'CI: Wegwerf-Postgres je Lauf fuer DB-Tests (A-08) und CODEOWNERS fuer common/ (A-09)' (#398) from feat/ci-db-cluster into main
CI / Web-Barrierefreiheitspruefung (axe, Tastatur, Reflow, Textabstaende) (push) Canceled after 0s
CI / Core-Modul (Build/Vet/Test) (push) Successful in 58s
CI / DMS Security-Test-Gate (AC5, Merge-Gate) (push) Successful in 4s
CI / Connect Security-Test-Gate (QA-01 AC4, Merge-Gate) (push) Successful in 3s
CI / DMS-Modul Supply-Chain-Scan (govulncheck) (push) Failing after 17s
CI / Web (dms-browser) (push) Failing after 1m22s
CI / Web (pdf-viewer) (push) Failing after 1m0s
CI / Web (shl) (push) Failing after 14s
CI / DMS-Modul (Lint/Build/Test/Coverage/Artefakt) (push) Failing after 2s

This commit was merged in pull request #398.
This commit is contained in:
patrick committed 2026-10-28 11:32:56 +01:00
commit c22ad6e8ca
3 files changed
+59 -9

No files matched your search

+2
View File
@@ -0,0 +1,2 @@
# common/ ist modulübergreifend: Änderungen brauchen Review (Auswirkungsliste im PR)
/common/ @patrick
+18 -9
View File
@@ -4,25 +4,34 @@ on:
pull_request:
paths:
- "common/**"
- "dms/**"
- "mail/**"
- "archive/**"
- "ai/**"
- "connect/**"
- "workflow/**"
- "internal/**"
- "scripts/ci-pg-cluster.sh"
- ".gitea/workflows/db-tests.yml"
jobs:
db-tests:
runs-on: nexarch-test
env:
TEST_ADMIN_DSN: ${{ secrets.TEST_ADMIN_DSN }}
REQUIRE_DB: "1"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.25"
- name: Tests (common)
- name: Wegwerf-Postgres starten
run: scripts/ci-pg-cluster.sh start
- name: common
working-directory: common
run: go test ./testdb/... ./migrate/... -count=1 -p 1
run: go test ./... -count=1 -p 1
- name: archive
working-directory: archive
run: go test ./... -count=1 -p 1
- name: ai
working-directory: ai
run: go test ./... -count=1 -p 1
- name: connect
working-directory: connect
run: go test ./... -count=1 -p 1
- name: Wegwerf-Postgres stoppen
if: always()
run: scripts/ci-pg-cluster.sh stop
+39
View File
@@ -0,0 +1,39 @@
#!/usr/bin/env bash
# Startet/stoppt einen Wegwerf-Postgres fuer CI-DB-Tests (kein Secret, keine feste DB).
set -euo pipefail
PGBIN=${PGBIN:-/usr/lib/postgresql/17/bin}
PREFIX=/tmp/nexarch-ci-pg.
case "${1:-}" in
start)
dir=$(mktemp -d "${PREFIX}XXXXXX")
chown postgres:postgres "$dir"
port=$((55000 + RANDOM % 1000))
while ss -ltn | grep -q ":$port "; do port=$((55000 + RANDOM % 1000)); done
runuser -u postgres -- "$PGBIN/initdb" -D "$dir/data" -A trust -U postgres >/dev/null
runuser -u postgres -- "$PGBIN/pg_ctl" -D "$dir/data" -l "$dir/log" -w \
-o "-p $port -c listen_addresses=127.0.0.1 -c unix_socket_directories=$dir" start >/dev/null
for db in tenant_a tenant_b; do
"$PGBIN/psql" -h 127.0.0.1 -p "$port" -U postgres -qc "create database $db"
done
base="postgres://postgres@127.0.0.1:$port"
{
echo "NEXARCH_CI_PGDIR=$dir"
echo "TEST_ADMIN_DSN=$base/postgres?sslmode=disable"
echo "TEST_TENANT_DSN=$base/tenant_a?sslmode=disable"
echo "TEST_TENANT_DSN_B=$base/tenant_b?sslmode=disable"
echo "REQUIRE_DB=1"
} >> "${GITHUB_ENV:-/dev/stdout}"
;;
stop)
dir=${NEXARCH_CI_PGDIR:-}
case "$dir" in "$PREFIX"*) ;; *) echo "kein CI-Cluster zu stoppen" ; exit 0 ;; esac
runuser -u postgres -- "$PGBIN/pg_ctl" -D "$dir/data" -m fast stop >/dev/null || true
rm -rf "$dir"
;;
*)
echo "Aufruf: $0 start|stop" >&2
exit 2
;;
esac