summaryrefslogtreecommitdiffstats
path: root/scripts/travis.sh
blob: 02d7752cc36d4a2e6e0b6ee25fd69151a5bc62e0 (plain)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env bash

RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color

BUILDSTEP_FAILED=0

function run_command {
	eval $@

	ret=$?
	if [ $ret != 0 ]; then
		colour=$RED
		BUILDSTEP_FAILED=1
	else
		colour=$GREEN
	fi
	echo -e "\n${colour}The command \"$@\" exited with $ret.$NC\n\n"

	return $ret
}

function checkpatch {
	git diff $TRAVIS_BRANCH {rtrlib,tools,tests}/**/*.[ch] > /tmp/patch
	run_command scripts/checkpatch.pl --ignore FILE_PATH_CHANGES,PREFER_KERNEL_TYPES,CONST_STRUCT,OPEN_BRACE,SPDX_LICENSE_TAG,OPEN_ENDED_LINE,UNNECESSARY_PARENTHESES,PREFER_PRINTF,GLOBAL_INITIALISERS,PREFER_PACKED,BOOL_MEMBER,STATIC_CONST_CHAR_ARRAY,LONG_LINE_STRING --terse --no-tree --strict --show-types --max-line-length 120 /tmp/patch
	ret=$?
	if [ $ret != 0 ]; then
		cat -n /tmp/patch
	fi
}

[[ $TRAVIS = "true" ]] && run_command git fetch --unshallow
run_command scripts/cppcheck.sh
run_command scripts/check-coding-style.sh
[[ $TRAVIS_EVENT_TYPE = "pull_request" ]] && run_command checkpatch
run_command cmake -D RTRLIB_TRANSPORT_SSH=Off .
run_command make
run_command make test
run_command make clean
run_command cmake -D CMAKE_BUILD_TYPE=Release -DENABLE_COVERAGE=On -DUNIT_TESTING=On -DRTRLIB_TRANSPORT_SSH=On .
run_command make
run_command make test
run_command make gcov
run_command scripts/check-exports.sh

exit $BUILDSTEP_FAILED