[infra] Update build_status to support two build types + cleanup (#1743, #1547). (#1758)

* [infra] Update build_status to support two build types + cleanup (#1743, #1547).

* Minor fixes.

* Remove default value for status_filename argument.
This commit is contained in:
Max Moroz 2018-08-27 06:46:17 -07:00 committed by GitHub
parent 4fd7dbcaf6
commit 1bc9bb0b65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 62 additions and 49 deletions

View File

@ -14,8 +14,8 @@ import googleapiclient
from googleapiclient.discovery import build as gcb_build
from google.cloud import logging
from google.cloud import storage
from jinja2 import Environment, FileSystemLoader
import build_and_run_coverage
import build_project
STATUS_BUCKET = 'oss-fuzz-build-logs'
@ -38,10 +38,8 @@ def scan_project_names(projects_dir):
return sorted(projects)
def upload_status(successes, failures):
def upload_status(successes, failures, status_filename):
"""Upload main status page."""
env = Environment(
loader=FileSystemLoader(os.path.join(SCRIPT_DIR, 'templates')))
data = {
'projects': failures + successes,
'failures': failures,
@ -51,14 +49,7 @@ def upload_status(successes, failures):
storage_client = storage.Client()
bucket = storage_client.get_bucket(STATUS_BUCKET)
blob = bucket.blob('status.html')
blob.cache_control = 'no-cache'
blob.upload_from_string(
env.get_template('status_template.html').render(data),
content_type='text/html')
blob = bucket.blob('status.json')
blob = bucket.blob(status_filename)
blob.cache_control = 'no-cache'
blob.upload_from_string(json.dumps(data), content_type='application/json')
@ -107,21 +98,14 @@ def execute_with_retries(request):
raise
def main():
if len(sys.argv) != 2:
usage()
projects_dir = sys.argv[1]
credentials = GoogleCredentials.get_application_default()
cloudbuild = gcb_build('cloudbuild', 'v1', credentials=credentials)
def update_build_status(
cloudbuild, projects, build_tag, status_filename):
successes = []
failures = []
for project in scan_project_names(projects_dir):
for project in projects:
print project
query_filter = ('images="gcr.io/oss-fuzz/{0}" AND tags="{1}"'.format(
project, build_project.FUZZING_BUILD_TAG))
project, build_tag))
try:
response = execute_with_retries(cloudbuild.projects().builds().list(
projectId='oss-fuzz', pageSize=2, filter=query_filter))
@ -155,7 +139,24 @@ def main():
'success': False,
})
upload_status(successes, failures)
upload_status(successes, failures, status_filename)
def main():
if len(sys.argv) != 2:
usage()
projects_dir = sys.argv[1]
projects = scan_project_names(projects_dir)
credentials = GoogleCredentials.get_application_default()
cloudbuild = gcb_build('cloudbuild', 'v1', credentials=credentials)
update_build_status(cloudbuild, projects, build_project.FUZZING_BUILD_TAG,
status_filename='status.json')
update_build_status(cloudbuild, projects,
build_and_run_coverage.COVERAGE_BUILD_TAG,
status_filename='status-coverage.json')
if __name__ == '__main__':

View File

@ -6,6 +6,7 @@
"paper-item": "PolymerElements/paper-item#2.0-preview",
"app-layout": "PolymerElements/app-layout#2.0-preview",
"paper-card": "PolymerElements/paper-card#2.0-preview",
"paper-tabs": "PolymerElements/paper-tabs#2.0-preview",
"iron-icons": "PolymerElements/iron-icons#2.0-preview",
"iron-ajax": "PolymerElements/iron-ajax#2.0-preview",
"iron-flex-layout": "PolymerElements/iron-flex-layout#2.0-preview",

View File

@ -3,7 +3,6 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1, user-scalable=yes">
<title>OSS-Fuzz build status</title>
<meta name="description" content="OSS-Fuzz build status">
@ -12,6 +11,7 @@
<script src="/bower_components/webcomponentsjs/webcomponents-loader.js"></script>
<link rel="import" href="/src/build-status/build-status.html">
<style>

View File

@ -8,6 +8,7 @@
<link rel="import" href="../../bower_components/paper-item/paper-item.html">
<link rel="import" href="../../bower_components/paper-item/paper-item-body.html">
<link rel="import" href="../../bower_components/paper-card/paper-card.html">
<link rel="import" href="../../bower_components/paper-tabs/paper-tabs.html">
<link rel="import" href="../../bower_components/paper-icon-button/paper-icon-button.html">
<link rel="import" href="../../bower_components/iron-icons/iron-icons.html">
<link rel="import" href="../../bower_components/iron-ajax/iron-ajax.html">
@ -37,6 +38,13 @@
cursor: pointer;
}
paper-tabs {
-webkit-font-smoothing: antialiased;
width: 100%;
margin-bottom: 1px;
height: 40px;
}
:host {
display: block;
}
@ -67,6 +75,12 @@
</app-header>
<div class="layout horizontal">
<paper-card class="projects">
<div class="card-tabs">
<paper-tabs selected="fuzzing" id="build_type" attr-for-selected="type" on-click="onChanged">
<paper-tab type="fuzzing">Fuzzing Builds</paper-tab>
<paper-tab type="coverage">Coverage Builds</paper-tab>
</paper-tabs>
</div>
<div class="card-content">
<template is="dom-repeat" items="[[status.projects]]" as="project">
<paper-item on-tap="onTap">
@ -102,7 +116,8 @@
</div>
</paper-card>
</div>
<iron-ajax auto handle-as="json" url="/status.json" on-response="onResponse"></iron-ajax>
<iron-ajax id="status_fuzzing" auto handle-as="json" url="/status.json" on-response="onResponseForFuzzing"></iron-ajax>
<iron-ajax id="status_coverage" auto handle-as="json" url="/status-coverage.json" on-response="onResponseForCoverage"></iron-ajax>
<iron-ajax id="logxhr" auto handle-as="text" on-response="onLogResponse"></iron-ajax>
</template>
@ -123,8 +138,16 @@
};
}
onResponse(e) {
this.status = e.detail.response;
onResponseForFuzzing(e) {
this.status_fuzzing = e.detail.response;
if (!this.status) {
// Show status of the fuzzing builds by default.
this.status = this.status_fuzzing;
}
}
onResponseForCoverage(e) {
this.status_coverage = e.detail.response;
}
onLogResponse(e) {
@ -139,6 +162,14 @@
this.loading_log = true;
}
onChanged(e) {
if (this.$.build_type.selected == 'coverage') {
this.status = this.status_coverage
} else {
this.status = this.status_fuzzing
}
}
showMessage(loading_log, log) {
return !loading_log && log === '';
}
@ -153,7 +184,7 @@
let timezone = ds.substring(ds.indexOf("("));
return date.toLocaleString() + " " + timezone;
}
}
};
window.customElements.define(BuildStatus.is, BuildStatus);
</script>

View File

@ -1,20 +0,0 @@
<!DOCTYPE html>
<meta charset="utf-8">
<head>
<title>OSS Fuzz Build Status</title>
</head>
<body>
<h1>Failing builds</h1>
<ul>
{% for project in failures -%}
<li><a href="/log-{{project.build_id}}.txt">{{project.name}}</a></li>
{% endfor -%}
</ul>
<h1>Healthy builds</h1>
<ul>
{% for project in successes -%}
<li><a href="/log-{{project.build_id}}.txt">{{project.name}}</a></li>
{% endfor -%}
</ul>
<p>Last updated {{ last_updated }} (UTC)</p>
</body>