From 4170b17ea6cef584f991adfd264cec62db63d20a Mon Sep 17 00:00:00 2001 From: estebanthi Date: Mon, 5 Jan 2026 11:56:40 +0100 Subject: [PATCH] Use unique db container and cleanup --- .github/workflows/python-uv-ci.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/python-uv-ci.yml b/.github/workflows/python-uv-ci.yml index a627752..19475e2 100644 --- a/.github/workflows/python-uv-ci.yml +++ b/.github/workflows/python-uv-ci.yml @@ -134,7 +134,10 @@ jobs: db_type="${{ inputs.db_type }}" case "$db_type" in postgres|postgresql) - container_name="ci-postgres" + run_id="${GITHUB_RUN_ID:-local}" + attempt="${GITHUB_RUN_ATTEMPT:-0}" + container_name="ci-postgres-${run_id}-${attempt}" + echo "DB_CONTAINER_NAME=$container_name" >> "$GITHUB_ENV" docker run -d --name "$container_name" \ -e POSTGRES_USER=postgres \ -e POSTGRES_PASSWORD=postgres \ @@ -182,3 +185,10 @@ jobs: - name: Run tests if: ${{ inputs.test_command != '' }} run: ${{ inputs.test_command }} + + - name: Cleanup database + if: ${{ always() && inputs.enable_db }} + run: | + if [ -n "${DB_CONTAINER_NAME:-}" ]; then + docker rm -f "$DB_CONTAINER_NAME" >/dev/null 2>&1 || true + fi