Skip to content

Make Go review expectations explicit - #7393

Open
Warashi wants to merge 1 commit into
masterfrom
docs/go-coding-guidelines
Open

Warashi wants to merge 1 commit into
masterfrom
docs/go-coding-guidelines

Conversation

@Warashi

@Warashi Warashi commented Sep 19, 2026

Copy link
Copy Markdown
Member

What this PR does:

This PR adds Go coding guidelines for PipeCD contributors.
Some sections are based on analysis with Copilot, and some are my own ideas.

I'm not using English as usual, so I wrote these guidelines using Copilot. Some descriptions may seem like AI-generated English, and it's right. But all of these are my own themes.

Why we need it:

Happily, we have had many contributors recently. So it's helpful to provide project-specific guidance on Go coding.

Which issue(s) this PR fixes:

Fixes #

Does this PR introduce a user-facing change?: No

  • How are users affected by this change:
  • Is this breaking change:
  • How to migrate (if breaking change):

Screenshots/Videos (for documentation or website changes):
Attach a screenshot or screen recording if your PR modifies any files under docs/ or any .md/.mdx files. Run the site locally using make run/site and verify your changes before submitting.

Screenshot 2026-09-19 at 18-24-21 Go Coding Guidelines PipeCD

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Shinnosuke Sawada-Dazai <3600530+Warashi@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings September 19, 2026 09:14
@netlify

netlify Bot commented Sep 19, 2026

Copy link
Copy Markdown

Deploy Preview for pipecd-site ready!

Name Link
🔨 Latest commit 3c6174a
🔍 Latest deploy log https://app.netlify.com/projects/pipecd-site/deploys/6aae52696e558c0008e2a045
😎 Deploy Preview https://deploy-preview-7393--pipecd-site.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@Warashi Warashi changed the title docs: Make Go review expectations explicit Make Go review expectations explicit Sep 19, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

No unresolved review issues were identified.

Review effort: Lite
Findings: None

What changed in this PR

Adds explicit PipeCD Go coding and review guidance, linked from contributor documentation.

Changes:

  • Adds comprehensive Go coding guidelines.
  • Links the guidelines from the versioned contributor guide and CONTRIBUTING.md.
File Description
docs/​content/​en/​docs-v1.0.x/​contribution-guidelines/​go-coding-guidelines.md New Go coding guidance
docs/​content/​en/​docs-v1.0.x/​contribution-guidelines/​contributing-to-pipecd.md Links to Go guidelines
CONTRIBUTING.md Links to Go guidelines

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@codecov

codecov Bot commented Sep 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 29.81%. Comparing base (d1ee168) to head (3c6174a).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #7393   +/-   ##
=======================================
  Coverage   29.81%   29.81%           
=======================================
  Files         601      601           
  Lines       64453    64453           
=======================================
  Hits        19214    19214           
  Misses      43746    43746           
  Partials     1493     1493           
Flag Coverage Δ
. 23.61% <ø> (ø)
.-pkg-app-pipedv1-plugin-analysis 32.16% <ø> (ø)
.-pkg-app-pipedv1-plugin-ecs 33.64% <ø> (ø)
.-pkg-app-pipedv1-plugin-kubernetes 58.98% <ø> (ø)
.-pkg-app-pipedv1-plugin-kubernetes_multicluster 59.62% <ø> (ø)
.-pkg-app-pipedv1-plugin-scriptrun 54.83% <ø> (ø)
.-pkg-app-pipedv1-plugin-terraform 38.46% <ø> (ø)
.-pkg-app-pipedv1-plugin-wait 33.04% <ø> (ø)
.-pkg-app-pipedv1-plugin-waitapproval 52.71% <ø> (ø)
.-pkg-plugin-sdk 50.12% <ø> (ø)
.-tool-actions-gh-release 19.23% <ø> (ø)
.-tool-actions-plan-preview 25.51% <ø> (ø)
.-tool-codegen-protoc-gen-auth 0.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Warashi Warashi left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I wrote comments around my proposal for coding guidelines; these were also written with AI support. All thoughts are my own, but the representation is AI-supported.

PipeCD-specific guidance for writing and reviewing Go code.
---

These guidelines aim to make everyday coding decisions explicit so

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The file is written in its intended post-merge form. It documents
existing practices and proposes explicit defaults where those
practices differ; it is not a claim that every rule is already agreed
upon or consistently implemented. I have kept the proposal rationale
in review comments so it will not become part of the published guide.

