Skip to content

ci(docker): add compose env snapshot tool and checks - #21820

Open
devashish2203 wants to merge 4 commits into
masterfrom
pfp-8938-env-snapshot-tool
Open

devashish2203 wants to merge 4 commits into
masterfrom
pfp-8938-env-snapshot-tool

Conversation

@devashish2203

@devashish2203 devashish2203 commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Adds a mechanical check of the resolved Docker Compose model, as groundwork for moving Docker env values into layered env/ files. No behaviour change to any stack.

  • .github/scripts/compose_env_snapshot.py (stdlib Python): renders each stack with docker compose config --format json and keeps environment, image, ports, volumes, command, entrypoint per service. snapshot writes a file; diff compares two. Checkout and home paths are normalised so two checkouts compare equal. Scenarios (98, about 5 s with a warm Gradle daemon):
    • every profile, clean env, and with each ${KEY} from the compose and env files set to a sentinel
    • every quickstart_configs Gradle key (covers ONNX and Spark)
    • quickstart_compose() from smoke-test/run-quickstart.sh
    • the AI smoke leg of docker-unified.yml (both providers)
    • ZDU (base + docker-compose.zdu-test-override.yml, both topologies)
  • snapshot exits 1 when a stack fails to render, unless it is a known-broken stack failing with its recorded error; diff exits 1 when the snapshots differ. Any tool error exits 2.
  • :docker:printComposeSettings: prints, per quickstart config, the env and compose arguments the compose plugin uses (read from composeExecutor, as generateQuickstartComposeConfig does). The plugin's environment overrides the process env; process-env keys the plugin does not set still reach compose. Values of keys ending in SECRET, SIGNING_KEY or SALT are printed as <redacted>.
  • verify-quickstart-compose.yml:
    • runs on PRs touching docker/**, env/**, smoke-test/run-quickstart.sh, the scripts, the workflows the tool copies the AI leg and ZDU settings from (docker-unified.yml, zdu-e2e-daily.yml), and the env files it points compose at (smoke-test/test_resources/actions/actions.env, the Spark smoke test's *.env files); it also re-runs when a label is added or removed
    • asserts the generated quickstart file has no env_file key
    • new job: every stack renders; on PRs, a base-versus-PR snapshot diff is posted as the job summary. Any difference fails the job unless the PR has the env-change-intended label; a tool error always fails it.
  • check_quickstart_compose.sh also unsets variables named in the *.env files under docker/ and env/, including bare pass-through lines; its pre-commit hook now also runs on env/ changes (override file and generated config).
  • The new script and its test are added to the linted scripts in test-github-scripts.yml.

Notes for reviewers

  • This PR changes the snapshot of every gradle/* stack, because the base branch has no printComposeSettings task yet. It therefore carries the env-change-intended label.
  • Two stacks do not render on master and are marked known-broken in the tool. Each counts as known-broken only while it fails with its recorded error:
    • profile debug-frontend: frontend-debug-frontend depends on system-update-debug, which is not in that profile
    • Gradle task quickstartDebugSearchSplit: its compose file docker/profiles/docker-compose.search-split-override.yml is not in the repository

Verification

  • python3 .github/scripts/compose_env_snapshot.py snapshot -o …: 98 scenarios, 3 render failures, all known-broken. Two runs diff empty.
  • Snapshot of a master checkout vs this branch: 0 differences outside gradle/* (master lacks the print task).
  • bash .github/scripts/check_quickstart_compose.sh: generated quickstart file unchanged.
  • Merge order of plugin env over process env: confirmed by rendering quickstartCLI with conflicting shell values.
  • pytest .github/scripts/test/test_compose_env_snapshot.py (diff output, and known-broken matching on the recorded error), ruff and mypy (settings of test-github-scripts.yml), actionlint, githubActionsPrettierCheck: pass.

Checklist

  • The PR conforms to DataHub's Contributing Guideline (particularly PR Title Format)
  • Links to related issues (if applicable)
  • Tests for the changes have been added/updated (if applicable)
  • Docs related to the changes have been added/updated (if applicable)
  • For any breaking change/potential downtime/deprecation/big changes an entry has been made in Breaking Changes — not applicable

🤖 Generated with Claude Code


Summary by cubic

Adds a snapshot tool for the resolved Docker Compose model of every stack, groundwork for moving Docker env values into layered env/ files. No behavior change to any stack.

  • compose_env_snapshot.py renders roughly 98 scenarios (profiles, Gradle quickstart tasks, smoke, AI leg, ZDU) and diffs two snapshots; checkout and home paths are normalized so two checkouts compare equal. A stack that fails with an unexpected (non-recorded) error fails the check.
  • New Gradle task printComposeSettings prints the env and compose arguments the compose plugin uses per quickstart config, redacting secrets.
  • verify-quickstart-compose.yml runs on PRs touching docker/**, env/**, the snapshot scripts, the workflows and env files the tool copies settings from; asserts the generated quickstart file has no env_file key, and posts a base-versus-PR snapshot diff as the job summary. The diff fails the job on any difference unless the PR carries the env-change-intended label; tool errors always fail.
  • The quickstart pre-commit hook now also runs on env/ changes, and the checker unsets variables named by env files compose reads, including bare pass-through lines.

Two stacks are known-broken: profile debug-frontend depends on a service not in its profile, and Gradle task quickstartDebugSearchSplit references a compose file not in the repository.

Written for commit c8fdb45. Summary will update on new commits.

View guided diff Turn on auto-fix

Add .github/scripts/compose_env_snapshot.py, which renders every Docker
Compose stack (each profile bare and with shell overrides, each Gradle
quickstart task, smoke, the AI smoke leg, ZDU) with `docker compose config`
and diffs two snapshots. Add :docker:printComposeSettings, which prints the
env and compose arguments the compose plugin uses per quickstart config.

verify-quickstart-compose now runs on docker/** and env/** changes, asserts
the generated quickstart file has no env_file key, checks that every stack
renders, and on PRs posts a base-versus-PR snapshot diff as a job summary
(failing only with the "no env change" label). The quickstart pre-commit
hook also runs on env/ changes.

No behaviour change to any stack.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cursor

cursor Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

PR Summary

Overview
Adds CI machinery to snapshot and diff the fully resolved Docker Compose model across DataHub startup paths (profiles, Gradle quickstart configs, smoke, AI, ZDU), as groundwork for layered env/ files. No intended runtime change to how stacks run.

The new compose_env_snapshot.py runs docker compose config per scenario, normalizes paths, and compares two JSON snapshots; unit tests cover diffing and known-broken profiles. docker:printComposeSettings is added so Gradle quickstart scenarios mirror the compose plugin’s env and file args (secrets redacted).

verify-quickstart-compose.yml gains broader path filters, a check that the generated quickstart compose file has no env_file, and a compose-env-snapshot job that fails PRs when base vs head models differ unless the PR has the env-change-intended label (re-run on label add/remove). The quickstart compose check script and pre-commit hook now also consider env/** variables when unsetting host env for a clean generate.

Reviewed by Cursor Bugbot for commit c8fdb45. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions github-actions Bot added the devops PR or Issue related to DataHub backend & deployment label Dec 2, 2026
@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Smart test selection

pytest smoke tests

Mode: active. Only the selection below runs for the pytest smoke tests on this PR (applied: canary).

  • Selection: canary: always-run modules plus this PR's changed tests (no product feature identified)
  • Size: 10 of 853 tests in 1 batch, predicted longest batch ~0 min
  • Tags: change-type: build, ci, docs, test-infra
  • Confidence: HIGH (8 changed files)
  • Classifier reasoning: The change only touches CI workflows and scripts, the Gradle quickstart compose helper task, and smoke-test compose snapshot tooling, with no product code changes, so it is CI, build and test-infra tooling with no feature tags.
Selected scopes (3 files or classes, 10 tests)
  • tests/e2e/authorization/test_self_entity_auth.py
  • tests/e2e/read_only/test_services_up.py
  • tests/e2e/search/test_search_projection.py::TestSearchProjection

Add the run-all-tests:pytest label to run the full pytest suite on this PR.

Playwright E2E tests

This run: p0

  • Selection: p0: P0 tests plus the tests the change affects
  • Size: 145 tests in 79 spec files, ~32 min predicted on 4 shard(s)
  • Baseline: 79 spec files run for every PR (@p0)
  • No spec was selected because of this PR's changes.

Add the run-all-tests:playwright label to run the full Playwright suite on this PR.

commit c8fdb45 · workflow run

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 8 files

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread docker/build.gradle Resolved
Comment thread .github/scripts/compose_env_snapshot.py Resolved
Comment thread .github/scripts/compose_env_snapshot.py Resolved
Comment thread .github/scripts/compose_env_snapshot.py Resolved
@codecov

codecov Bot commented Dec 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

…labelled intended

The snapshot diff job now fails on any difference in the rendered compose
model unless the PR carries the env-change-intended label. With the label
the job passes and still posts the diff as the job summary.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@devashish2203 devashish2203 added the env-change-intended The PR changes rendered Docker compose env on purpose; lets the env snapshot diff check pass label Dec 3, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 1 file (changes from recent commits).

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

- printComposeSettings redacts secret, signing key and salt values.
- The snapshot diff exits 2 on a tool error, and the workflow always fails on it,
  label or not.
- A known-broken stack only counts as known when it fails with its recorded error.
- The shell scenario sets DATAHUB_APP_VERSION, a container env value.
- The check also runs when docker-unified.yml or zdu-e2e-daily.yml change.
- check_quickstart_compose.sh unsets variables named by any env file compose reads,
  including bare pass-through lines, and fails on a grep read error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 4 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread docker/build.gradle Resolved
Comment thread .github/scripts/compose_env_snapshot.py Resolved
…aths

- Move the render-failure check into unexpected_failures() and test that a
  known-broken stack failing with a different error counts as unexpected.
- Run the check when the actions env file the AI scenario uses, or the Spark
  smoke env files the Gradle task points compose at, change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@david-leifker david-leifker left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

This branch was successfully deployed

1 active deployment
Preview — c8fdb454 Deployed Dec 3, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

devops PR or Issue related to DataHub backend & deployment env-change-intended The PR changes rendered Docker compose env on purpose; lets the env snapshot diff check pass

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants