From ee52fbc46c4812921c5e68c16be2542e36d45366 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Wed, 12 Jan 2022 17:42:24 +0300 Subject: 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 Reviewed-by: asmundo Reviewed-by: sterni --- ops/besadii/main.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'ops/besadii/main.go') diff --git a/ops/besadii/main.go b/ops/besadii/main.go index 39c7084a30..c02c2fbc0d 100644 --- a/ops/besadii/main.go +++ b/ops/besadii/main.go @@ -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 { -- cgit 1.4.1