-
Notifications
You must be signed in to change notification settings - Fork 18k
x/build: make a bot review CLs for common mistakes (like Tricorder) #18548
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
Comments
What about lint and vet? |
Sure. I imagine we'd start with some basic things and once we have it automated, we can add more to it later. I wouldn't make lint & vet a requirement for the initial deployment. |
IIRC @josharian has been working on getting golang/go to pass vet, but it doesn't currently, and relies on an "exemption" file for places/test files that don't pass vet on purpose. |
Perhaps with
Github has various accepted formats for these (https://help.github.com/articles/closing-issues-via-commit-messages/). I assume you want to limit it to "Fixes #n", though? |
@mvdan, the two common mistakes I'm thinking of:
|
Another common mistake is using a git SHA when they should use a CL number. |
Another thing that comes to mind is gerrit/github links that should be |
I'd also like the bot to catch accidentally committing a binary,
which happened at least five times (the following list is not
comprehensive as I just looked at the top 12 largest files):
https://golang.org/cl/4287056 1179384 bytes
https://golang.org/cl/4406044 3500057 bytes
https://golang.org/cl/9560 6084208 bytes
https://golang.org/cl/19968 2243120 bytes
I also remember one time we rewrote the git history to
remove one accidentally committed binary file.
I once suggested that we change Gerrit setting to reject
binary files bigger than a certain size, but that was rejected.
If we make such a pre-check bot, we can at least make it
point out a binary file is included (and its size). This will be
a warning.
Another idea about spamming old bugs, also checks for
tiny issue numbers (say, less than 100), because people
sometimes use #1 as bulletpoints and some test output
use #X as a short "Number X", I remember runtime/pprof
tests do this.
|
On Fri, Jan 6, 2017 at 4:31 PM, Ian Lance Taylor ***@***.***> wrote:
Another common mistake is using a git SHA when they should use a CL number.
I'd like the bot to be more helpful and actually figure out the correct CL
number
for the git commit hash and suggest its use.
|
I have no memory of this and am pretty sure we have never rewritten the Git history. |
We rewrote people's memory along with the git history, to simplify matters going forward. |
On Fri, Jan 6, 2017 at 4:57 PM, Brad Fitzpatrick ***@***.***> wrote:
I also remember one time we rewrote the git history to
remove one accidentally committed binary file.
I have no memory of this and am pretty sure we have never rewritten the
Git history.
Sorry, my memory is indeed off. It's not to remove a binary file, but to
revert a bad merge.
https://groups.google.com/d/msg/golang-dev/2wkzNtLKWyI/bl3wVhNAIm4J
It is to remove these two commits:
https://golang.org/cl/5351/, commit
https://go.googlesource.com/go/+/c21f1d5ef30ff52cb42fca146a9c7161dfee5c3c
https://golang.org/cl/5353/, commit
https://go.googlesource.com/go/+/e5048a5eaabdb86156d8de1a97d32eb898560e50
|
Maybe we can add some pre-check in git-codereview? After |
@LionNatsu from the email thread:
|
@kevinburke Oh, indeed. |
I'm interested in working on this (I wrote Go Report Card https://goreportcard.com/ with @hermanschaaf which does a lot of this too). Edit: the Go Report Card reference was just to mention that I've worked on a similar problem before and could maybe borrow some code from there. |
@shawnps, the first thing to figure out is where this runs and how, and how it interacts with Gerrit. We already have one process polling Gerrit (the build coordinator's "watcher"), and if we revamp dev.golang.org that would be a second. This would be a third. I suspect we'll want to make this bot interact with the proposed dev.golang.org all-Github-and-Gerrit-in-RAM server, and then this bot could long-poll our new "Github/Gerrit Model Server" waiting for changes (new or updated CLs). But in the meantime I suppose it could run manually every N minutes. Please use https://godoc.org/golang.org/x/build/gerrit which we already use. If something's missing, modify that package as needed. You'll want to store state somewhere. It's easy to find CLs the bot's already left comments on, but the bot should probably be silent and not +1 the bug if there's nothing to say, which means you'll need to store state about which bugs you've seen and are happy about. That should probably go into Google Cloud Datastore (https://cloud.google.com/datastore/) which we already use in the Go build system (see "git grep datastore" in src/golang.org/x/build/cmd/coordinator), as opposed to files on the local filesystem. (Filesystems come and go as we destroy and recreate the world) |
@bradfitz thanks, I was just about to ask about many of the details you just listed. Taking a look at https://godoc.org/golang.org/x/build/gerrit now.
Found datastore reference here: https://github.com/golang/build/blob/master/cmd/coordinator/gce.go#L119 So this particular app (coordinator) "runs on CoreOS on Google Compute Engine and manages builds using Docker containers and/or VMs as needed" - is the suggestion that the new bot would run on GCE or GAE in a similar manner to this one? |
Yes, this would run on GCE somewhere. I would start by making it a non-package main package that you can instantiate and run. Then make a tiny tiny package main runner program for it for development and local testing. Once it's working, we can integrate that bot into something. I also imagine that some helper environment will need to be described by a Dockerfile, since you'll want things like golint and go vet available. |
Okay thanks. As a first step I'm currently trying to figure out how to grab files for a specific change on Gerrit in order to run gofmt on them. |
Click "Download" in the web UI for a hint: git fetch https://go.googlesource.com/crypto refs/changes/79/34779/8 && git cherry-pick FETCH_HEAD You can have the bot do a shallow git clone of the parent git commit, and then chrery-pick atop that. Alternatively, there's an API to get files from Gerrit at a specific revision as a tarball. See the cmd/coordinator code: func getSourceTgzFromGerrit(repo, rev string) (tgz []byte, err error) {
return getSourceTgzFromURL("gerrit", repo, rev, "https://go.googlesource.com/"+repo+"/+archive/"+rev+".tar.gz")
} |
@bradfitz thanks, I had gotten as far as getting the
(I know the I guess I can use this to get this piece: |
@bradfitz let me know if that looks like I'm on the right track, will be offline soon but I'll pick this back up in the morning. I appreciate all the feedback and help, thanks! |
Rather than do a query for "34871", you probably just want to load the detail of a single change using https://godoc.org/golang.org/x/build/gerrit#Client.GetChangeDetail |
@bradfitz any idea if there's a reason why |
IIRC, GetChangeDetail returns everything already, so there's no need to selectively say what you want? If not, we can modify that package as needed. |
@bradfitz I will dig a bit more but I think I need the current revision in order to get the tarball, and current revision only appears in ChangeInfo if you request it: https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#change-info see "current_revision": "Only set if the current revision is requested or if all revisions are requested." But maybe this is my misunderstanding of how revisions work in Gerrit. |
@bradfitz I was able to get the revision info with this patch:
without this, I've found |
CL made here for the above diff: https://go-review.googlesource.com/#/c/34922/ |
We had a long-running dup bug that I just closed, but contains discussion and links: #20648 |
This comment has been minimized.
This comment has been minimized.
CL 109361 introduced some changes which were not properly gofmt'ed. Because the CL was sent via Github no gofmt checks were performed on it (cf. #24946, #18548). Change-Id: I207065f01161044c420e272f4fd112e0a59be259 Reviewed-on: https://go-review.googlesource.com/115356 Run-TryBot: Tobias Klauser <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]>
Remove it. It has too many false positives. There are no more checkers running, but it's still worthwhile to leave so we can easily add them back in the future. Updates golang/go#18548. Change-Id: Ifbaf9a7d6cf685132587702b923a73a01a4ac419 Reviewed-on: https://go-review.googlesource.com/c/build/+/582956 Reviewed-by: Dmitri Shuralyov <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Russ Cox <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]>
Change https://go.dev/cl/582956 mentions this issue: |
Tracking bug to write a bot to review CLs for common mistakes:
And whatever else we add in the future.
(forked from email thread https://groups.google.com/forum/#!topic/golang-dev/KpHMoePhg6c)
/cc @kevinburke @rsc
The text was updated successfully, but these errors were encountered: