Skip to content

feat(ruleset): add support for additional ruleset rule types - #639

Open
gdams wants to merge 2 commits into
eclipse-csi:mainfrom
gdams:feat/ruleset-additional-rule-types
Open

feat(ruleset): add support for additional ruleset rule types#639
gdams wants to merge 2 commits into
eclipse-csi:mainfrom
gdams:feat/ruleset-additional-rule-types

Conversation

@gdams

@gdams gdams commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

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, with review_new_pushes and review_draft_pull_requests options.

Pattern rules

Modelled via a shared PatternSettings embedded model (operator, pattern, name, negate):

  • commit_message_pattern
  • commit_author_email_pattern
  • committer_email_pattern
  • branch_name_pattern
  • tag_name_pattern

Push restriction rules

Simple list/int fields on the Ruleset model:

  • file_path_restriction (restricted_file_paths)
  • max_file_path_length
  • file_extension_restriction (restricted_file_extensions)
  • max_file_size

CI / security rules

  • code_scanning: required code scanning tools with configurable security/alert thresholds (CodeScanningSettings). Encoded as tool:security_alerts_threshold:alerts_threshold.
  • workflows: required workflows with do_not_enforce_on_create (WorkflowsSettings). Encoded as repository_id:path@ref.

Changes

  • otterdog/models/ruleset.py — new embedded model classes, new Ruleset fields, updated validate, 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 — new newCopilotReview(), newPattern(), newCodeScanning(), newWorkflows() helpers and exports; new fields on newRepoRuleset.
  • 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 passed
  • poetry run pytest tests/ → 250 passed, 2 skipped, 0 failures

gdams added 2 commits April 21, 2026 13:07
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
@mbarbero

Copy link
Copy Markdown
Contributor

Thank you, @gdams, for your patience and for the numerous pull requests. We have had some team changes, and we should be able to address them in the next couple of weeks.

@sonarqubecloud

Copy link
Copy Markdown

@LittleHuba

Copy link
Copy Markdown

@mbarbero what is the current status of this PR?
We need this in S-CORE to improve our static-analysis CI workflow.

@mbarbero

Copy link
Copy Markdown
Contributor

@mbarbero what is the current status of this PR? We need this in S-CORE to improve our static-analysis CI workflow.

We don't have an ETA, but if you require a feature configuration that isn't currently supported by Otterdog, please don't hesitate to open a help desk ticket to request that the configuration be manually set by admins.

@mbarbero

mbarbero commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

cc @heurtematte

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants