aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Ammar Askar <aaskar@google.com>2019-08-12 12:25:22 -0400
committerGravatar Abhishek Arya <inferno@chromium.org>2019-08-12 09:25:22 -0700
commit8776ec2327d71470783666f523ab302c57848d1b (patch)
treee9656b46dfd5949092e047a1a8024d75472f2eae
parente4c5f42a7be3a8b2329bb99f5066b20f0e105262 (diff)
[infra] Publish build badges on status page (#2513)
* [infra] Publish build badges on status page * Address feedback from github PR * Change success badge to 'fuzzing' and failing badge to 'build failing'
-rw-r--r--infra/gcb/badge_images/building.pngbin0 -> 3020 bytes
-rw-r--r--infra/gcb/badge_images/building.svg1
-rw-r--r--infra/gcb/badge_images/coverage_failing.pngbin0 -> 4160 bytes
-rw-r--r--infra/gcb/badge_images/coverage_failing.svg1
-rw-r--r--infra/gcb/badge_images/failing.pngbin0 -> 3465 bytes
-rw-r--r--infra/gcb/badge_images/failing.svg1
-rwxr-xr-xinfra/gcb/builds_status.py44
7 files changed, 47 insertions, 0 deletions
diff --git a/infra/gcb/badge_images/building.png b/infra/gcb/badge_images/building.png
new file mode 100644
index 00000000..9e7e7344
--- /dev/null
+++ b/infra/gcb/badge_images/building.png
Binary files differ
diff --git a/infra/gcb/badge_images/building.svg b/infra/gcb/badge_images/building.svg
new file mode 100644
index 00000000..19f28d7f
--- /dev/null
+++ b/infra/gcb/badge_images/building.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="104" height="20"><linearGradient id="b" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="a"><rect width="104" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#a)"><path fill="#555" d="M0 0h55v20H0z"/><path fill="#4c1" d="M55 0h49v20H55z"/><path fill="url(#b)" d="M0 0h104v20H0z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="110"> <text x="285" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="450">oss-fuzz</text><text x="285" y="140" transform="scale(.1)" textLength="450">oss-fuzz</text><text x="785" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="390">fuzzing</text><text x="785" y="140" transform="scale(.1)" textLength="390">fuzzing</text></g> </svg> \ No newline at end of file
diff --git a/infra/gcb/badge_images/coverage_failing.png b/infra/gcb/badge_images/coverage_failing.png
new file mode 100644
index 00000000..85abe235
--- /dev/null
+++ b/infra/gcb/badge_images/coverage_failing.png
Binary files differ
diff --git a/infra/gcb/badge_images/coverage_failing.svg b/infra/gcb/badge_images/coverage_failing.svg
new file mode 100644
index 00000000..dc7b72e3
--- /dev/null
+++ b/infra/gcb/badge_images/coverage_failing.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="152" height="20"><linearGradient id="b" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="a"><rect width="152" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#a)"><path fill="#555" d="M0 0h55v20H0z"/><path fill="#dfb317" d="M55 0h97v20H55z"/><path fill="url(#b)" d="M0 0h152v20H0z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="110"> <text x="285" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="450">oss-fuzz</text><text x="285" y="140" transform="scale(.1)" textLength="450">oss-fuzz</text><text x="1025" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="870">coverage failing</text><text x="1025" y="140" transform="scale(.1)" textLength="870">coverage failing</text></g> </svg> \ No newline at end of file
diff --git a/infra/gcb/badge_images/failing.png b/infra/gcb/badge_images/failing.png
new file mode 100644
index 00000000..0d2bb470
--- /dev/null
+++ b/infra/gcb/badge_images/failing.png
Binary files differ
diff --git a/infra/gcb/badge_images/failing.svg b/infra/gcb/badge_images/failing.svg
new file mode 100644
index 00000000..ed0f8621
--- /dev/null
+++ b/infra/gcb/badge_images/failing.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="128" height="20"><linearGradient id="b" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="a"><rect width="128" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#a)"><path fill="#555" d="M0 0h55v20H0z"/><path fill="#e05d44" d="M55 0h73v20H55z"/><path fill="url(#b)" d="M0 0h128v20H0z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="110"> <text x="285" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="450">oss-fuzz</text><text x="285" y="140" transform="scale(.1)" textLength="450">oss-fuzz</text><text x="905" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="630">build failing</text><text x="905" y="140" transform="scale(.1)" textLength="630">build failing</text></g> </svg> \ No newline at end of file
diff --git a/infra/gcb/builds_status.py b/infra/gcb/builds_status.py
index 0b2fe15e..eb98ac16 100755
--- a/infra/gcb/builds_status.py
+++ b/infra/gcb/builds_status.py
@@ -20,6 +20,7 @@ import build_project
STATUS_BUCKET = 'oss-fuzz-build-logs'
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
+BADGE_DIR = 'badges/'
RETRY_COUNT = 3
RETRY_WAIT = 5
MAX_BUILD_RESULTS = 2000
@@ -173,6 +174,45 @@ def update_build_status(
upload_status(successes, failures, status_filename)
+def update_build_badges(builds, projects, build_tag, coverage_tag):
+ for project in projects:
+ last_build = find_last_build(builds, project, build_tag)
+ last_coverage_build = find_last_build(builds, project, coverage_tag)
+ if not last_build or not last_coverage_build:
+ continue
+
+ badge = 'building'
+ if not is_build_successful(last_coverage_build):
+ badge = 'coverage_failing'
+ if not is_build_successful(last_build):
+ badge = 'failing'
+
+ print("[badge] {}: {}".format(project, badge))
+
+ storage_client = storage.Client()
+ status_bucket = storage_client.get_bucket(STATUS_BUCKET)
+
+ # Supported image types for badges
+ image_types = {
+ 'svg': 'image/svg+xml',
+ 'png': 'image/png'
+ }
+ for extension, mime_type in image_types.items():
+ badge_name = '{badge}.{extension}'.format(
+ badge=badge, extension=extension)
+ # Retrieve the image relative to this script's location
+ badge_file = os.path.join(
+ SCRIPT_DIR, 'badge_images', image_directory, badge_name)
+
+ # The uploaded blob name should look like `badges/project.png`
+ blob_name = '{badge_dir}{project_name}.{extension}'.format(
+ badge_dir=BADGE_DIR, project_name=project,
+ extension=extension)
+
+ badge_blob = status_bucket.blob(blob_name)
+ badge_blob.upload_from_filename(badge_file, content_type=mime_type)
+
+
def main():
if len(sys.argv) != 2:
usage()
@@ -190,6 +230,10 @@ def main():
build_and_run_coverage.COVERAGE_BUILD_TAG,
status_filename='status-coverage.json')
+ update_build_badges(builds, projects,
+ build_tag=build_project.FUZZING_BUILD_TAG,
+ coverage_tag=build_and_run_coverage.COVERAGE_BUILD_TAG)
+
if __name__ == '__main__':
main()