Skip to content

Commit 6573861

Browse files
efiacorCopilot
andauthored
ci: configure copilot review to reduce noise (#1064)
* ci: add copilot review config and limit reviews to PR open only - Add .github/copilot-code-review.yml with project-specific instructions: skip linter-overlap issues, generated code, vendored code, and style nits. Focus reviews on logic errors, concurrency, security, and K8s API correctness. - Add workflow to request Copilot review only on PR open (not on every push). Manual re-request still available via GitHub UI. - Requires disabling automatic Copilot reviews in repo settings. Signed-off-by: Fiachra Corcoran <fiachra.corcoran@est.tech> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Fiachra Corcoran <fiachra.corcoran@est.tech> * Address review comments Signed-off-by: Fiachra Corcoran <fiachra.corcoran@est.tech> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Fiachra Corcoran <fiachra.corcoran@est.tech> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Fiachra Corcoran <fiachra.corcoran@est.tech> --------- Signed-off-by: Fiachra Corcoran <fiachra.corcoran@est.tech> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent ada25cf commit 6573861

2 files changed

Lines changed: 128 additions & 0 deletions

File tree

.github/copilot-code-review.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Copyright 2026 The kpt Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# Copilot code review configuration for Porch
16+
# Porch is a Kubernetes package orchestration system using controller-runtime.
17+
18+
review:
19+
instructions:
20+
# Linter overlap — these are already enforced by golangci-lint in CI
21+
- "Do not comment on issues caught by: errcheck, govet, ineffassign, staticcheck, unused, nosprintfhostport, gofmt"
22+
- "Do not comment on import ordering or formatting"
23+
- "Do not flag SA1019 deprecation warnings on client.Apply — this is intentionally suppressed"
24+
25+
# Style — established project conventions, not up for debate
26+
- "Do not comment on error wrapping style (this project uses fmt.Errorf with %w consistently)"
27+
- "Do not suggest renaming variables, functions, or packages"
28+
- "Do not suggest extracting single-use helper functions"
29+
- "Do not suggest adding comments to exported symbols unless the function is non-obvious"
30+
31+
# Architecture context
32+
- "This project uses Kubernetes controller-runtime with Server-Side Apply (SSA)"
33+
- "Controllers use distinct field managers and ForceOwnership — do not flag this as a concern"
34+
- "Reconcile functions returning (*ctrl.Result, error) where nil result means continue is an intentional pattern"
35+
- "Errors intentionally not returned to controller-runtime (returned as nil) is a deliberate choice to avoid requeue backoff — do not flag this"
36+
- "log.FromContext(ctx) with V-levels is the logging convention — do not suggest alternatives"
37+
38+
# What to actually review
39+
- "Focus on: logic errors, race conditions, resource leaks, deadlocks, nil pointer dereferences"
40+
- "Flag: missing context cancellation checks, unbounded goroutines, missing error handling in deferred Close calls"
41+
- "Flag: incorrect SSA field manager usage, writing fields owned by another controller"
42+
- "Flag: security issues (credential leaks, injection, TOCTOU)"
43+
- "Flag: incorrect Kubernetes API usage (wrong GVK, missing RBAC, broken owner references)"
44+
45+
path_instructions:
46+
- path: "api/generated/**"
47+
instructions: "Do not review — generated by k8s code-generator"
48+
- path: "**/zz_generated*"
49+
instructions: "Do not review — generated by controller-tools"
50+
- path: "test/mockery/mocks/**"
51+
instructions: "Do not review — generated by mockery"
52+
- path: "third_party/**"
53+
instructions: "Do not review — vendored upstream code"
54+
- path: "go.sum"
55+
instructions: "Do not review"
56+
- path: "go.mod"
57+
instructions: "Only flag if a dependency looks suspicious or has a known CVE"
58+
- path: "docs/**"
59+
instructions: "Only flag factual errors or broken links. Do not comment on grammar or style"
60+
- path: "**/*_test.go"
61+
instructions: "Focus on correctness, flakiness risks, and missing edge case coverage. Do not suggest style changes. testify (assert/require/mock) and Ginkgo/Gomega are the test frameworks. Suggest using testify assertions or Ginkgo/Gomega matchers instead of raw t.Errorf/t.Fatalf"
62+
- path: "test/e2e/**"
63+
instructions: "Focus on test reliability and resource cleanup. Do not suggest refactoring test helpers"
64+
- path: "test/**"
65+
instructions: "Only flag correctness/security issues; avoid style/linter-overlap feedback. Note: golangci-lint excludes test/ from CI linting."
66+
- path: ".github/**"
67+
instructions: "Focus on security (pinned actions, minimal permissions, injection risks). Do not suggest cosmetic changes"
68+
- path: "deployments/**"
69+
instructions: "Focus on correctness of RBAC, resource limits, and security context. Do not comment on YAML style"
70+
- path: "examples/**"
71+
instructions: "Do not review — tutorial/example configs excluded from CI linting"
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Copyright 2026 The kpt Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# Request Copilot review when a PR is opened, reopened, or marked ready for review (non-draft).
16+
# Further reviews can be requested manually via the GitHub UI.
17+
#
18+
# Prerequisite: Disable automatic Copilot code review in repo settings
19+
# (Settings → Copilot → Code review → Disable automatic reviews)
20+
21+
name: Copilot Code Review
22+
23+
on:
24+
pull_request:
25+
types: [opened, ready_for_review, reopened]
26+
27+
permissions: {}
28+
29+
jobs:
30+
request-copilot-review:
31+
if: github.event.pull_request.draft == false && github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name
32+
runs-on: ubuntu-latest
33+
permissions:
34+
pull-requests: write
35+
steps:
36+
- name: Request Copilot review
37+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
38+
with:
39+
script: |
40+
const prNumber = context.payload.pull_request.number;
41+
core.info(`Requesting Copilot review for PR #${prNumber}`);
42+
43+
try {
44+
await github.rest.pulls.requestReviewers({
45+
owner: context.repo.owner,
46+
repo: context.repo.repo,
47+
pull_number: prNumber,
48+
reviewers: ['copilot-pull-request-reviewer[bot]'],
49+
});
50+
core.info(`✅ Copilot review requested for PR #${prNumber}`);
51+
} catch (error) {
52+
if (error.status === 422) {
53+
core.info(`Copilot review already requested or cannot be requested: ${error.message}`);
54+
} else {
55+
core.warning(`Could not request Copilot review: ${error.message}`);
56+
}
57+
}

0 commit comments

Comments
 (0)