[CIFuzz] Make it possible to skip bad build check. (#5475)

This will mainly be useful for non-OSS-Fuzz users.
Though it can also be used by OSS-Fuzz users to speed things
up (very slightly in most cases).
Fixes #4377
diff --git a/infra/cifuzz/actions/build_fuzzers/action.yml b/infra/cifuzz/actions/build_fuzzers/action.yml
index a8a81ac..835b7b4 100644
--- a/infra/cifuzz/actions/build_fuzzers/action.yml
+++ b/infra/cifuzz/actions/build_fuzzers/action.yml
@@ -24,6 +24,10 @@
   build-integration-path:
     description: "The path to the the project's build integration."
     required: false
+  bad-build-check:
+    description: "Whether or not OSS-Fuzz's check for bad builds should be done."
+    required: false
+    default: true
 runs:
   using: 'docker'
   image: '../../../build_fuzzers.Dockerfile'
@@ -36,3 +40,4 @@
     PROJECT_SRC_PATH: ${{ inputs.project-src-path }}
     BUILD_INTEGRATION_PATH: ${{ inputs.build-integration-path }}
     LOW_DISK_SPACE: 'True'
+    BAD_BUILD_CHECK: ${{ inputs.bad-build-check }}
diff --git a/infra/cifuzz/build_fuzzers_entrypoint.py b/infra/cifuzz/build_fuzzers_entrypoint.py
index ddae681..04f5620 100644
--- a/infra/cifuzz/build_fuzzers_entrypoint.py
+++ b/infra/cifuzz/build_fuzzers_entrypoint.py
@@ -72,8 +72,13 @@
     return returncode
 
   out_dir = os.path.join(config.workspace, 'out')
+
+  if not config.bad_build_check:
+    # If we've gotten to this point and we don't need to do bad_build_check,
+    # then the build has succeeded.
+    returncode = 0
   # yapf: disable
-  if build_fuzzers.check_fuzzer_build(
+  elif build_fuzzers.check_fuzzer_build(
       out_dir,
       config.sanitizer,
       config.language,
diff --git a/infra/cifuzz/config_utils.py b/infra/cifuzz/config_utils.py
index 9cf018b..ad2cd36 100644
--- a/infra/cifuzz/config_utils.py
+++ b/infra/cifuzz/config_utils.py
@@ -172,6 +172,7 @@
 
     self.allowed_broken_targets_percentage = os.getenv(
         'ALLOWED_BROKEN_TARGETS_PERCENTAGE')
+    self.bad_build_check = environment.get_bool('BAD_BUILD_CHECK', 'true')
 
     # TODO(metzman): Use better system for interpreting env vars. What if env
     # var is set to '0'?