Use unique db container and cleanup
This commit is contained in:
12
.github/workflows/python-uv-ci.yml
vendored
12
.github/workflows/python-uv-ci.yml
vendored
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user