Skip to content

feat(rulesets): add automatic Copilot code review for gitflow develop branch - #60

Merged
JacobPEvans-personal merged 2 commits into
mainfrom
feat/gitflow-copilot-review
Jul 17, 2026
Merged

feat(rulesets): add automatic Copilot code review for gitflow develop branch#60
JacobPEvans-personal merged 2 commits into
mainfrom
feat/gitflow-copilot-review

Conversation

@JacobPEvans-personal

Copy link
Copy Markdown
Member

Summary

  • Adds github_organization_ruleset.org_gitflow_copilot_review, scoped to the develop branch on gitflow-tagged repos only (main on gitflow repos is release-only and low-volume, so it's excluded).
  • Reuses the existing gitflow custom property (gitflow.tf) and the same repository_property scoping pattern as org_gitflow_base/org_gitflow_main/org_gitflow_develop — no new tagging mechanism.
  • copilot_code_review rule block already supported by the locked provider version (integrations/github 6.13.0, feature shipped in 6.10.0) — no provider bump needed.
  • review_on_push = false so Copilot reviews once per PR instead of on every push.

Cost impact

Not free. Per GitHub's billing docs, each Copilot code review incurs two simultaneous charges:

  • Actions minutes: $0. All 9 current gitflow repos are public, which is exempt from Actions-minute charges (independent of the AI-credit cost below).
  • AI credits: ~$0.52/review. Copilot code review consumes 13 premium requests per review; at the standard $0.04/request overage rate that's ~$0.52. The org (dryvist) currently has 0 assigned Copilot seats (gh api orgs/dryvist/copilot/billing), so there's no pooled included allowance — usage bills directly to the org.
  • Scope is intentionally gitflow-only (9 repos) and develop-only (not the full 32-repo public fleet, not main) to bound this exposure. review_on_push = false caps it at ~1 review per PR regardless of push count.

Test plan

  • tofu fmt -check -diff — clean
  • tofu init -backend=false && tofu validate — success, confirms the copilot_code_review block matches the provider schema
  • tofu plan on Terrakube — expect exactly 1 to add, 0 to change, 0 to destroy
  • tofu apply
  • Post-apply: confirm the live ruleset via gh api orgs/dryvist/rulesets and confirm a gitflow repo's develop branch shows copilot_code_review in effective rules, main does not
  • Open a real PR against a gitflow repo's develop and confirm Copilot is requested as reviewer once, not on subsequent pushes

Copilot AI review requested due to automatic review settings July 17, 2026 01:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an org-level GitHub ruleset to automatically request Copilot code review for PRs targeting the develop branch, scoped only to repositories opted into the existing gitflow custom property. This aligns with the repo’s governance-as-code approach by centrally managing a targeted review automation rule via Terraform.

Changes:

  • Introduces github_organization_ruleset.org_gitflow_copilot_review for refs/heads/develop on gitflow=true repositories.
  • Adds org_gitflow_copilot_review_enforcement variable to control enforcement mode for the new ruleset.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
variables.tf Adds enforcement variable + documentation for the new gitflow Copilot review ruleset.
rulesets.tf Defines the new organization ruleset that enables Copilot code review for develop on gitflow-tagged repos.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread variables.tf Outdated
Comment thread rulesets.tf Outdated
… branch

Adds org-gitflow-copilot-review, scoped to the develop branch on
gitflow-tagged repos only (main is release-only, low-volume). Reuses the
existing gitflow custom property; no new tagging mechanism. review_on_push
is false to cap AI-credit spend at ~1 review per PR.
Per review, the ruleset comment and variable description hard-coded
org-specific, time-sensitive billing facts (premium-request count, dollar
rate, current seat position, current repo visibility). Those rot in place
and contradict the repo convention that code stays org-agnostic and must
clone cleanly into another org.

Keep the durable rationale -- why develop-only, why review_on_push = false,
and that this ruleset bills per review unlike the free native ones. The
point-in-time figures stay in the PR body, which is where a dated record
belongs.
@JacobPEvans-personal
JacobPEvans-personal force-pushed the feat/gitflow-copilot-review branch from f97b6d5 to 0dd5f3b Compare July 17, 2026 03:34
@JacobPEvans-personal
JacobPEvans-personal merged commit a2fed46 into main Jul 17, 2026
6 checks passed
JacobPEvans-personal added a commit that referenced this pull request Jul 17, 2026
…#67)

The Copilot review ruleset from #60 was scoped via the gitflow custom
property -- all 9 gitflow-tagged repos, and it grows automatically as
more repos opt into gitflow. That ruleset was never applied (tofu apply
was left as an operator step and never run), but the org has already
exhausted its Copilot review capacity from unrelated usage. With 0
assigned Copilot seats, every review bills AI credits directly with no
pooled allowance -- property-based scoping is the wrong shape for a
budget that's already tight.

Replace it with an explicit (branch, repo-list) target model, mirroring
merge-gate.tf's existing for_each-over-buckets pattern rather than
inventing a new one. Starting scope: just ansible-proxmox-apps on
develop, in the new config/copilot-review.yml. Growing the pilot is a
one-line YAML edit, never a broader property match.

Since nothing was ever applied, this is a clean replacement: no import,
no moved block, no state migration. The enforcement variable is renamed
org_gitflow_copilot_review_enforcement -> org_copilot_review_enforcement
since it's no longer gitflow-tied (safe -- variables aren't in state).

Verified: tofu fmt/validate pass; tflint passes against v0.63.1 (the
version CI resolves, via the signature = "pgp" pin from #61/#64).
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.

2 participants