Skip to content
Merged
61 changes: 61 additions & 0 deletions .github/workflows/check_base_os.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Copyright 2025 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.
#
################################################################################

name: 'Check Base OS Consistency'

on:
pull_request:
paths:
- 'projects/**'

jobs:
check-consistency:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history to compare with main

- name: Get changed project directories
id: changed-projects
run: |
# Get the list of changed files compared to the target branch
# and filter for unique directories under 'projects/'.
CHANGED_DIRS=$(git diff --name-only ${{ github.base_ref }} ${{ github.head_ref }} | \
grep '^projects/' | \
xargs -n 1 dirname | \
sort -u)
echo "changed_dirs=${CHANGED_DIRS}" >> $GITHUB_OUTPUT

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Install dependencies
run: pip install PyYAML

- name: Check each modified project
if: steps.changed-projects.outputs.changed_dirs != ''
run: |
EXIT_CODE=0
for project_dir in ${{ steps.changed-projects.outputs.changed_dirs }};
do
echo "--- Checking ${project_dir} ---"
python3 infra/ci/check_base_os.py "${project_dir}" || EXIT_CODE=$?
done
exit $EXIT_CODE
15 changes: 13 additions & 2 deletions infra/build/functions/build_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
class Config:
testing: bool = False
test_image_suffix: Optional[str] = None
base_image_tag: Optional[str] = None
repo: Optional[str] = DEFAULT_OSS_FUZZ_REPO
branch: Optional[str] = None
parallel: bool = False
Expand Down Expand Up @@ -453,12 +454,22 @@ def get_build_steps_for_project(project,
f'--architecture {build.architecture} {project.name}\\n' +
'*' * 80)
# Test fuzz targets.
check_build_command = [
'python3', 'infra/helper.py', 'check_build', '--sanitizer',
build.sanitizer, '--engine', build.fuzzing_engine,
'--architecture', build.architecture
]
if config.base_image_tag:
check_build_command.extend(
['--base-image-tag', config.base_image_tag])
check_build_command.append(project.name)

