about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-01-12T14·42+0300
committertazjin <tazjin@tvl.su>2022-01-14T17·35+0000
commitee52fbc46c4812921c5e68c16be2542e36d45366 (patch)
tree9a762aa4ac5817094fa0de438f0eb3a7e86b0f74
parent0d24efcdc9d00cf1e66e4308facfb94fbbf2dd3d (diff)
feat(besadii): Skip builds of patchsets with no code changes r/3592
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>
-rw-r--r--ops/besadii/main.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/ops/besadii/main.go b/ops/besadii/main.go
index 39c7084a3022..c02c2fbc0d0c 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 {