[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'
This commit is contained in:
Ammar Askar 2019-08-12 12:25:22 -04:00 committed by Abhishek Arya
parent e4c5f42a7b
commit 8776ec2327
7 changed files with 47 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@ -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>

After

Width:  |  Height:  |  Size: 960 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

@ -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>

After

Width:  |  Height:  |  Size: 983 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

@ -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>

After

Width:  |  Height:  |  Size: 975 B

View File

@ -20,6 +20,7 @@ import build_project
STATUS_BUCKET = 'oss-fuzz-build-logs' STATUS_BUCKET = 'oss-fuzz-build-logs'
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
BADGE_DIR = 'badges/'
RETRY_COUNT = 3 RETRY_COUNT = 3
RETRY_WAIT = 5 RETRY_WAIT = 5
MAX_BUILD_RESULTS = 2000 MAX_BUILD_RESULTS = 2000
@ -173,6 +174,45 @@ def update_build_status(
upload_status(successes, failures, status_filename) 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(): def main():
if len(sys.argv) != 2: if len(sys.argv) != 2:
usage() usage()
@ -190,6 +230,10 @@ def main():
build_and_run_coverage.COVERAGE_BUILD_TAG, build_and_run_coverage.COVERAGE_BUILD_TAG,
status_filename='status-coverage.json') 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__': if __name__ == '__main__':
main() main()