aboutsummaryrefslogtreecommitdiffhomepage
path: root/infra/build/functions/request_coverage_build.py
diff options
context:
space:
mode:
Diffstat (limited to 'infra/build/functions/request_coverage_build.py')
-rw-r--r--infra/build/functions/request_coverage_build.py38
1 files changed, 20 insertions, 18 deletions
diff --git a/infra/build/functions/request_coverage_build.py b/infra/build/functions/request_coverage_build.py
index 0bc57e44..e861875a 100644
--- a/infra/build/functions/request_coverage_build.py
+++ b/infra/build/functions/request_coverage_build.py
@@ -14,36 +14,38 @@
#
################################################################################
"""Cloud function that requests coverage builds."""
+import base64
import google.auth
from google.cloud import ndb
import build_and_run_coverage
-from datastore_entities import Project
import request_build
BASE_PROJECT = 'oss-fuzz-base'
+def get_build_steps(project_name, image_project, base_images_project):
+ """Retrieve build steps."""
+ project_yaml_contents, dockerfile_lines = request_build.get_project_data(
+ project_name)
+ return build_and_run_coverage.get_build_steps(project_name,
+ project_yaml_contents,
+ dockerfile_lines, image_project,
+ base_images_project)
+
+
def request_coverage_build(event, context):
"""Entry point for coverage build cloud function."""
- del event, context #unused
+ del context #unused
+ if 'data' in event:
+ project_name = base64.b64decode(event['data']).decode('utf-8')
+ else:
+ raise RuntimeError('Project name missing from payload')
with ndb.Client().context():
credentials, image_project = google.auth.default()
- for project in Project.query():
- project_name = project.name
- project_yaml_contents = project.project_yaml_contents
- dockerfile_lines = project.dockerfile_contents.split('\n')
- # Catching sys.exit() for a project's build steps to avoid it
- # from interferring with other remaining builds.
- try:
- build_steps = build_and_run_coverage.get_build_steps(
- project_name, project_yaml_contents, dockerfile_lines,
- image_project, BASE_PROJECT)
- except SystemExit:
- continue
-
- request_build.run_build(project_name, image_project, build_steps,
- credentials,
- build_and_run_coverage.COVERAGE_BUILD_TAG)
+ build_steps = get_build_steps(project_name, image_project, BASE_PROJECT)
+ request_build.run_build(project_name, image_project, build_steps,
+ credentials,
+ build_and_run_coverage.COVERAGE_BUILD_TAG)