Extend rulesets to cover all rule types exposed by the GitHub REST API:
- copilot_review: automatically request Copilot code review (with
review_new_pushes and review_draft_pull_requests options)
- Pattern rules: commit_message_pattern, commit_author_email_pattern,
committer_email_pattern, branch_name_pattern, tag_name_pattern
(modelled via a shared PatternSettings embedded model)
- Push restriction rules: file_path_restriction, max_file_path_length,
file_extension_restriction, max_file_size (simple list/int fields on
the Ruleset model)
- code_scanning: required code scanning tools with configurable
security/alert thresholds (CodeScanningSettings embedded model)
- workflows: required workflows with do_not_enforce_on_create
(WorkflowsSettings embedded model)
Includes updates to:
- Ruleset model (from/to provider mappings, validation, jsonnet
rendering)
- JsonnetConfig with new template function names and default config
cached properties
- Default libsonnet template (newPattern, newCodeScanning,
newWorkflows, newCopilotReview)
- Ruleset JSON schema with new embedded definitions
- Unit tests covering the new rule types
Summary
Extends otterdog rulesets to cover all rule types exposed by the GitHub REST API that were not previously supported.
New rule types
Copilot review
copilot_review: automatically request Copilot code review, withreview_new_pushesandreview_draft_pull_requestsoptions.Pattern rules
Modelled via a shared
PatternSettingsembedded model (operator, pattern, name, negate):commit_message_patterncommit_author_email_patterncommitter_email_patternbranch_name_patterntag_name_patternPush restriction rules
Simple list/int fields on the
Rulesetmodel:file_path_restriction(restricted_file_paths)max_file_path_lengthfile_extension_restriction(restricted_file_extensions)max_file_sizeCI / security rules
code_scanning: required code scanning tools with configurable security/alert thresholds (CodeScanningSettings). Encoded astool:security_alerts_threshold:alerts_threshold.workflows: required workflows withdo_not_enforce_on_create(WorkflowsSettings). Encoded asrepository_id:path@ref.Changes
otterdog/models/ruleset.py— new embedded model classes, newRulesetfields, updatedvalidate,get_mapping_from_model,get_mapping_from_provider,get_mapping_to_provider,to_jsonnet.otterdog/jsonnet.py— new template function names and cached default configs.examples/template/otterdog-defaults.libsonnet— newnewCopilotReview(),newPattern(),newCodeScanning(),newWorkflows()helpers and exports; new fields onnewRepoRuleset.otterdog/resources/schemas/ruleset.json— new properties and$defs.tests/models/test_ruleset.py— 7 new tests covering from_provider mapping for all new rule types.Testing
poetry run pytest tests/models/test_ruleset.py→ 19 passedpoetry run pytest tests/→ 250 passed, 2 skipped, 0 failures