diff --git a/build/includes/website.mk b/build/includes/website.mk index f152554689..09716e0207 100644 --- a/build/includes/website.mk +++ b/build/includes/website.mk @@ -109,3 +109,8 @@ test-gen-api-docs: ensure-build-image $(GEN_API_DOCS) sort $(expected_docs) > /tmp/result.sorted diff -bB /tmp/result.sorted /tmp/generated.html.sorted + +build-report: BUILD_REPORT_BUCKET ?= agones-build-reports +build-report: ensure-build-image + docker run --rm $(common_mounts) --workdir=$(mount_path) $(DOCKER_RUN_ARGS) $(build_tag) bash -c \ + "go work use build/report; go run build/report/report.go; gcloud storage cp tmp/report/* gs://$(BUILD_REPORT_BUCKET)/" diff --git a/build/report/cloudbuild.yaml b/build/report/cloudbuild.yaml new file mode 100644 index 0000000000..30459ed43a --- /dev/null +++ b/build/report/cloudbuild.yaml @@ -0,0 +1,41 @@ +# Copyright 2023 Google LLC All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# +# Google Cloud Builder -- Generate report on recently flaky builds + +steps: + +# +# Creates the initial make + docker build platform +# + +- name: "ubuntu" + args: ["bash", "-c", "echo 'FROM gcr.io/cloud-builders/docker\nRUN apt-get install make\nENTRYPOINT [\"/usr/bin/make\"]' > Dockerfile.build"] +- name: "gcr.io/cloud-builders/docker" + args: ['build', '-f', 'Dockerfile.build', '-t', 'make-docker', '.'] # we need docker and make to run everything. +- name: "make-docker" + dir: "build" + env: + - "REGISTRY=${_REGISTRY}" + args: ["pull-build-image"] # since we are past CI build, we can assume that the build image exists. + +# Run build report +- name: "make-docker" + dir: "build" + args: ["build-report"] + +substitutions: + _REGISTRY: us-docker.pkg.dev/${PROJECT_ID}/ci +tags: ["build-report"] diff --git a/build/report/report.go b/build/report/report.go new file mode 100644 index 0000000000..f9e08ec9a8 --- /dev/null +++ b/build/report/report.go @@ -0,0 +1,199 @@ +// Copyright 2019 Google LLC All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import ( + "context" + "fmt" + "html/template" + "log" + "os" + "sort" + "time" + + cloudbuild "cloud.google.com/go/cloudbuild/apiv1/v2" + cloudbuildpb "cloud.google.com/go/cloudbuild/apiv1/v2/cloudbuildpb" + "google.golang.org/api/iterator" +) + +const ( + window = time.Hour * 24 * 7 * 4 // 4 weeks + wantBuildTriggerId = "da003bb8-e9bb-4983-a556-e77fb92f17ca" + outPath = "tmp/report" + reportBucket = "agones-build-reports" + + reportTemplate = ` + + +
+ + {{ .FlakePercent }}% of {{ .Builds }} successful builds from {{ .WindowStart }} to {{ .WindowEnd }} + required at least one re-run to succeed. Examples flakes: + +Time | +Flaky Build | +
---|---|
{{ .CreateTime }} | +{{ .Id }} | +