From 792afc0842a354b59fa10b56eda0b260043de803 Mon Sep 17 00:00:00 2001 From: Spike Curtis Date: Mon, 15 Jun 2026 16:23:36 -0400 Subject: [PATCH] ci: capture PostgreSQL logs in the gen job (#26340) Adds a `test-postgres-docker-logs` Make target that dumps the test PostgreSQL container's logs via `docker logs`. The container already logs every statement to stderr (`log_statement=all`, no `logging_collector`), so Docker captures them and no volume mounting or reconfiguration is needed. The CI `gen` job now starts the container with `make test-postgres-docker` before `make gen`, collects the logs at the end (always, even on failure), and uploads them as the `gen-postgres-logs` artifact to help debug generation issues that depend on the database. Refs: https://github.com/coder/internal/issues/1568 Opened by Coder Agents on behalf of @spikecurtis. --- .github/workflows/ci.yaml | 14 ++++++++++++++ Makefile | 9 +++++++++ 2 files changed, 23 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 857fb845c0..67883b118a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -342,6 +342,9 @@ jobs: - name: Install Go mise tools run: ./.github/scripts/retry.sh -- mise install --locked go:storj.io/drpc/cmd/protoc-gen-go-drpc go:github.com/coder/sqlc/cmd/sqlc + - name: Start PostgreSQL container + run: make test-postgres-docker + - name: make gen timeout-minutes: 8 run: | @@ -355,6 +358,17 @@ jobs: - name: Check for unstaged files run: ./scripts/check_unstaged.sh + - name: Collect PostgreSQL logs + if: always() + run: make test-postgres-docker-logs > postgres.log 2>&1 + + - name: Upload PostgreSQL logs + if: always() + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: gen-postgres-logs + path: postgres.log + fmt: needs: changes if: needs.changes.outputs.offlinedocs-only == 'false' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main' diff --git a/Makefile b/Makefile index be1992cb21..6c6d03f362 100644 --- a/Makefile +++ b/Makefile @@ -1598,6 +1598,15 @@ test-postgres-docker: done .PHONY: test-postgres-docker +# test-postgres-docker-logs prints the PostgreSQL container's logs. The +# postgres image logs to stderr (no logging_collector), which Docker captures, +# so combined with log_statement=all in test-postgres-docker these logs include +# every executed statement. Redirect to a file to save them, e.g. +# `make test-postgres-docker-logs > postgres.log`. +test-postgres-docker-logs: + docker logs test-postgres-docker-${POSTGRES_VERSION} +.PHONY: test-postgres-docker-logs + test-tailnet-integration: env \ CODER_TAILNET_TESTS=true \