test_step = {
'name': build_lib.get_runner_image_name(config.test_image_suffix),
'env': env,
'args': [
'bash', '-c',
f'test_all.py || (echo "{failure_msg}" && false)'
'bash', '-c', f'{" ".join(check_build_command)} || '
f'(echo "{failure_msg}" && false)'
],
'id': get_id('build-check', build)
}
Expand Down
18 changes: 9 additions & 9 deletions infra/build/functions/test_data/expected_build_steps.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
"gcr.io/oss-fuzz-base/base-runner",
"bash",
"-c",
"test_all.py || (echo \"********************************************************************************\\nBuild checks failed.\\nTo reproduce, run:\\npython infra/helper.py build_image test-project\\npython infra/helper.py build_fuzzers --sanitizer address --engine afl --architecture x86_64 test-project\\npython infra/helper.py check_build --sanitizer address --engine afl --architecture x86_64 test-project\\n********************************************************************************\" && false)"
"python3 infra/helper.py check_build --sanitizer address --engine afl --architecture x86_64 test-project || (echo \"********************************************************************************\\nBuild checks failed.\\nTo reproduce, run:\\npython infra/helper.py build_image test-project\\npython infra/helper.py build_fuzzers --sanitizer address --engine afl --architecture x86_64 test-project\\npython infra/helper.py check_build --sanitizer address --engine afl --architecture x86_64 test-project\\n********************************************************************************\" && false)"
],
"id": "build-check-afl-address-x86_64"
},
Expand Down Expand Up @@ -289,7 +289,7 @@
"gcr.io/oss-fuzz-base/base-runner",
"bash",
"-c",
"test_all.py || (echo \"********************************************************************************\\nBuild checks failed.\\nTo reproduce, run:\\npython infra/helper.py build_image test-project\\npython infra/helper.py build_fuzzers --sanitizer address --engine centipede --architecture x86_64 test-project\\npython infra/helper.py check_build --sanitizer address --engine centipede --architecture x86_64 test-project\\n********************************************************************************\" && false)"
"python3 infra/helper.py check_build --sanitizer address --engine centipede --architecture x86_64 test-project || (echo \"********************************************************************************\\nBuild checks failed.\\nTo reproduce, run:\\npython infra/helper.py build_image test-project\\npython infra/helper.py build_fuzzers --sanitizer address --engine centipede --architecture x86_64 test-project\\npython infra/helper.py check_build --sanitizer address --engine centipede --architecture x86_64 test-project\\n********************************************************************************\" && false)"
],
"id": "build-check-centipede-address-x86_64"
},
Expand Down Expand Up @@ -430,7 +430,7 @@
"gcr.io/oss-fuzz-base/base-runner",
"bash",
"-c",
"test_all.py || (echo \"********************************************************************************\\nBuild checks failed.\\nTo reproduce, run:\\npython infra/helper.py build_image test-project\\npython infra/helper.py build_fuzzers --sanitizer none --engine centipede --architecture x86_64 test-project\\npython infra/helper.py check_build --sanitizer none --engine centipede --architecture x86_64 test-project\\n********************************************************************************\" && false)"
"python3 infra/helper.py check_build --sanitizer none --engine centipede --architecture x86_64 test-project || (echo \"********************************************************************************\\nBuild checks failed.\\nTo reproduce, run:\\npython infra/helper.py build_image test-project\\npython infra/helper.py build_fuzzers --sanitizer none --engine centipede --architecture x86_64 test-project\\npython infra/helper.py check_build --sanitizer none --engine centipede --architecture x86_64 test-project\\n********************************************************************************\" && false)"
],
"id": "build-check-centipede-none-x86_64"
},
Expand Down Expand Up @@ -571,7 +571,7 @@
"gcr.io/oss-fuzz-base/base-runner",
"bash",
"-c",
"test_all.py || (echo \"********************************************************************************\\nBuild checks failed.\\nTo reproduce, run:\\npython infra/helper.py build_image test-project\\npython infra/helper.py build_fuzzers --sanitizer address --engine honggfuzz --architecture x86_64 test-project\\npython infra/helper.py check_build --sanitizer address --engine honggfuzz --architecture x86_64 test-project\\n********************************************************************************\" && false)"
"python3 infra/helper.py check_build --sanitizer address --engine honggfuzz --architecture x86_64 test-project || (echo \"********************************************************************************\\nBuild checks failed.\\nTo reproduce, run:\\npython infra/helper.py build_image test-project\\npython infra/helper.py build_fuzzers --sanitizer address --engine honggfuzz --architecture x86_64 test-project\\npython infra/helper.py check_build --sanitizer address --engine honggfuzz --architecture x86_64 test-project\\n********************************************************************************\" && false)"
],
"id": "build-check-honggfuzz-address-x86_64"
},
Expand Down Expand Up @@ -712,7 +712,7 @@
"gcr.io/oss-fuzz-base/base-runner",
"bash",
"-c",
"test_all.py || (echo \"********************************************************************************\\nBuild checks failed.\\nTo reproduce, run:\\npython infra/helper.py build_image test-project\\npython infra/helper.py build_fuzzers --sanitizer address --engine libfuzzer --architecture x86_64 test-project\\npython infra/helper.py check_build --sanitizer address --engine libfuzzer --architecture x86_64 test-project\\n********************************************************************************\" && false)"
"python3 infra/helper.py check_build --sanitizer address --engine libfuzzer --architecture x86_64 test-project || (echo \"********************************************************************************\\nBuild checks failed.\\nTo reproduce, run:\\npython infra/helper.py build_image test-project\\npython infra/helper.py build_fuzzers --sanitizer address --engine libfuzzer --architecture x86_64 test-project\\npython infra/helper.py check_build --sanitizer address --engine libfuzzer --architecture x86_64 test-project\\n********************************************************************************\" && false)"
],
"id": "build-check-libfuzzer-address-x86_64"
},
Expand Down Expand Up @@ -853,7 +853,7 @@
"gcr.io/oss-fuzz-base/base-runner",
"bash",
"-c",
"test_all.py || (echo \"********************************************************************************\\nBuild checks failed.\\nTo reproduce, run:\\npython infra/helper.py build_image test-project\\npython infra/helper.py build_fuzzers --sanitizer address --engine libfuzzer --architecture i386 test-project\\npython infra/helper.py check_build --sanitizer address --engine libfuzzer --architecture i386 test-project\\n********************************************************************************\" && false)"
"python3 infra/helper.py check_build --sanitizer address --engine libfuzzer --architecture i386 test-project || (echo \"********************************************************************************\\nBuild checks failed.\\nTo reproduce, run:\\npython infra/helper.py build_image test-project\\npython infra/helper.py build_fuzzers --sanitizer address --engine libfuzzer --architecture i386 test-project\\npython infra/helper.py check_build --sanitizer address --engine libfuzzer --architecture i386 test-project\\n********************************************************************************\" && false)"
],
"id": "build-check-libfuzzer-address-i386"
},
Expand Down Expand Up @@ -994,7 +994,7 @@
"gcr.io/oss-fuzz-base/base-runner",
"bash",
"-c",
"test_all.py || (echo \"********************************************************************************\\nBuild checks failed.\\nTo reproduce, run:\\npython infra/helper.py build_image test-project\\npython infra/helper.py build_fuzzers --sanitizer address --engine libfuzzer --architecture aarch64 test-project\\npython infra/helper.py check_build --sanitizer address --engine libfuzzer --architecture aarch64 test-project\\n********************************************************************************\" && false)"
"python3 infra/helper.py check_build --sanitizer address --engine libfuzzer --architecture aarch64 test-project || (echo \"********************************************************************************\\nBuild checks failed.\\nTo reproduce, run:\\npython infra/helper.py build_image test-project\\npython infra/helper.py build_fuzzers --sanitizer address --engine libfuzzer --architecture aarch64 test-project\\npython infra/helper.py check_build --sanitizer address --engine libfuzzer --architecture aarch64 test-project\\n********************************************************************************\" && false)"
],
"id": "build-check-libfuzzer-address-aarch64"
},
Expand Down Expand Up @@ -1135,7 +1135,7 @@
"gcr.io/oss-fuzz-base/base-runner",
"bash",
"-c",
"test_all.py || (echo \"********************************************************************************\\nBuild checks failed.\\nTo reproduce, run:\\npython infra/helper.py build_image test-project\\npython infra/helper.py build_fuzzers --sanitizer memory --engine libfuzzer --architecture x86_64 test-project\\npython infra/helper.py check_build --sanitizer memory --engine libfuzzer --architecture x86_64 test-project\\n********************************************************************************\" && false)"
"python3 infra/helper.py check_build --sanitizer memory --engine libfuzzer --architecture x86_64 test-project || (echo \"********************************************************************************\\nBuild checks failed.\\nTo reproduce, run:\\npython infra/helper.py build_image test-project\\npython infra/helper.py build_fuzzers --sanitizer memory --engine libfuzzer --architecture x86_64 test-project\\npython infra/helper.py check_build --sanitizer memory --engine libfuzzer --architecture x86_64 test-project\\n********************************************************************************\" && false)"
],
"id": "build-check-libfuzzer-memory-x86_64"
},
Expand Down Expand Up @@ -1276,7 +1276,7 @@
"gcr.io/oss-fuzz-base/base-runner",
"bash",
"-c",
"test_all.py || (echo \"********************************************************************************\\nBuild checks failed.\\nTo reproduce, run:\\npython infra/helper.py build_image test-project\\npython infra/helper.py build_fuzzers --sanitizer undefined --engine libfuzzer --architecture x86_64 test-project\\npython infra/helper.py check_build --sanitizer undefined --engine libfuzzer --architecture x86_64 test-project\\n********************************************************************************\" && false)"
"python3 infra/helper.py check_build --sanitizer undefined --engine libfuzzer --architecture x86_64 test-project || (echo \"********************************************************************************\\nBuild checks failed.\\nTo reproduce, run:\\npython infra/helper.py build_image test-project\\npython infra/helper.py build_fuzzers --sanitizer undefined --engine libfuzzer --architecture x86_64 test-project\\npython infra/helper.py check_build --sanitizer undefined --engine libfuzzer --architecture x86_64 test-project\\n********************************************************************************\" && false)"
],
"id": "build-check-libfuzzer-undefined-x86_64"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
"gcr.io/oss-fuzz-base/base-runner",
"bash",
"-c",
"test_all.py || (echo \"********************************************************************************\\nBuild checks failed.\\nTo reproduce, run:\\npython infra/helper.py build_image test-project\\npython infra/helper.py build_fuzzers --sanitizer address --engine centipede --architecture x86_64 test-project\\npython infra/helper.py check_build --sanitizer address --engine centipede --architecture x86_64 test-project\\n********************************************************************************\" && false)"
"python3 infra/helper.py check_build --sanitizer address --engine centipede --architecture x86_64 test-project || (echo \"********************************************************************************\\nBuild checks failed.\\nTo reproduce, run:\\npython infra/helper.py build_image test-project\\npython infra/helper.py build_fuzzers --sanitizer address --engine centipede --architecture x86_64 test-project\\npython infra/helper.py check_build --sanitizer address --engine centipede --architecture x86_64 test-project\\n********************************************************************************\" && false)"
],
"id": "build-check-centipede-address-x86_64"
},
Expand Down Expand Up @@ -246,7 +246,7 @@
"gcr.io/oss-fuzz-base/base-runner",
"bash",
"-c",
"test_all.py || (echo \"********************************************************************************\\nBuild checks failed.\\nTo reproduce, run:\\npython infra/helper.py build_image test-project\\npython infra/helper.py build_fuzzers --sanitizer none --engine centipede --architecture x86_64 test-project\\npython infra/helper.py check_build --sanitizer none --engine centipede --architecture x86_64 test-project\\n********************************************************************************\" && false)"
"python3 infra/helper.py check_build --sanitizer none --engine centipede --architecture x86_64 test-project || (echo \"********************************************************************************\\nBuild checks failed.\\nTo reproduce, run:\\npython infra/helper.py build_image test-project\\npython infra/helper.py build_fuzzers --sanitizer none --engine centipede --architecture x86_64 test-project\\npython infra/helper.py check_build --sanitizer none --engine centipede --architecture x86_64 test-project\\n********************************************************************************\" && false)"
],
"id": "build-check-centipede-none-x86_64"
},
Expand Down
Loading
Loading