ci(docker): add compose env snapshot tool and checks
Ā
DE
15h ago+592+592+012345678901234567890123456789-2-2-0123456789
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 withdocker compose config --format jsonand keepsenvironment,image,ports,volumes,command,entrypointper service.snapshotwrites a file;diffcompares 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_configsGradle key (covers ONNX and Spark) quickstart_compose()fromsmoke-test/run-quickstart.sh- the AI smoke leg of
docker-unified.yml(both providers) - ZDU (base +
docker-compose.zdu-test-override.yml, both topologies)
- every profile, clean env, and with each
snapshotexits 1 when a stack fails to render, unless it is a known-broken stack failing with its recorded error;diffexits 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 fromcomposeExecutor, asgenerateQuickstartComposeConfigdoes). The plugin'senvironmentoverrides the process env; process-env keys the plugin does not set still reach compose. Values of keys ending inSECRET,SIGNING_KEYorSALTare 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*.envfiles); it also re-runs when a label is added or removed - asserts the generated quickstart file has no
env_filekey - 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-intendedlabel; a tool error always fails it.
- runs on PRs touching
check_quickstart_compose.shalso unsets variables named in the*.envfiles underdocker/andenv/, including bare pass-through lines; its pre-commit hook now also runs onenv/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 noprintComposeSettingstask yet. It therefore carries theenv-change-intendedlabel. - 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-frontenddepends onsystem-update-debug, which is not in that profile - Gradle task
quickstartDebugSearchSplit: its compose filedocker/profiles/docker-compose.search-split-override.ymlis not in the repository
- profile
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
quickstartCLIwith 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 oftest-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.pyrenders 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
printComposeSettingsprints the env and compose arguments the compose plugin uses per quickstart config, redacting secrets. verify-quickstart-compose.ymlruns on PRs touchingdocker/**,env/**, the snapshot scripts, the workflows and env files the tool copies settings from; asserts the generated quickstart file has noenv_filekey, and posts a base-versus-PR snapshot diff as the job summary. The diff fails the job on any difference unless the PR carries theenv-change-intendedlabel; 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.