Skip to content

Configure Copilot Code Review for the provider repo#3425

Open
robert-crandall wants to merge 11 commits into
mainfrom
robert-crandall/copilot/open-pr-request
Open

Configure Copilot Code Review for the provider repo#3425
robert-crandall wants to merge 11 commits into
mainfrom
robert-crandall/copilot/open-pr-request

Conversation

@robert-crandall
Copy link
Copy Markdown

@robert-crandall robert-crandall commented May 13, 2026

This PR adds Copilot instructions to this repo.


Before the change?

  • The repo had no .github/copilot-instructions.md and no path-scoped .github/instructions/*.md files, so Copilot Code Review (CCR) ran with no project-specific guidance. That meant a lot of churn on PRs: low-value nits, suggestions based on older Go toolchains, and missing context about provider-specific conventions (notably the intentional "no read-after-write" pattern, see [MAINT]: Remove read call from create/update #2892).

After the change?

  • Added .github/copilot-instructions.md with the repo-wide review policy:
    • Go 1.24 toolchain anchor so CCR doesn't suggest pre-1.22 loop-variable shadowing, rewrite range over int, or flag generics/min/max/clear/slices/maps as unknown.
    • Severity and nit policy: only HIGH and MEDIUM findings are reported. No LOW, no style/formatting/naming/comment-wording feedback (those belong to linters and human reviewers).
    • Carve-outs for things that always matter even if they look like nits: Sensitive: true on secret-bearing attributes, schema Description, ValidateFunc/ValidateDiagFunc on bounded inputs, examples for new resources, docs for schema changes, import ID format.
    • Repo-specific rule: do not flag missing read-after-write in create/update; that is intentional ([MAINT]: Remove read call from create/update #2892).
  • Added four path-scoped instruction files under .github/instructions/:
    • schema-and-state.instructions.md — applies to github/**/*.go; covers schema/state compatibility, CRUD behavior, API safety.
    • tests.instructions.md — applies to github/**/*_test.go; coverage expectations and test structure.
    • examples.instructions.md — applies to examples/**; standard module layout, no nested provider blocks, sensitive variable handling.
    • docs.instructions.md — applies to website/**; keeping docs in sync with schema, documenting import IDs and permission scopes.

I think this should noticeably cut the contributor friction CCR has been generating, especially around Go-version false positives and stylistic nits. If something turns out to be too restrictive (or not restrictive enough), the instruction files are easy to iterate on.

Pull request checklist

  • Schema migrations have been created if needed (example)
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)

Docs/tests checkboxes left unchecked: this PR only touches .github/ config for CCR. No provider code, no schema, no user-facing docs are affected.

Does this introduce a breaking change?

  • Yes
  • No

@github-actions
Copy link
Copy Markdown

👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

@robert-crandall robert-crandall requested a review from Copilot May 13, 2026 19:10
@robert-crandall robert-crandall marked this pull request as ready for review May 13, 2026 19:11
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds repository-wide and path-scoped Copilot Code Review (CCR) instruction files to align automated review feedback with this provider’s conventions (notably Go 1.24 toolchain assumptions and the intentional “no read-after-write” pattern from #2892), reducing low-value churn on PRs.

Changes:

  • Added repo-wide CCR guidance in .github/copilot-instructions.md (toolchain anchors, severity policy, provider-specific review priorities).
  • Added path-scoped CCR instruction files for provider Go code, tests, examples, and website docs under .github/instructions/.
Show a summary per file
File Description
.github/copilot-instructions.md Defines repo-wide CCR policy (Go/tooling context, severity rules, provider-specific review checklist).
.github/instructions/schema-and-state.instructions.md Path-scoped guidance for github/**/*.go focusing on schema/state compatibility, CRUD behavior, and API safety.
.github/instructions/tests.instructions.md Path-scoped guidance for github/**/*_test.go covering expectations for test updates and acceptance testing.
.github/instructions/examples.instructions.md Path-scoped guidance for examples/** enforcing example structure, provider config rules, and sensitive handling.
.github/instructions/docs.instructions.md Path-scoped guidance for website/** ensuring docs stay in sync with schema, imports, and permissions.

Copilot's findings

Tip

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

  • Files reviewed: 5/5 changed files
  • Comments generated: 0

Copy link
Copy Markdown
Collaborator

@deiga deiga left a comment

Choose a reason for hiding this comment

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

This is looking really good!

Comment thread .github/instructions/docs.instructions.md Outdated
Comment thread .github/instructions/schema-and-state.instructions.md Outdated
Comment thread .github/instructions/schema-and-state.instructions.md
Comment thread .github/instructions/schema-and-state.instructions.md Outdated
Comment thread .github/instructions/schema-and-state.instructions.md
Comment thread .github/copilot-instructions.md Outdated
Comment thread .github/copilot-instructions.md Outdated
Comment thread .github/copilot-instructions.md Outdated
Comment thread .github/copilot-instructions.md Outdated
Comment thread .github/copilot-instructions.md Outdated
- Correct Go version anchor: 1.24 -> 1.26 (matches go.mod).
- Drop ValidateFunc everywhere; ValidateDiagFunc only (ValidateFunc is
  deprecated and not allowed in this repo).
- Rewrite docs.instructions.md to target templates/** instead of the
  no-longer-existing website/**. Docs under docs/** are auto-generated;
  edits go in templates/, examples/, or resource Description fields.
- Replace remaining website/ references in copilot-instructions.md with
  docs/ and templates/.
- Add repository-rename convention to schema-and-state.instructions.md:
  attribute must be 'repository' (not ForceNew), plus computed
  'repository_id', plus CustomizeDiff: diffRepository.
- Add Delete 404 handling: treat as success, not error.
- Require *Context CRUD variants and diag.Diagnostics on all new
  resources.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@robert-crandall
Copy link
Copy Markdown
Author

Thanks for the review @deiga! Addressed all 11 comments in 96bacb6:

.github/copilot-instructions.md

  • Go version anchor 1.24 -> 1.26 (it really is 1.26 in go.mod; I was looking at an older checkout).
  • Dropped ValidateFunc everywhere (deprecated, not allowed in this repo). ValidateDiagFunc only.
  • website/ references -> docs/ and templates/.

.github/instructions/schema-and-state.instructions.md

  • Added a new "Repository as a Required Argument" section covering the rename-safe pattern: attribute named repository (not ForceNew), computed repository_id, CustomizeDiff: diffRepository. Pointed at customdiff.All(...) for resources that already chain a CustomizeDiff.
  • Delete now explicitly treats 404 as success, separate from the Read-404-removes-from-state rule.
  • All CRUD funcs (including importer StateContext) must use the *Context variants and return diag.Diagnostics.
  • Dropped ValidateFunc; ValidateDiagFunc only.

.github/instructions/docs.instructions.md

  • Rewrote against reality: website/** doesn't exist, docs/** is auto-generated and is reverted by a CI workflow if touched manually. applyTo now targets templates/**. The file explains that edits belong in templates/, examples/, or resource Description fields, and flags any manual docs/** edit as HIGH.

Let me know if any of the framing on the repository-rename pattern needs tweaking; that one was new to me and I leaned on util_diff.go plus the existing CustomizeDiff: diffRepository callsites for the convention.

@deiga
Copy link
Copy Markdown
Collaborator

deiga commented May 13, 2026

The new changes cover pretty much everything I noticed! Thanks @robert-crandall

I just remembered that it could be useful to include mention that we now use https://pkg.go.dev/github.com/hashicorp/terraform-plugin-testing and it's conventions should be followed for any changes or additions in tests.

Add a 'terraform-plugin-testing Conventions' section to
.github/instructions/tests.instructions.md covering:

- Prefer ConfigStateChecks over the legacy Check /
  ComposeTestCheckFunc pattern.
- Use ValueComparers (compare.ValuesSame / compare.ValuesDiffer) for
  cross-step value comparisons instead of custom pointer structs.
- Don't flag legacy patterns in unmodified tests; only in new or
  substantially modified ones.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@robert-crandall
Copy link
Copy Markdown
Author

The new changes cover pretty much everything I noticed! Thanks @robert-crandall

I just remembered that it could be useful to include mention that we now use https://pkg.go.dev/github.com/hashicorp/terraform-plugin-testing and it's conventions should be followed for any changes or additions in tests.

Good call! Added a terraform-plugin-testing Conventions section to .github/instructions/tests.instructions.md in b415e8f:

@stevehipwell
Copy link
Copy Markdown
Collaborator

@robert-crandall how about https://awesome-copilot.github.com/instructions/#file=instructions%2Fgo.instructions.md for the Go code? I have some customizations to suggest op top of that but it's a good starting point for generic Go code.

Incorporates the upstream Go instructions from
https://github.com/github/awesome-copilot/blob/main/instructions/go.instructions.md
as a path-scoped instructions file (applyTo: **/*.go,**/go.mod,**/go.sum).

A preamble subordinates the Go guidance to the repo's existing severity
policy (HIGH/MEDIUM only, no LOW or nits) and notes the Go-version
anchors in copilot-instructions.md plus the no-read-after-write
exception, so CCR doesn't suddenly start surfacing style nits or fight
provider-specific conventions.

The main copilot-instructions.md now lists every path-scoped file so
the set is discoverable.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@robert-crandall
Copy link
Copy Markdown
Author

@robert-crandall how about https://awesome-copilot.github.com/instructions/#file=instructions%2Fgo.instructions.md for the Go code? I have some customizations to suggest op top of that but it's a good starting point for generic Go code.

Good idea! Done in 73cda9b

@robert-crandall robert-crandall requested a review from deiga May 15, 2026 18:20
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.

4 participants