The goal is to reduce repeated style discussions and focus reviews on
behavior. General Go guidance is linked by topic rather than copied.
The scope is new and changed code, not a repository-wide cleanup.
Implementation changes and additional lint rules are separate work.

returns successfully, the SDK should check whether a response is
present when the contract requires one.

Return `codes.Internal` for a nil response that the contract does not

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I propose making response presence an explicit SDK contract and
checking it at the SDK boundary. An unexpected nil response should be
reported as a plugin contract violation, not accepted as success,
replaced with an empty response, or left to fail during conversion.

This preserves intentional nil responses: DetermineStrategy already
documents (nil, nil) and the SDK falls back to PipelineSync. The
proposal is about response presence, not general panic recovery or
validation of every response field. The implementation belongs in a
separate change.


For PipeCD configuration and plugin contracts:

- Require a configuration type's `Validate()` method through an

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I propose expressing required capabilities such as configuration
validation through interfaces or type constraints, rather than
discovering their absence at runtime. pkg/configv1.Spec already
expresses Validate this way.

This is not a ban on runtime type assertions. Initializer is an
optional plugin capability and should remain optional. Required-field
and range validation still belongs at boundaries. Apply this when
designing new or changed code, without a bulk rewrite of existing
contracts.

Comment on lines +95 to +98
Plugin errors or stage logs should provide enough information to
identify the failed operation and investigate its cause. Record the
cause even when a normal execution failure is represented by a failed
stage result rather than an RPC error.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The proposed requirement is diagnostic: retain enough information to
identify the failed operation and investigate its cause, including
failures returned as a stage result rather than an RPC error.

I am not proposing a shared error taxonomy, a new wrapper, or
preserving plugin-specific sentinel identity across RPC calls. There
is no automatic error-category-based decision in scope here. If a
concrete consumer needs that distinction, classification should be
designed for that need separately. gRPC status conversion stays at the
SDK boundary; this does not prescribe Internal for every failure.

Comment on lines +136 to +140
Choose synchronization tools according to the required behavior, not
just for visual consistency. Decide whether one failure cancels the
other operations, whether all operations must finish, and how their
results determine the overall result. Reuse an existing helper when it
provides those same semantics.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I propose choosing and reusing fan-out helpers by their failure
semantics, not by a preference for one synchronization primitive.

For example, kubernetes_multicluster's runOnTargets cancels the shared
context on failure and reports overall failure if any target fails.
Its rollback path waits for every target and currently reports
success if at least one result is not StageStatusFailure. Replacing
one with the other would change behavior. This guideline preserves
that distinction; it does not endorse or redesign the rollback
success criterion or require a new generic helper.


### Choose test doubles by maintenance cost

Default to a concise handwritten test double for a small interface

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I propose a small handwritten test double as the default when it is
concise, while retaining generated mocks when they already fit or
reduce maintenance cost. The decision should follow the interface and
test, not a blanket main-module-versus-plugin rule.

Independent plugins cannot import main-module test helpers, but that
does not prevent generating mocks within a plugin. This proposal does
not migrate existing tests or impose a new fake/mock naming taxonomy.

Comment on lines +228 to +230
In new table-driven tests, use `want` for an expected value and
`wantErr` for an expected error. When there are multiple expected
values, add meaning to the name, such as `wantStatus`.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I propose want/wantErr, with descriptive suffixes such as wantStatus,
as the default for new test tables. This gives reviewers a predictable
convention without claiming that existing expected/expect-style names
are incorrect.

When adding cases to an existing table, keep that table's naming.
Unrelated renames, a repository-wide migration, and a dedicated linter
are not part of this proposal.

Comment on lines +243 to +246
Within PipeCD's existing testify tests, use `require` for
prerequisites and `assert` for independent expectations. This is a
project-specific choice, not adoption of Go Test Comments'
recommendation to avoid assertion libraries.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I propose using require when failure invalidates later checks, and
assert for independent expectations. The deciding factor is whether
the test can meaningfully continue, not whether the assertion happens
to inspect an error.

For example, checking an error before calling err.Error() is a
prerequisite. Blanket require-error enforcement would miss this
distinction, so it is not part of the proposal. References to Go Test
Comments cover continuation, not its recommendation against
assertion libraries.

@Warashi
Warashi marked this pull request as ready for review September 19, 2026 09:38
@Warashi
Warashi requested review from a team as code owners September 19, 2026 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants