Merge pull request #11430 from phobos-/crazybee-icm
[betaflight.git] / .travis.sh
blob492e78f9fa9bb372a15c1a9ac37d4ec37d8016be
1 #!/bin/bash
3 FC_VER=$(make version)
4 REVISION=$(git rev-parse --short HEAD)
5 BRANCH=$(git rev-parse --abbrev-ref HEAD)
6 LAST_COMMIT_DATE=$(git log -1 --date=short --format="%cd")
7 TARGET_FILE=obj/betaflight_${FC_VER}_${TARGET}
8 TRAVIS_REPO_SLUG=${TRAVIS_REPO_SLUG:=$USER/undefined}
9 BUILDNAME=${BUILDNAME:=travis}
10 TRAVIS_BUILD_NUMBER=${TRAVIS_BUILD_NUMBER:=undefined}
12 MAKE="make EXTRA_FLAGS=-Werror"
14 CURL_BASEOPTS=(
15 "--retry" "10"
16 "--retry-max-time" "120" )
18 CURL_PUB_BASEOPTS=(
19 "--form" "revision=${REVISION}"
20 "--form" "branch=${BRANCH}"
21 "--form" "travis_build_number=${TRAVIS_BUILD_NUMBER}"
22 "--form" "last_commit_date=${LAST_COMMIT_DATE}"
23 "--form" "github_repo=${TRAVIS_REPO_SLUG}"
24 "--form" "build_name=${BUILDNAME}" )
26 # A hacky way of building the docs at the same time as the normal builds.
27 if [ $PUBLISHDOCS ] ; then
28 if [ $PUBLISH_URL ] ; then
30 # Patch Gimli to fix underscores_inside_words
31 curl -L "${CURL_BASEOPTS[@]}" https://github.com/walle/gimli/archive/v0.5.9.tar.gz | tar zxf -
33 sed -i 's/).render(/, :no_intra_emphasis => true).render(/' gimli-0.5.9/ext/github_markup.rb
35 cd gimli-0.5.9/
36 gem build gimli.gemspec && gem install gimli
37 cd ../
39 ./build_docs.sh
41 curl -k "${CURL_BASEOPTS[@]}" "${CURL_PUB_BASEOPTS[@]}" --form "manual=@docs/Manual.pdf" ${PUBLISH_URL} || true
44 elif [ $PUBLISHMETA ] ; then
45 if [ $PUBLISH_URL ] ; then
46 RECENT_COMMITS=$(git shortlog -n25)
47 curl -k "${CURL_BASEOPTS[@]}" "${CURL_PUB_BASEOPTS[@]}" --form "recent_commits=${RECENT_COMMITS}" ${PUBLISH_URL} || true
50 elif [ $TARGET ] ; then
51 $MAKE $TARGET || exit $?
53 if [ $PUBLISH_URL ] ; then
54 if [ -f ${TARGET_FILE}.bin ] ; then
55 TARGET_FILE=${TARGET_FILE}.bin
56 elif [ -f ${TARGET_FILE}.hex ] ; then
57 TARGET_FILE=${TARGET_FILE}.hex
58 else
59 echo "build artifact (hex or bin) for ${TARGET_FILE} not found, aborting";
60 exit 1
63 curl -k "${CURL_BASEOPTS[@]}" "${CURL_PUB_BASEOPTS[@]}" --form "file=@${TARGET_FILE}" ${PUBLISH_URL} || true
64 exit 0;
67 elif [ $GOAL ] ; then
68 if [ "test-all" == "$GOAL" ] ; then
69 $MAKE checks || exit $?
70 else
71 export V=0
74 $MAKE $GOAL || exit $?
76 if [ $PUBLISHCOV ] ; then
77 if [ "test-all" == "$GOAL" ] ; then
78 lcov --directory . -b src/test --capture --output-file coverage.info 2>&1 | grep -E ":version '402\*', prefer.*'406\*" --invert-match
79 lcov --remove coverage.info 'lib/test/*' 'src/test/*' '/usr/*' --output-file coverage.info # filter out system and test code
80 lcov --list coverage.info # debug before upload
81 coveralls-lcov coverage.info # uploads to coveralls
84 else
85 $MAKE all