feat: stevedore-release-scope hook, and make python hooks actually installable - #4
Merged
Merged
Conversation
`language: python` makes pre-commit pip-install this repo and then run the hook's `entry` as a command, so a repo-relative path entry can never resolve. `service-yaml-check` shipped with `entry: hooks/service-yaml-check.py` and no build definition, so every consumer's install failed with "Directory '.' is not installable" — the hook has never run anywhere. Add a pyproject.toml that packages the hooks as `pinpredict_hooks`, move the module into the package, and point the hook at the console script. The `additional_dependencies: [pyyaml]` pin goes away because the package now declares PyYAML as a real dependency.
…uild contract
Onboarding or retiring a service must not silently make every image in the
stevedore catalog re-release. The hook checks the three surfaces where that
widening happens:
- a named service is an image id in .stevedore.yaml and has a sibling chart
whose Chart.yaml name matches, so a manual `services: <id>` dispatch stays
resolvable on both release paths;
- docker-release and chart-release receive the same `only:` selector, so a
manual dispatch can never release a different set of images than charts;
- change_detection.shared_paths carries the explicit all-image contract
signal and not the paths every onboarding touches anyway (Dockerfile,
.dockerignore, the solution file).
Every assertion is opt-in via args, so a repo missing a surface skips it
rather than failing, and a repo with no .stevedore.yaml is a clean no-op. All
violations are collected and reported in one run instead of failing on the
first, so a single `pre-commit run` shows the whole picture.
The repo had no CI and no pre-commit config of its own — nothing exercised the `language: python` install path, which is exactly how `service-yaml-check` stayed uninstallable without anyone noticing. Add a tests job across the supported python range, a `hook-install` job that pip-installs the package and `try-repo`s each hook against a fixture consumer, and a .pre-commit-config.yaml so the repo dogfoods its own gate (unit tests, whitespace/EOF/merge-conflict/yaml checks, yamllint, gitleaks).
Add stevedore-release-scope (with its flag reference and the note that the manual-dispatch selector expression is not uniform across the org) and backfill check-go-version-sync, which landed without a table row. Record the repository layout and the packaging rule that Python hooks must be console scripts, so the next hook does not repeat the service-yaml-check install failure. Bump the documented rev to v0.3.0.
The fixture's .platform/services/oms.yaml carried only a name, so service-yaml-check correctly failed on the missing repositories block and took the hook-install job red. That job asserts each hook installs and runs, so the fixture has to satisfy the checks the hook enforces.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds the shared
stevedore-release-scopehook, and fixes the packaging bug that meant nolanguage: pythonhook in this repo has ever run.Part of trading#3362 — moving static CI guards to pre-commit. This PR must merge and be tagged
v0.3.0before the trading side lands: trading's config pinsrev: v0.3.0, and pre-commit resolves all repos before running any hook, so until the tag exists trading's hooks cannot run locally at all.service-yaml-checkwas never runnablelanguage: pythonmakes pre-commit pip-install this repo and run the hook'sentryas a command.service-yaml-checkshipped withentry: hooks/service-yaml-check.pyand the repo had no build definition, so every consumer's install failed withDirectory '.' is not installable. Nothing exercised the install path, so it went unnoticed.Fixed by adding a
pyproject.tomlthat packages the hooks aspinpredict_hookswith console-script entry points, moving the module into the package, and pointing the hook at the script name. Theadditional_dependencies: ["pyyaml>=6"]pin goes away — the package declares PyYAML for real.stevedore-release-scopeAsserts that onboarding or retiring a service does not silently widen the image build contract so that every image in the catalog re-releases. Three surfaces:
.stevedore.yamland has a sibling chart whoseChart.yamlname matches, keeping a manualservices: <id>dispatch resolvable on both release paths;docker-releaseandchart-releasereceive the sameonly:selector, so a manual dispatch can never release a different set of images than charts;change_detection.shared_pathscarries the explicit all-image contract signal and not the paths every onboarding touches anyway (Dockerfile,.dockerignore,*.sln).Every assertion is opt-in via args, so a repo missing a surface skips it instead of failing, and a repo with no
.stevedore.yamlis a clean no-op. All violations are collected and reported in one run rather than failing on the first.The manual-dispatch selector expression is deliberately not uniform across the org — most repos map
services: allto an empty selector,tradingmaps it toallon purpose — so--expect-selectoris opt-in per repo. The docker/chart consistency check runs either way.Guardrails so this doesn't recur
.github/workflows/ci.yml— unit tests on 3.9 and 3.13, plus ahook-installjob that pip-installs the package, resolves each console script, andpre-commit try-repos every hook against a fixture consumer. That job is the direct regression guard for the failure above..pre-commit-config.yaml— the repo now dogfoods its own gate, including the unit tests. A hook whose tests only run in CI is exactly howservice-yaml-checkstayed broken.check-go-version-syncrow that landed without one.Verification
python -m unittest discover -s tests— 15 tests, green.pre-commit run --all-files— all hooks pass.