From 4465b0fc52abd9eedaf8ab5e2be837f93edd49ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=BChnel?= Date: Thu, 26 Mar 2020 10:19:20 +0100 Subject: [PATCH] changed output paths of lint.sh --- Jenkins/BETA-phabricator-linux/Jenkinsfile | 8 +++----- Jenkins/Phabricator-pipeline/Jenkinsfile | 2 +- scripts/lint.sh | 18 +++++++++++------- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/Jenkins/BETA-phabricator-linux/Jenkinsfile b/Jenkins/BETA-phabricator-linux/Jenkinsfile index d1c323a..824b7fc 100644 --- a/Jenkins/BETA-phabricator-linux/Jenkinsfile +++ b/Jenkins/BETA-phabricator-linux/Jenkinsfile @@ -124,7 +124,7 @@ pipeline { { script { try { - sh(script: "${SCRIPT_DIR}/lint.sh HEAD~1") + sh(script: "${SCRIPT_DIR}/lint.sh HEAD~1 ${RESULT_DIR}") } catch (e) { success = false; failure_message += "\nFailed to run linters" // append as build might already be broken @@ -154,8 +154,6 @@ pipeline { set -eu cp ${LLVM_DIR}/build/CMakeCache.txt . || : cp ${LLVM_DIR}/build/test-results.xml . || : - cp ${LLVM_DIR}/clang-format.patch . || : - cp ${LLVM_DIR}/clang-tidy.txt . || : mkdir -p ${TARGET_DIR} cp * ${TARGET_DIR} """ @@ -167,8 +165,8 @@ pipeline { --test-result-file "${RESULT_DIR}/test-results.xml" \ --host "${PHABRICATOR_HOST}/api/" \ --buildresult ${currentBuild.result} \ - --clang-format-patch "${LLVM_DIR}/clang-format.patch" \ - --clang-tidy-result "${LLVM_DIR}/clang-tidy.txt" \ + --clang-format-patch "${RESULT_DIR}/clang-format.patch" \ + --clang-tidy-result "${RESULT_DIR}/clang-tidy.txt" \ --clang-tidy-ignore "${SCRIPT_DIR}/clang-tidy-comments.ignore" \ --results-dir "${TARGET_DIR}" \ --results-url "${RESULT_URL}" \ diff --git a/Jenkins/Phabricator-pipeline/Jenkinsfile b/Jenkins/Phabricator-pipeline/Jenkinsfile index 42c3a14..31a90c2 100644 --- a/Jenkins/Phabricator-pipeline/Jenkinsfile +++ b/Jenkins/Phabricator-pipeline/Jenkinsfile @@ -130,7 +130,7 @@ pipeline { steps { script { try { - sh(script: "${SCRIPT_DIR}/lint.sh") + sh(script: "${SCRIPT_DIR}/lint.sh HEAD ${TARGET_DIR}") } catch (e) { success = false; failure_message += "\nFailed to run linters" // append as build might already be broken diff --git a/scripts/lint.sh b/scripts/lint.sh index a6840ce..2b1e71f 100755 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -19,12 +19,16 @@ set -eux echo "Running linters... =====================================" -# In the normal case: diff staging area against head -# Optionml: diff against another commit, set via command line parameter -COMMIT=HEAD -if (( $# == 1 )); then - COMMIT="$1" +if (( $# != 2 )); then + echo "Syntax: lint.sh " + exit 1 fi; +# Commit to diff against +COMMIT="$1" +# output directory for test results +OUTPUT_DIR="$2" +# root directory, where the config files are located +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" if [ ! -f "compile_commands.json" ] ; then echo "Could not find compile commands.json in $(pwd)" @@ -35,12 +39,12 @@ fi # Let clang format apply patches --diff doesn't produces results in the format we want. git-clang-format "${COMMIT}" set +e -git diff -U0 --exit-code | "${SCRIPT_DIR}/ignore_diff.py" "${SCRIPT_DIR}/clang-format.ignore" > "${TARGET_DIR}"/clang-format.patch +git diff -U0 --exit-code | "${DIR}/ignore_diff.py" "${DIR}/clang-format.ignore" > "${OUTPUT_DIR}"/clang-format.patch set -e # Revert changes of git-clang-format. git checkout -- . # clang-tidy -git diff -U0 "${COMMIT}" | "${SCRIPT_DIR}/ignore_diff.py" "${SCRIPT_DIR}/clang-tidy.ignore" | clang-tidy-diff -p1 -quiet | sed "/^[[:space:]]*$/d" > "${TARGET_DIR}"/clang-tidy.txt +git diff -U0 "${COMMIT}" | "${DIR}/ignore_diff.py" "${DIR}/clang-tidy.ignore" | clang-tidy-diff -p1 -quiet | sed "/^[[:space:]]*$/d" > "${OUTPUT_DIR}"/clang-tidy.txt echo "linters completed ======================================"