mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
Merge pull request #6940 from kaspar030/factor_out_changed_files.sh
dist: tools: factor out changed files collection in check scripts
This commit is contained in:
commit
8cf3714202
13
dist/tools/ci/build_and_test.sh
vendored
13
dist/tools/ci/build_and_test.sh
vendored
@ -51,6 +51,7 @@ function run {
|
||||
|
||||
if [[ $BUILDTEST_MCU_GROUP ]]
|
||||
then
|
||||
export BASE_BRANCH="${CI_BASE_BRANCH}"
|
||||
|
||||
if [ "$BUILDTEST_MCU_GROUP" == "static-tests" ]
|
||||
then
|
||||
@ -82,11 +83,11 @@ then
|
||||
run ./dist/tools/ci/print_toolchain_versions.sh
|
||||
|
||||
run ./dist/tools/whitespacecheck/check.sh ${CI_BASE_BRANCH}
|
||||
run ./dist/tools/licenses/check.sh ${CI_BASE_BRANCH} --diff-filter=MR --error-exitcode=0
|
||||
run ./dist/tools/licenses/check.sh ${CI_BASE_BRANCH} --diff-filter=AC
|
||||
run ./dist/tools/doccheck/check.sh ${CI_BASE_BRANCH}
|
||||
run ./dist/tools/externc/check.sh ${CI_BASE_BRANCH}
|
||||
run ./dist/tools/cppcheck/check.sh ${CI_BASE_BRANCH}
|
||||
DIFFFILTER="MR" ERROR_EXIT_CODE=0 run ./dist/tools/licenses/check.sh
|
||||
DIFFFILTER="AC" run ./dist/tools/licenses/check.sh
|
||||
run ./dist/tools/doccheck/check.sh
|
||||
run ./dist/tools/externc/check.sh
|
||||
run ./dist/tools/cppcheck/check.sh
|
||||
run ./dist/tools/pr_check/pr_check.sh ${CI_BASE_BRANCH}
|
||||
exit $RESULT
|
||||
fi
|
||||
@ -106,7 +107,7 @@ then
|
||||
# - make -C ./tests/unittests all test BOARD=qemu-i386 || exit
|
||||
fi
|
||||
|
||||
BASE_BRANCH="${CI_BASE_BRANCH}"
|
||||
|
||||
./dist/tools/compile_test/compile_test.py $BASE_BRANCH
|
||||
set_result $?
|
||||
fi
|
||||
|
25
dist/tools/ci/changed_files.sh
vendored
Normal file
25
dist/tools/ci/changed_files.sh
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
# Copyright 2017 Kaspar Schleiser <kaspar@schleiser.de>
|
||||
# Copyright 2014 Ludwig Knüpfer <ludwig.knuepfer@fu-berlin.de>
|
||||
# Copyright 2014 Hinnerk van Bruinehsen <h.v.bruinehsen@fu-berlin.de>
|
||||
#
|
||||
# This file is subject to the terms and conditions of the GNU Lesser
|
||||
# General Public License v2.1. See the file LICENSE in the top level
|
||||
# directory for more details.
|
||||
|
||||
changed_files() {
|
||||
: ${FILEREGEX:='\.([CcHh]|[ch]pp)$'}
|
||||
: ${EXCLUDE:='^(.+/include/vendor/)'}
|
||||
: ${DIFFFILTER:='ACMR'}
|
||||
|
||||
DIFFFILTER="--diff-filter=${DIFFFILTER}"
|
||||
|
||||
# select either all or only touched-in-branch files, filter through FILEREGEX
|
||||
if [ -z "${BASE_BRANCH}" ]; then
|
||||
FILES="$(git ls-tree -r --full-tree --name-only HEAD | grep -E ${FILEREGEX})"
|
||||
else
|
||||
FILES="$(git diff ${DIFFFILTER} --name-only ${BASE_BRANCH} | grep -E ${FILEREGEX})"
|
||||
fi
|
||||
|
||||
# filter out negatives
|
||||
echo "${FILES}" | grep -v -E ${EXCLUDE}
|
||||
}
|
36
dist/tools/cppcheck/check.sh
vendored
36
dist/tools/cppcheck/check.sh
vendored
@ -1,5 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Copyright 2017 Kaspar Schleiser <kaspar@schleiser.de>
|
||||
# Copyright 2014 Ludwig Knüpfer <ludwig.knuepfer@fu-berlin.de>
|
||||
# Copyright 2014 Hinnerk van Bruinehsen <h.v.bruinehsen@fu-berlin.de>
|
||||
#
|
||||
@ -7,6 +8,8 @@
|
||||
# General Public License v2.1. See the file LICENSE in the top level
|
||||
# directory for more details.
|
||||
|
||||
. ${RIOTBASE:+${RIOTBASE}/}dist/tools/ci/changed_files.sh
|
||||
|
||||
# Don't show warnings about unusedStructMembers by default
|
||||
DEFAULT_SUPPRESSIONS="${1}"
|
||||
if echo "${DEFAULT_SUPPRESSIONS}" | grep -q '^--show-unused-struct'; then
|
||||
@ -16,38 +19,7 @@ else
|
||||
DEFAULT_SUPPRESSIONS=--suppress="unusedStructMember"
|
||||
fi
|
||||
|
||||
BRANCH=${1}
|
||||
FILEREGEX='\.([CcHh]|[ch]pp)$'
|
||||
EXCLUDE='^(.+/include/vendor/)'
|
||||
|
||||
# If no branch but an option is given, unset BRANCH.
|
||||
# Otherwise, consume this parameter.
|
||||
if echo "${BRANCH}" | grep -q '^-'; then
|
||||
BRANCH=""
|
||||
else
|
||||
if [ -n "${BRANCH}" ]; then
|
||||
shift 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# If the --diff-filter option is given, consume this parameter.
|
||||
# Set the default DIFFFILTER option otherwise.
|
||||
DIFFFILTER="${1}"
|
||||
if echo "${DIFFFILTER}" | grep -q '^--diff-filter='; then
|
||||
shift 1
|
||||
else
|
||||
DIFFFILTER="--diff-filter=ACMR"
|
||||
fi
|
||||
|
||||
# select either all or only touched-in-branch files, filter through FILEREGEX
|
||||
if [ -z "${BRANCH}" ]; then
|
||||
FILES="$(git ls-tree -r --full-tree --name-only HEAD | grep -E ${FILEREGEX})"
|
||||
else
|
||||
FILES="$(git diff ${DIFFFILTER} --name-only ${BRANCH} | grep -E ${FILEREGEX})"
|
||||
fi
|
||||
|
||||
# filter out negatives
|
||||
FILES=$(echo "${FILES}" | grep -v -E ${EXCLUDE})
|
||||
FILES=$(changed_files)
|
||||
|
||||
if [ -z "${FILES}" ]; then
|
||||
exit
|
||||
|
20
dist/tools/externc/check.sh
vendored
20
dist/tools/externc/check.sh
vendored
@ -1,5 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Copyright 2017 Kaspar Schleiser <kaspar@schleiser.de>
|
||||
# Copyright 2014 Ludwig Knüpfer <ludwig.knuepfer@fu-berlin.de>
|
||||
# Copyright 2014 DangNhat Pham-Huu <51002279@hcmut.edu.vn>
|
||||
#
|
||||
@ -7,28 +8,13 @@
|
||||
# General Public License v2.1. See the file LICENSE in the top level
|
||||
# directory for more details.
|
||||
|
||||
# customizable
|
||||
CHECKROOT=$(dirname "${0}")
|
||||
. ${RIOTBASE:+${RIOTBASE}/}dist/tools/ci/changed_files.sh
|
||||
|
||||
# prepare
|
||||
ROOT=$(git rev-parse --show-toplevel)
|
||||
EXIT_CODE=0
|
||||
BRANCH="${1}"
|
||||
DIFFFILTER="${2}"
|
||||
|
||||
# set default diff-filter
|
||||
if [ -z "${DIFFFILTER}" ]; then
|
||||
DIFFFILTER="ACMR"
|
||||
fi
|
||||
|
||||
# select files to check
|
||||
if [ -z "${BRANCH}" ]; then
|
||||
FILES="$(git ls-tree -r --full-tree --name-only HEAD | grep -E '\.h$')"
|
||||
else
|
||||
FILES="$(git diff --diff-filter=${DIFFFILTER} --name-only ${BRANCH} | grep -E '\.h$')"
|
||||
fi
|
||||
|
||||
FILES=$(echo "${FILES}" | grep -v -E '^(dist/tools|boards/msba2-common/tools/|.+/include/vendor/)')
|
||||
FILES=$(FILEREGEX='\.h$' changed_files)
|
||||
|
||||
# check files
|
||||
for FILE in ${FILES}; do
|
||||
|
40
dist/tools/licenses/check.sh
vendored
40
dist/tools/licenses/check.sh
vendored
@ -1,11 +1,14 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Copyright 2017 Kaspar Schleiser <kaspar@schleiser.de>
|
||||
# Copyright 2014 Ludwig Knüpfer <ludwig.knuepfer@fu-berlin.de>
|
||||
#
|
||||
# This file is subject to the terms and conditions of the GNU Lesser
|
||||
# General Public License v2.1. See the file LICENSE in the top level
|
||||
# directory for more details.
|
||||
|
||||
. ${RIOTBASE:+${RIOTBASE}/}dist/tools/ci/changed_files.sh
|
||||
|
||||
# customizable
|
||||
CHECKROOT=$(dirname "${0}")
|
||||
LICENSEDIR="${CHECKROOT}/patterns"
|
||||
@ -20,7 +23,8 @@ TAB_CHAR="$(printf '\t')"
|
||||
ROOT=$(git rev-parse --show-toplevel)
|
||||
LICENSES=$(ls "${LICENSEDIR}")
|
||||
EXIT_CODE=0
|
||||
ERROR_EXIT_CODE="1"
|
||||
|
||||
: ${ERROR_EXIT_CODE:=1}
|
||||
|
||||
# reset output dir
|
||||
rm -fr "${OUTPUT}"
|
||||
@ -29,39 +33,7 @@ for LICENSE in ${LICENSES}; do
|
||||
echo -n '' > "${OUTPUT}/${LICENSE}"
|
||||
done
|
||||
|
||||
# If no branch but an option is given, unset BRANCH.
|
||||
# Otherwise, consume this parameter.
|
||||
BRANCH="${1}"
|
||||
if echo "${BRANCH}" | grep -q '^-'; then
|
||||
BRANCH=""
|
||||
else
|
||||
if [ -n "${BRANCH}" ]; then
|
||||
shift 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# If the --diff-filter option is given, consume this parameter.
|
||||
# Set the default DIFFFILTER option otherwise.
|
||||
DIFFFILTER="${1}"
|
||||
if echo "${DIFFFILTER}" | grep -q '^--diff-filter='; then
|
||||
shift 1
|
||||
else
|
||||
DIFFFILTER="--diff-filter=ACMR"
|
||||
fi
|
||||
|
||||
# If the --error-exitcode option is given, consume this parameter
|
||||
# and overwrite the default ERROR_EXIT_CODE.
|
||||
if echo "${1}" | grep -q '^--error-exitcode='; then
|
||||
ERROR_EXIT_CODE=$(echo ${1} | sed -e 's/--error-exitcode=//')
|
||||
shift 1
|
||||
fi
|
||||
|
||||
# select files to check
|
||||
if [ -z "${BRANCH}" ]; then
|
||||
FILES="$(git ls-tree -r --full-tree --name-only HEAD | grep -E '\.([sSch]|cpp)$')"
|
||||
else
|
||||
FILES="$(git diff ${DIFFFILTER} --name-only ${BRANCH} | grep -E '\.([sSchp]|cpp)$')"
|
||||
fi
|
||||
FILES=$(FILEREGEX='\.([sSch]|cpp)$' changed_files)
|
||||
|
||||
# categorize files
|
||||
for FILE in ${FILES}; do
|
||||
|
Loading…
Reference in New Issue
Block a user