File: travis-checkpatch

package info (click to toggle)
opensm 3.3.23-3.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,932 kB
  • sloc: ansic: 97,383; yacc: 2,227; sh: 685; lex: 404; makefile: 391; perl: 143
file content (29 lines) | stat: -rwxr-xr-x 1,386 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash
# Copyright 2017 Mellanox Technologies Ltd.
# Licensed under BSD (MIT variant) or GPLv2. See COPYING.


if [ "x$TRAVIS_EVENT_TYPE" != "xpull_request" ]; then
	# Peform checkpatch checks on pull requests only
	exit 0
fi

# The below "set" is commented, because the checkpatch.pl returns 1 (error) for warnings too.
# And the rdma-core code is not mature enough to be warning safe
# set -e

if [ "x$TRAVIS_COMMIT_RANGE" != "x" ]; then
	wget -q https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/plain/scripts/checkpatch.pl \
	        https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/plain/scripts/spelling.txt
	DIR_FOR_PATCHES_TO_CHECK=$(mktemp -d)
	git format-patch --no-cover-letter $TRAVIS_COMMIT_RANGE ^$TRAVIS_BRANCH -o $DIR_FOR_PATCHES_TO_CHECK/
	CHECKPATCH_OPT="--no-tree --ignore PREFER_KERNEL_TYPES,FILE_PATH_CHANGES,EXECUTE_PERMISSIONS,USE_NEGATIVE_ERRNO,CONST_STRUCT $DIR_FOR_PATCHES_TO_CHECK/*"
	perl checkpatch.pl $CHECKPATCH_OPT
	if [ $? -ne 0 ]; then
		# We rerun checkpatch to simplify parsing and to understand if we failed for errors
		# For example, the output on some arbitrary patchset of the following line without awk is:
		# total: 1 errors, 3 warnings, 42 lines checked
		NUMB_ERRRORS=$(perl checkpatch.pl --terse $CHECKPATCH_OPT | awk 'BEGIN {FS = "total:"} ; {sum+=$2} END {print sum}')
		exit $NUMB_ERRRORS
	fi
fi