← Back to issue list

feat(go): Add `enable-check` build attribute and `go-testtags` property to run tests during build

View original Github issue

Metadata

Project
craft-parts
Number
#1494
Type
pull request
State
open
Author
Copilot
Labels
Created
Updated
Closed

Current evaluation

Adds enable-check build attribute and go-testtags property to the go plugin to run unit tests during build, with docs and tests. Review status changes_requested (2 reviewers, 26 unresolved comments); author added requested integration tests 145 days ago.

Suggested action: needs review

Reason: Review status is changes_requested from 2 reviewers with 26 unresolved comments, and the author's last action (145 days ago) was adding the integration tests @steinbro requested on 2026-03-12 (commit 3794057, test_go_enable_checks and test_go_enable_checks_failing_test), so a maintainer re-review of the follow-up is the next step. The feature is not yet in the main branch (no enable-check in go_plugin.py) and issue #1493 remains open, so the PR is still relevant rather than stale.

Impact: 45 Quick Win: 27.0 Staleness: 50 Complexity: 40 Confidence: 80

Issue body

Adds support for running unit tests as part of the Go plugin build step, along with a new `go-testtags` property for passing test-specific build tags to `go test`. ## Changes Made - **`enable-check` build attribute**: When set in `build-attributes`, the plugin appends a `go test ./...` command after `go install`, running unit tests as part of the build step. - **`go-testtags` plugin property**: A new list-of-strings property analogous to `go-buildtags`, but used specifically for `go test`. The tags passed to `go test` are the union of `go-buildtags` and `go-testtags`; `go install` continues to use only `go-buildtags`. - **`plugins.py`**: Added `"enable-check"` to `PLUGINS_BUILD_ATTRIBUTES`. - **`go_plugin.py`**: Added `supported_build_attributes()` returning `{"enable-check"}`; added `go_testtags` field to `GoPluginProperties`; updated `get_build_commands()` to compute separate tag strings for install and test. - **`go_plugin.rst`**: Added `go-testtags` key section; added `enable-check` attribute section; updated "How it works" to describe both tag lists being combined for `go test`. - **Unit tests** (`test_go_plugin.py`): Added cases for `enable-check` with no tags, with `go-buildtags` only, with `go-testtags` only, and with both combined. - **Integration tests** (`test_go.py`): Added `test_go_enable_check` (passing tests succeed) and `test_go_enable_check_failing_test` (failing tests raise `PluginBuildError` with `"go test"` confirmed in the shell trace captured in `stderr`). <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>go plugin: Add flag to run tests during build phase</issue_title> > <issue_description>### What needs to get done > > Add support to the go plugin for a `enable-checks` build attribute. When enabled, the final build command executed by the plugin should be `go test` with the proper arguments to run unit tests on the build artifact. Add a test case for the go plugin to confirm the new final command is added. Update the build attributes section of the go plugin documentation to describe the new parameter. > > ### Why it needs to get done > > Users should be able to run unit tests as part of their build without needing to specify an `override-build` script.</issue_description> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > </comments> > </details> <!-- START COPILOT CODING AGENT SUFFIX --> - Fixes canonical/craft-parts#1493 <!-- START COPILOT CODING AGENT TIPS --> --- 💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey).

Evaluation history

Date Model Scores Action Summary
qwen/qwen3.8-27b
Impact: 45
Quick Win: 27.0
Staleness: 50
Complexity: 40
Confidence: 80
needs review Adds enable-check build attribute and go-testtags property to the go plugin to run unit tests during build, with docs and tests. Review status changes_requested (2 reviewers, 26 unresolved comments); author added requested integration tests 145 days ago.
qwen/qwen3.6-35b-a3b
Staleness: 55
Complexity: 45
Confidence: 80
needs review Adds enable-check build attribute and go-testtags property to run Go unit tests during build. Currently in changes_requested state with 26 unresolved review comments.
qwen3.6-35b-a3b-mtp-q6
Staleness: 45
Complexity: 30
Confidence: 85
needs review Adds enable-check build attribute and go-testtags property to the Go plugin for running unit tests during build. Includes code changes, documentation, and tests. Currently awaiting maintainer review.
qwen3.6-35b-a3b-mtp-q6
Staleness: 50
Complexity: 45
Confidence: 85
needs review Implements enable-check build attribute and go-testtags property to run Go unit tests during the build phase. Open pull request, last activity 72 days ago, awaiting review.

Update history

No update history recorded yet.

Related work

  • Likely Fixed By: canonical/craft-parts#1493 (confidence 90%)

    PR body explicitly states 'Fixes canonical/craft-parts#1493'; issue is still open and the feature is absent from the main branch, so this PR would resolve it if merged.

Related issues

Issue Project State Summary Similarity
#1493 go plugin: Add flag to run tests during build phase craft-parts open Feature request to add an enable-checks build attribute to the go plugin so unit tests run during the build phase without an override-build script. Unlabelled, no comments or assignee, inactive ~5.7 months; feature not yet implemented.
81%
#733 Add the go-buildtags property to the go plugin snapcraft merged Merged by maintainer come-maiz, adding the go-buildtags property to the go plugin. The update modifies two files with 166 additions and 5 deletions, implementing the feature requested in LP #1609623.
71%