-
Notifications
You must be signed in to change notification settings - Fork 17.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
doc: introduce a page for CI best practices #42119
Comments
The reason I want this to be a doc on the main site or the main repo is two-fold: so that it's code reviewed (so the wiki doesn't work), and so that it can be maintained and updated over time (so a blog post doesn't work). |
CC @stevetraut |
Friendly bump - who should I get the green light from for this document? I think the freeze is probably the best time to work on docs, so I'd like to start writing this doc before the end of the year. If no green light is needed I can just start writing and send a CL, but I'd rather not do that if the decision will likely be "we don't want this doc in the website" :) |
Our tech writer @stevetraut would be the best person to coordinate with. He's in the process of writing a programmer's guide to Go with many different topics. I think CI best practices would fit into that nicely. |
Sorry for the late response, folks. @mvdan Thanks for the idea! I think it could be useful content. I'm not sure it's within the "programming with Go" focus that the programmer's guide Jay mentioned has, but content aimed at team development would be useful. Currently, though, the guide is still taking shape and we're not sure yet what's in and what's out. May I suggest that you add it to the wiki? That would get it in front of folks right away. And I'm sure I'll be collecting other content and ideas from the wiki along the way, and may add a topic on CI. |
Thanks for the response. I honestly don't think the wiki is the best place, because it's not code-reviewed and anyone can edit it, so it's not a good place to document best practices. That is the reason why I opened #34038 last year, though unfortunately the process is taking a long time. That's why I was hoping this new document could be added directly to a git repository or the main site. I could always start writing it while we decide where it goes, but I still think it has relatively less value (and can't be properly maintained) if it ends up in the wiki. |
@mvdan, you're right that the wiki isn't the right long-term place, and we agree. But we have limited attention, and right now this specific page is not at the top of our list. We don't even have the framework set up for where the page would properly go. So if you want to publish something now, the wiki is still the best place. Long term, we'll have a better answer. |
Unfortunately |
golang/go#42119 Signed-off-by: Andrew Klotz <[email protected]>
Given that we'll get |
Another interesting point is 1.17's |
Yet another idea, as a bonus: ensure that |
A question/suggestion (depending whether it's in scope or not): would this guide also provide guidance on how to work with multi-module repositories? In particular, dealing with the fact that |
Probably, yes, though I think the first version should aim to tackle the common case: a single module. Ideally all of this would be "best practices for testing a module in CI", but since most CI systems work at the VCS repository level, I think we'll need to bridge the gap a little with extra recommendations. |
Judging by Steve's Gerrit profile, it seems like he's left Google. Who is the next tech writer, or whomever I should coordinate these efforts with? I'd like to contribute documentation which is sorely needed in my opinion, like this thread and #48539, and for the past few years I haven't been able to find anyone to help make that happen. |
Another one that pops to mind: using |
Another one we figured out with @myitcv: We wanted a setup where pushes to |
Yet another idea: another command that we want to ensure results in zero changes, like |
One more idea: for monorepos with checked in
|
great to know what good practice is. I usually run go mod tidy and go mod verify as part of any PR. Also what is the effect of not keeping go.mod up to date? I recently started working with a repo where the go.mod files did not reflect reality but this appeared to do no harm. Why and when cmds like go mod tidy/verify are executed would be useful |
I have just added this item, as @myitcv correctly pointed out that https://go.dev/doc/toolchain can be a rather surprising behavior in a CI environment where one explicitly wants to test a matrix of Go versions. If an old version is unexpectedly too old or would break, we want CI to fail and alert us of that, not to automatically download a newer toolchain and silently succeed. |
I also updated the original post about the newly proposed |
Bases on input from golang/go#42119
Based on input from golang/go#42119
Most CI scripts and defaults do just the basics:
go test ./...
There are many more commands that likely make sense for a majority of projects, and some are well known, but we don't have a single place to document and maintain them well. For example:
gofmt
from a specific version of Go, e.g.test -z $(gofmt -l .)
orgofmt -l -check .
with cmd/gofmt: change -d to exit 1 if diffs exist #46289go test -race ./...
to catch data races in testsgo vet ./...
, sincego test
only runs a subset ofgo vet
go mod tidy
results in no changes ingo.mod
andgo.sum
- orgo mod tidy -check
with cmd/go: add mod tidy -diff #27005go mod verify
to ensure thatgo.sum
agrees with what's in the module cachego test -run=- -bench=. -benchtime=1x ./...
to catch stale benchmarks (see proposal: cmd/go: run benchmarks for one iteration when testing #41824)GOTOOLCHAIN=local
to ensure old versions do not automatically download and use newer toolchainsAnd potentially
staticcheck ./...
too, since it's now sort of recommended by gopls as an extension togo vet
. Though note that this should be a small set of recommendations that most projects should follow, so it shouldn't include an endless list of linters that might be interesting to some users.We should include a ready-to-use script containing all of the recommended steps, for example in POSIX Shell. We could document each step directly via script comments, meaning that the entire thing could be copy-pasted and self-documenting.
I'm happy to kickstart this work during the freeze. /cc @bcmills @jayconrod @myitcv @jadekler
The text was updated successfully, but these errors were encountered: