-
Notifications
You must be signed in to change notification settings - Fork 0
Docker Demo #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Docker Demo #2
Changes from all commits
0ca2eff
4a28695
0ac61f4
3c1ee38
d231824
58551c2
4f63408
70bb3e0
54b5b8f
64a1e3c
6b8dfe2
fcf42f0
edf2448
38d3f23
cb4fe14
0b7dafb
7b19e49
43d7c50
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,86 @@ | ||||||||||||||||||||||||
| name: Docker demo test (Docker Compose) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| on: | ||||||||||||||||||||||||
| push: | ||||||||||||||||||||||||
| branches: [main] | ||||||||||||||||||||||||
| pull_request: | ||||||||||||||||||||||||
| branches: [main] | ||||||||||||||||||||||||
| workflow_dispatch: | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| concurrency: | ||||||||||||||||||||||||
| group: ${{ github.workflow }}-${{ github.ref }} | ||||||||||||||||||||||||
| cancel-in-progress: true | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| jobs: | ||||||||||||||||||||||||
| demo: | ||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||
| timeout-minutes: 12 | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||
| - uses: actions/checkout@v5 | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| - name: Set up Docker Buildx | ||||||||||||||||||||||||
| uses: docker/setup-buildx-action@v3 | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| - name: Pre-pull base images (cache warmup) | ||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||
| docker pull postgres:16 | ||||||||||||||||||||||||
| docker pull python:3.12-slim | ||||||||||||||||||||||||
| docker pull ghcr.io/astral-sh/uv:latest || true | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| - name: Build app image with cache | ||||||||||||||||||||||||
| uses: docker/build-push-action@v6 | ||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||
| context: . | ||||||||||||||||||||||||
| tags: ggmpilot:demo-ci | ||||||||||||||||||||||||
| load: true | ||||||||||||||||||||||||
| cache-from: type=gha | ||||||||||||||||||||||||
| cache-to: type=gha,mode=max | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| - name: Show Docker info | ||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||
| docker version | ||||||||||||||||||||||||
| docker info | ||||||||||||||||||||||||
| docker compose version || true | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| - name: Run docker demo (Compose; keep DB running) | ||||||||||||||||||||||||
| shell: bash | ||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||
| set -euo pipefail | ||||||||||||||||||||||||
| export DEMO_APP_IMAGE=ggmpilot:demo-ci | ||||||||||||||||||||||||
| docker compose -f docker/demo/docker-compose.yml up -d demo-db | ||||||||||||||||||||||||
| docker compose -f docker/demo/docker-compose.yml run --rm demo-run | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| - name: Validate demo output (tables exist) | ||||||||||||||||||||||||
| if: always() | ||||||||||||||||||||||||
| shell: bash | ||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||
| set -euo pipefail | ||||||||||||||||||||||||
| # Verify a few expected tables in silver schema. | ||||||||||||||||||||||||
| docker ps -a | ||||||||||||||||||||||||
| docker exec ggmpilot-demo-db psql -U postgres -d demo -v ON_ERROR_STOP=1 -c "\ | ||||||||||||||||||||||||
| SELECT table_schema, table_name\ | ||||||||||||||||||||||||
| FROM information_schema.tables\ | ||||||||||||||||||||||||
| WHERE table_schema IN ('source','staging','silver')\ | ||||||||||||||||||||||||
| ORDER BY 1,2;\ | ||||||||||||||||||||||||
|
Comment on lines
+61
to
+65
|
||||||||||||||||||||||||
| docker exec ggmpilot-demo-db psql -U postgres -d demo -v ON_ERROR_STOP=1 -c "\ | |
| SELECT table_schema, table_name\ | |
| FROM information_schema.tables\ | |
| WHERE table_schema IN ('source','staging','silver')\ | |
| ORDER BY 1,2;\ | |
| docker exec ggmpilot-demo-db bash -c "psql -U postgres -d demo -v ON_ERROR_STOP=1 <<'EOF' | |
| SELECT table_schema, table_name | |
| FROM information_schema.tables | |
| WHERE table_schema IN ('source','staging','silver') | |
| ORDER BY 1,2; | |
| EOF |
Copilot
AI
Dec 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The validation step uses bash -lc to run commands inside the container, which is inconsistent with the use of bash (without -l) elsewhere in the workflow. The login shell flag (-l) is unnecessary here and can introduce unexpected behavior from profile files. Use bash -c for consistency and more predictable execution.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| """Repo-wide pytest configuration. | ||
|
|
||
| This file applies to all tests in the repository (including package-level | ||
| `*/tests` folders). It is intentionally minimal and focuses on integration-test | ||
| hygiene. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import os | ||
|
|
||
| import pytest | ||
|
|
||
|
|
||
| # Make shared fixtures/helpers from tests.integration_utils available everywhere. | ||
| pytest_plugins = ["tests.integration_utils"] | ||
|
|
||
|
|
||
| def _truthy_env(name: str) -> bool: | ||
| return os.getenv(name, "").strip().lower() in {"1", "true", "yes", "on"} | ||
|
|
||
|
|
||
| @pytest.fixture(scope="session", autouse=True) | ||
| def _cleanup_test_db_containers_session(): | ||
| """Clean up ggmpilot test DB containers before and after the session. | ||
|
|
||
| CI failures due to "port is already allocated" or inability to start new | ||
| containers are often caused by leftover `*-docker-db-*` containers/volumes | ||
| from previous runs. This cleanup is best-effort and only runs when: | ||
|
|
||
| - Docker is reachable, and | ||
| - either `RUN_SLOW_TESTS` is enabled or we are in CI. | ||
|
|
||
| To opt out locally, set `GGMPILOT_KEEP_TEST_CONTAINERS=1`. | ||
| """ | ||
|
|
||
| from tests.integration_utils import ( | ||
| cleanup_all_test_db_containers, | ||
| docker_running, | ||
| slow_tests_enabled, | ||
| ) | ||
|
|
||
| # In pytest-xdist, this session fixture would run in every worker process. | ||
| # Only run the global cleanup in the master/controller process to avoid | ||
| # workers deleting containers used by other workers. | ||
| if os.getenv("PYTEST_XDIST_WORKER"): | ||
| yield | ||
| return | ||
|
|
||
| if _truthy_env("GGMPILOT_KEEP_TEST_CONTAINERS"): | ||
| yield | ||
| return | ||
|
|
||
| should_cleanup = docker_running() and (slow_tests_enabled() or _truthy_env("CI")) | ||
| if should_cleanup: | ||
| cleanup_all_test_db_containers() | ||
|
|
||
| yield | ||
|
|
||
| if should_cleanup: | ||
| cleanup_all_test_db_containers() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The workflow uses
docker pull ghcr.io/astral-sh/uv:latest || truewhich silently ignores pull failures. While this might be intentional for cache warmup, it could mask network issues or repository access problems. Consider logging when the pull fails to make troubleshooting easier.