From a6f436fefca1240da23cfbd9db2a016e81014f0a Mon Sep 17 00:00:00 2001 From: Max Dymond Date: Wed, 24 Jul 2019 10:39:35 +0100 Subject: [PATCH 1/2] Ensure OSS fuzz travis builds work for PRs Use the correct repository for cloning when doing a push build or a pull-request. Only do one fuzzer build! --- .travis.yml | 2 ++ test/ossfuzz/travisoss.sh | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8dae9a9..265e3ff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,8 @@ matrix: exclude: - compiler: clang env: JANSSON_BUILD_METHOD=coverage JANSSON_CMAKE_OPTIONS="-DJANSSON_COVERAGE=ON -DJANSSON_COVERALLS=ON -DCMAKE_BUILD_TYPE=Debug" JANSSON_EXTRA_INSTALL="lcov curl" + - compiler: clang + env: JANSSON_BUILD_METHOD=fuzzer allow_failures: - env: JANSSON_BUILD_METHOD=coverage JANSSON_CMAKE_OPTIONS="-DJANSSON_COVERAGE=ON -DJANSSON_COVERALLS=ON -DCMAKE_BUILD_TYPE=Debug" JANSSON_EXTRA_INSTALL="lcov curl" install: diff --git a/test/ossfuzz/travisoss.sh b/test/ossfuzz/travisoss.sh index e99cc6e..9fdcb2f 100755 --- a/test/ossfuzz/travisoss.sh +++ b/test/ossfuzz/travisoss.sh @@ -16,8 +16,18 @@ then exit 0 fi +# Work out which repo to clone from, inside Docker +if [[ ${TRAVIS_PULL_REQUEST} != "false" ]] +then + # Pull-request branch + REPO=${TRAVIS_PULL_REQUEST_SLUG} +else + # Push build. + REPO=${TRAVIS_REPO_SLUG} +fi + # Modify the oss-fuzz Dockerfile so that we're checking out the current branch on travis. -sed -i "s@https://github.com/akheron/jansson.git@-b $TRAVIS_BRANCH https://github.com/akheron/jansson.git@" /tmp/ossfuzz/projects/${PROJECT_NAME}/Dockerfile +sed -i "s@https://github.com/akheron/jansson.git@-b ${TRAVIS_BRANCH} https://github.com/${REPO}.git@" /tmp/ossfuzz/projects/${PROJECT_NAME}/Dockerfile # Try and build the fuzzers pushd /tmp/ossfuzz From 7feae084b1be7f4fee424bfa4a76631ec1af37de Mon Sep 17 00:00:00 2001 From: Max Dymond Date: Wed, 24 Jul 2019 10:50:21 +0100 Subject: [PATCH 2/2] Use the correct branch for OSS Fuzz as well. --- test/ossfuzz/travisoss.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/ossfuzz/travisoss.sh b/test/ossfuzz/travisoss.sh index 9fdcb2f..ddcfa07 100755 --- a/test/ossfuzz/travisoss.sh +++ b/test/ossfuzz/travisoss.sh @@ -21,13 +21,15 @@ if [[ ${TRAVIS_PULL_REQUEST} != "false" ]] then # Pull-request branch REPO=${TRAVIS_PULL_REQUEST_SLUG} + BRANCH=${TRAVIS_PULL_REQUEST_BRANCH} else # Push build. REPO=${TRAVIS_REPO_SLUG} + BRANCH=${TRAVIS_BRANCH} fi # Modify the oss-fuzz Dockerfile so that we're checking out the current branch on travis. -sed -i "s@https://github.com/akheron/jansson.git@-b ${TRAVIS_BRANCH} https://github.com/${REPO}.git@" /tmp/ossfuzz/projects/${PROJECT_NAME}/Dockerfile +sed -i "s@https://github.com/akheron/jansson.git@-b ${BRANCH} https://github.com/${REPO}.git@" /tmp/ossfuzz/projects/${PROJECT_NAME}/Dockerfile # Try and build the fuzzers pushd /tmp/ossfuzz