feat(besadii): Skip builds of patchsets with no code changes

Currently Gerrit is configured to copy forward the scores of the
'Verified' label if the tree of the commit does not change (e.g. only
author information or commit message is modified).

Besadii still triggers builds for these patchsets though. With this
change it will inspect the (previously ignored) "kind" of the patchset
and skip patchsets with the same tree as their predecessor.

See Gerrit docs for the semantics of "kind":

https://gerrit-review.googlesource.com/Documentation/json.html#patchSet

Note that an argument can be made that we should do the exact opposite
- stop carrying over 'Verified' at all and always build all patchsets.

I think this depends on whether we intend to use commit metadata in CI
runs at all. Adding a few people to the review for opinions.

Change-Id: I48a96a1ad1e07d92330d84e5cfdc820a39395297
Reviewed-on: https://cl.tvl.fyi/c/depot/+/4867
Tested-by: BuildkiteCI
Reviewed-by: grfn <grfn@gws.fyi>
Reviewed-by: asmundo <asmundo@gmail.com>
Reviewed-by: sterni <sternenseemann@systemli.org>
This commit is contained in:
Vincent Ambo 2022-01-12 17:42:24 +03:00 committed by tazjin
parent 0d24efcdc9
commit ee52fbc46c

View file

@ -345,7 +345,7 @@ func buildTriggerFromPatchsetCreated(cfg *config) (*buildTrigger, error) {
var trigger buildTrigger
// Information that is only needed for parsing
var targetBranch, changeUrl, uploader string
var targetBranch, changeUrl, uploader, kind string
flag.StringVar(&trigger.project, "project", "", "Gerrit project")
flag.StringVar(&trigger.commit, "commit", "", "commit hash")
@ -354,12 +354,18 @@ func buildTriggerFromPatchsetCreated(cfg *config) (*buildTrigger, error) {
flag.StringVar(&targetBranch, "branch", "", "CL target branch")
flag.StringVar(&changeUrl, "change-url", "", "HTTPS URL of change")
flag.StringVar(&uploader, "uploader", "", "Change uploader name & email")
flag.StringVar(&kind, "kind", "", "Kind of patchset")
// patchset-created also passes various flags which we don't need.
ignoreFlags([]string{"kind", "topic", "change", "uploader-username", "change-owner", "change-owner-username"})
ignoreFlags([]string{"topic", "change", "uploader-username", "change-owner", "change-owner-username"})
flag.Parse()
// Ignore patchsets which do not contain code changes
if kind == "NO_CODE_CHANGE" || kind == "NO_CHANGE" {
return nil, nil
}
// Parse username & email
err := extractChangeUploader(uploader, &trigger)
if err != nil {