HH-448: enforce PostgreSQL E2E gate (#87)

* HH-448 enforce PostgreSQL E2E gate

* HH-448 fail CI when concurrency test is missing

---------

Co-authored-by: Rogee <rogee@ipao.vip>
This commit is contained in:
Rogee
2026-08-21 20:00:41 +08:00
committed by GitHub
co-authored by rogee
parent cf263d10b4
commit 7e3872170f
3 changed files with 105 additions and 32 deletions
+63 -3
View File
@@ -49,11 +49,11 @@ jobs:
run: go vet ./...
backend-postgres:
name: Backend (PostgreSQL concurrency)
name: Backend (PostgreSQL)
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16-alpine
image: pgvector/pgvector:pg16
env:
POSTGRES_DB: gochat_test
POSTGRES_USER: postgres
@@ -76,7 +76,67 @@ jobs:
env:
GOCHAT_TEST_DB: postgres
GOCHAT_TEST_DB_URL: postgres://postgres:postgres@localhost:5432/gochat_test?sslmode=disable
run: go test ./internal/autoassignment -run '^TestAssignmentServiceOnlyOneConcurrentWorkerWinsPostgres$' -count=3
run: |
set -euo pipefail
output="$RUNNER_TEMP/autoassignment-concurrency.json"
go test -json ./internal/autoassignment -run '^TestAssignmentServiceOnlyOneConcurrentWorkerWinsPostgres$' -count=3 | tee "$output"
grep -Eq '"Action":"pass".*"Test":"TestAssignmentServiceOnlyOneConcurrentWorkerWinsPostgres"' "$output" || {
echo "PostgreSQL auto-assignment concurrency test did not run" >&2
exit 1
}
- name: Test PostgreSQL E2E
working-directory: backend
env:
GOCHAT_TEST_DB: postgres
GOCHAT_TEST_DB_URL: postgres://postgres:postgres@localhost:5432/gochat_test?sslmode=disable
run: |
set -euo pipefail
output="$RUNNER_TEMP/postgres-e2e.json"
go test -json -count=1 -timeout 10m ./tests/e2e/... | tee "$output"
python3 - "$output" <<'PY'
import json
import sys
required = {
"TestAuthE2ESuite",
"TestAccountCRUDE2ESuite",
"TestConversationE2ESuite",
"TestCRME2ESuite",
"TestCSRFE2ETestSuite",
"TestRBACE2ESuite",
}
results = {}
with open(sys.argv[1], encoding="utf-8") as events:
for line in events:
event = json.loads(line)
if event.get("Test") and event.get("Action") in {"pass", "skip", "fail"}:
results[event["Test"]] = event["Action"]
missing = sorted(suite for suite in required if results.get(suite) != "pass")
passed_subtests = {suite: 0 for suite in required}
skipped_subtests = {suite: 0 for suite in required}
for test, action in results.items():
suite, separator, _ = test.partition("/")
if separator and suite in required:
if action == "pass":
passed_subtests[suite] += 1
elif action == "skip":
skipped_subtests[suite] += 1
empty = sorted(suite for suite, count in passed_subtests.items() if count == 0)
for suite in sorted(required):
print(f"{suite}: {passed_subtests[suite]} passed, {skipped_subtests[suite]} skipped")
print(
"E2E totals: "
f"{sum(action == 'pass' for action in results.values())} passed, "
f"{sum(action == 'skip' for action in results.values())} skipped"
)
if missing:
raise SystemExit(f"required E2E suites did not pass: {', '.join(missing)}")
if empty:
raise SystemExit(f"required E2E suites ran no passing subtests: {', '.join(empty)}")
PY
frontend:
name: Frontend Build