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

DE
15h ago
+592-2

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.