Repository navigation
feat: add watch to check definitions in .infrahub.yml (INFP-506) - #1585
Merged
Merged
Conversation
Check definitions now accept the same optional 'watch' block as Python
transforms and generator definitions, listing extra files and directories
the check depends on.
The JSON schema generated for .infrahub.yml marks 'watch' as required on
check definitions through the shared advisory allOf branch, so YAML language
servers warn when a check definition has no watch block. The models still
accept a check definition without watch, and 'watch: {}' or 'files: []'
does not trigger the warning.
Deploying infrahub-sdk-python with
|
| Latest commit: |
faf224b
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://9bf486e1.infrahub-sdk-python.pages.dev |
| Branch Preview URL: | https://infp-506-check-definition-wa.infrahub-sdk-python.pages.dev |
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## infrahub-develop #1585 +/- ##
====================================================
- Coverage 88.65% 88.63% -0.03%
====================================================
Files 161 161
Lines 17618 16571 -1047
Branches 2447 2224 -223
====================================================
- Hits 15620 14687 -933
+ Misses 1398 1319 -79
+ Partials 600 565 -35
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 12 files with indirect coverage changes 🚀 New features to boost your workflow:
|
polmichel
approved these changes
Dec 4, 2026
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.
Why
This prepares the
watchfield on check definitions for selective user check runs (INFP-506) in Infrahub 1.13. Repository authors can list the extra files and directories a check depends on in.infrahub.yml, in the same form they already use for Python transforms and generator definitions.Infrahub does not read this field yet. The backend part that would use it to decide which checks to run has not been built, so declaring
watchon a check definition has no effect on check runs today.Non-goals:
InfrahubCheckorinfrahub_sdk/checks.py.InfrahubWatchConfigdocstring or to theMISSING_WATCH_MESSAGEandMALFORMED_WATCH_MESSAGEtexts, which also mention transforms and regeneration. Rewording them would change the warnings for generators and transforms too..infrahub.ymlreference documentation, which is generated in the Infrahub repository.What changed
InfrahubCheckDefinitionConfighas an optionalwatchfield, defined the same way as onInfrahubGeneratorDefinitionConfig. A check definition withoutwatchstill parses, withwatchset toNone. A list such aswatch: [a, b]is rejected, as it is for generators..infrahub.ymlmarkswatchas required on check definitions, through the sameREQUIRE_WATCH_JSON_SCHEMAbranch that generators and Python transforms use. YAML language servers then show a warning in the editor when a check definition has nowatchblock. The warning is advisory: the models still accept a check definition withoutwatch, andwatch: {}orfiles: []does not trigger it.nameandfile_path.How to test
The tests cover:
watchfield on check definitions: omitted, object form, list form.watchis flagged, one withwatch: {},files: []orfiles: ["lib/"]is not.Impact & rollout
.infrahub.ymlfiles still parse. Editors that use the published JSON schema will show a new warning on check definitions without awatchblock.Checklist
.infrahub.ymlreference is generated in the Infrahub repository