diff options
author | Max Moroz <mmoroz@chromium.org> | 2020-01-30 15:36:44 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-30 15:36:44 -0800 |
commit | 7751ab5a87907ec971beace9d4d139aaab6287cf (patch) | |
tree | 8e13cdaa566f4ae3d6915ae7ffdf38d8e95b9b56 /infra | |
parent | 1405af8d0ae702576d13b9659d95cb84d6b7e03e (diff) | |
download | oss-fuzz-7751ab5a87907ec971beace9d4d139aaab6287cf.tar.gz |
[infra] Introduce "language" attribute in the project.yaml (#3297). (#3299)
* [infra] Introduce "language" attribute in the project.yaml (#3297).
* follow up
* enable the attribute for more projects
* trailing newline
Diffstat (limited to 'infra')
-rw-r--r-- | infra/gcb/build_and_run_coverage.py | 12 | ||||
-rw-r--r-- | infra/gcb/build_project.py | 1 | ||||
-rwxr-xr-x | infra/presubmit.py | 22 |
3 files changed, 27 insertions, 8 deletions
diff --git a/infra/gcb/build_and_run_coverage.py b/infra/gcb/build_and_run_coverage.py index d7599ba7c..b94fe3558 100644 --- a/infra/gcb/build_and_run_coverage.py +++ b/infra/gcb/build_and_run_coverage.py @@ -34,8 +34,8 @@ LATEST_REPORT_INFO_URL = ('/' + COVERAGE_BUCKET_NAME + # Link where to upload code coverage report files to. UPLOAD_URL_FORMAT = 'gs://' + COVERAGE_BUCKET_NAME + '/{project}/{type}/{date}' -# TODO(#2817): Support code coverage for Go projects. -GO_FUZZ_BUILD = 'go-fuzz-build -libfuzzer' +# Languages from project.yaml that have code coverage support. +LANGUAGES_WITH_COVERAGE_SUPPORT = ['c', 'cpp'] def skip_build(message): @@ -61,9 +61,11 @@ def get_build_steps(project_dir): build_script_path = os.path.join(project_dir, 'build.sh') if os.path.exists(build_script_path): with open(build_script_path) as fh: - if GO_FUZZ_BUILD in fh.read(): - skip_build('Project "%s" uses go-fuzz, coverage is not supported yet.' % - project_name) + if project_yaml['language'] not in LANGUAGES_WITH_COVERAGE_SUPPORT: + skip_build(('Project "{project_name}" is written in "{language}", ' + 'coverage is not supported yet.').format( + project_name=project_name, + language=project_yaml['language'])) dockerfile_path = os.path.join(project_dir, 'Dockerfile') name = project_yaml['name'] diff --git a/infra/gcb/build_project.py b/infra/gcb/build_project.py index 569c7dbe4..f45b0996a 100644 --- a/infra/gcb/build_project.py +++ b/infra/gcb/build_project.py @@ -58,6 +58,7 @@ def load_project_yaml(project_dir): project_yaml.setdefault('run_tests', True) project_yaml.setdefault('coverage_extra_args', '') project_yaml.setdefault('labels', {}) + project_yaml.setdefault('language', 'cpp') return project_yaml diff --git a/infra/presubmit.py b/infra/presubmit.py index 54c0efc23..7be16a80f 100755 --- a/infra/presubmit.py +++ b/infra/presubmit.py @@ -74,7 +74,7 @@ class ProjectYamlChecker: SECTIONS_AND_CONSTANTS = { 'sanitizers': {'address', 'none', 'memory', 'undefined', 'dataflow'}, 'architectures': {'i386', 'x86_64'}, - 'fuzzing_engines': {'afl', 'libfuzzer', 'honggfuzz', 'dataflow'} + 'fuzzing_engines': {'afl', 'libfuzzer', 'honggfuzz', 'dataflow'}, } # Note: this list must be updated when we allow new sections. @@ -89,8 +89,11 @@ class ProjectYamlChecker: 'sanitizers', 'vendor_ccs', 'view_restrictions', + 'language', ] + LANGUAGES_SUPPORTED = ['c', 'cpp', 'go', 'rust', 'python'] + # Note that some projects like boost only have auto-ccs. However, forgetting # primary contact is probably a mistake. REQUIRED_SECTIONS = ['primary_contact'] @@ -108,8 +111,11 @@ class ProjectYamlChecker: return True checks = [ - self.check_project_yaml_constants, self.check_required_sections, - self.check_valid_section_names, self.check_valid_emails + self.check_project_yaml_constants, + self.check_required_sections, + self.check_valid_section_names, + self.check_valid_emails, + self.check_valid_language, ] for check_function in checks: check_function() @@ -179,6 +185,16 @@ class ProjectYamlChecker: if '@' not in email_address or '.' not in email_address: self.error(email_address + ' is an invalid email address.') + def check_valid_language(self): + """Check that the language specified is valid.""" + language = self.data.get('language') + if not language: + return + + if language not in self.LANGUAGES_SUPPORTED: + self.error('{language} is not supported ({supported}).'.format( + language=language, supported=self.LANGUAGES_SUPPORTED)) + def _check_one_project_yaml(project_yaml_filename): """Do checks on the project.yaml file.""" |