Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cloudbuild for building chronos images for all C++. #12549

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions infra/experimental/chronos/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2024 Google LLC
#
# 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.
#
################################################################################
FROM gcr.io/cloud-builders/gcloud

RUN apt-get update && apt-get install -y jq
30 changes: 30 additions & 0 deletions infra/experimental/chronos/build_all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash
# Copyright 2024 Google LLC
#
# 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.
#
################################################################################

# Build all C/C++ projects.
c_project_yaml=$(find projects/ -name project.yaml -exec grep -l 'language: c' {} \;)
projs=$(echo $c_project_yaml | xargs dirname | xargs basename -a | sort)

cd infra/experimental/chronos

for proj in $projs; do
fuzz_target=$(curl -s "https://introspector.oss-fuzz.com/api/harness-source-and-executable?project=$proj" | jq --raw-output '.pairs[0].executable')
if [ "$fuzz_target" != null ]; then
echo ./build_on_cloudbuild.sh $proj $fuzz_target c
./build_on_cloudbuild.sh $proj $fuzz_target c
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

always c language? The above grep will capture both c and c++, and I assume we want to pick one here?

fi
done
1 change: 1 addition & 0 deletions infra/experimental/chronos/build_on_cloudbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ FUZZ_TARGET=$2
FUZZING_LANGUAGE=$3

gcloud builds submit "https://github.com/google/oss-fuzz" \
--async \
--git-source-revision=master \
--config=cloudbuild.yaml \
--substitutions=_PROJECT=$PROJECT,_FUZZ_TARGET=$FUZZ_TARGET,_FUZZING_LANGUAGE=$FUZZING_LANGUAGE \
Expand Down
6 changes: 5 additions & 1 deletion infra/experimental/chronos/cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,9 @@ images:
- us-central1-docker.pkg.dev/oss-fuzz/oss-fuzz-gen/${_PROJECT}-ofg-cached-cov
timeout: 1800s
serviceAccount: 'projects/oss-fuzz/serviceAccounts/[email protected]'
logsBucket: oss-fuzz-gcb-logs
options:
logging: CLOUD_LOGGING_ONLY
logging: GCS_ONLY
tags:
- ${_PROJECT}
- chronos
34 changes: 34 additions & 0 deletions infra/experimental/chronos/cloudbuild_all.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright 2024 Google LLC
#
# 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.
#
################################################################################
# CloudBuild for generating Chronos-cached images.
steps:
- name: 'gcr.io/cloud-builders/docker'
args:
- build
- -t
- gcloud
- .
dir: infra/experimental/chronos
- name: 'gcloud'
args:
- infra/experimental/chronos/build_all.sh
entrypoint: /bin/bash
timeout: 1800s
serviceAccount: 'projects/oss-fuzz/serviceAccounts/[email protected]'
options:
logging: CLOUD_LOGGING_ONLY
tags:
- chronos-all
Loading