[CIFuzz] Adding dry_run mode to check_build (#3444)

Prevents crash from surfacing when dry run mode is enabled and check fuzzers fails.
This commit is contained in:
Leo Neat 2020-02-28 09:41:44 -08:00 committed by GitHub
parent 98020984ba
commit 8d905b08c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 10 deletions

View File

@ -58,30 +58,30 @@ def main():
dry_run = (os.environ.get('DRY_RUN').lower() == 'true')
# The default return code when an error occurs.
error_code = 1
returncode = 1
if dry_run:
# Sets the default return code on error to success.
error_code = 0
returncode = 0
if not workspace:
logging.error('This script needs to be run in the Github action context.')
return error_code
return returncode
if event == 'push' and not cifuzz.build_fuzzers(
oss_fuzz_project_name, github_repo_name, workspace,
commit_sha=commit_sha):
logging.error('Error building fuzzers for project %s with commit %s.',
oss_fuzz_project_name, commit_sha)
return error_code
return returncode
if event == 'pull_request' and not cifuzz.build_fuzzers(
oss_fuzz_project_name, github_repo_name, workspace, pr_ref=pr_ref):
logging.error('Error building fuzzers for project %s with pull request %s.',
oss_fuzz_project_name, pr_ref)
return error_code
return returncode
out_dir = os.path.join(workspace, 'out')
if cifuzz.check_fuzzer_build(out_dir):
return 0
return 1
return returncode
if __name__ == '__main__':

View File

@ -58,7 +58,7 @@ def main():
dry_run = (os.environ.get('DRY_RUN').lower() == 'true')
# The default return code when an error occurs.
error_code = 1
returncode = 1
if dry_run:
# A testcase file is required in order for CIFuzz to surface bugs.
# If the file does not exist, the action will crash attempting to upload it.
@ -68,17 +68,17 @@ def main():
os.makedirs(out_dir, exist_ok=True)
# Sets the default return code on error to success.
error_code = 0
returncode = 0
if not workspace:
logging.error('This script needs to be run in the Github action context.')
return error_code
return returncode
# Run the specified project's fuzzers from the build.
run_status, bug_found = cifuzz.run_fuzzers(fuzz_seconds, workspace,
oss_fuzz_project_name)
if not run_status:
logging.error('Error occured while running in workspace %s.', workspace)
return error_code
return returncode
if bug_found:
logging.info('Bug found.')
if not dry_run: