|
1 | 1 | # Kudos to these guys: |
2 | | -# http://genbattle.bitbucket.org/blog/2016/01/17/c++-travis-ci/ |
3 | | -# https://github.com/ticapix/arduino-toolbox/blob/master/.travis.yml |
4 | 2 | # https://github.com/Return-To-The-Roots/s25client/blob/master/.travis.yml |
| 3 | +# http://docs.platformio.org/en/stable/ci/travis.html |
5 | 4 |
|
6 | 5 | sudo: false |
7 | | -language: cpp |
| 6 | +language: python |
8 | 7 |
|
9 | 8 | os: |
10 | | - - linux |
| 9 | + - linux |
11 | 10 |
|
12 | | -compiler: |
13 | | - - g++ |
14 | | - - clang |
| 11 | +python: |
| 12 | + - "2.7" |
| 13 | + |
| 14 | +# Cache PlatformIO packages using Travis CI container-based infrastructure |
| 15 | +cache: |
| 16 | + directories: |
| 17 | + - "~/.platformio" |
15 | 18 |
|
16 | 19 | env: |
17 | | - - BUILD_TYPE=Debug |
| 20 | + global: |
| 21 | + - BUILD_TYPE=Debug |
| 22 | + matrix: |
| 23 | + - BUILD_UNIT_TESTS=1 |
| 24 | + - PLATFORMIO_CI_SRC=examples/Basic_IO |
| 25 | + - PLATFORMIO_CI_SRC=examples/Bench |
| 26 | + - PLATFORMIO_CI_SRC=examples/Callbacks |
| 27 | + - PLATFORMIO_CI_SRC=examples/DualMerger |
| 28 | + - PLATFORMIO_CI_SRC=examples/Input |
| 29 | + - PLATFORMIO_CI_SRC=examples/MidiUSB |
| 30 | + - PLATFORMIO_CI_SRC=examples/RPN_NRPN |
| 31 | + - PLATFORMIO_CI_SRC=examples/SimpleSynth |
18 | 32 |
|
19 | 33 | addons: |
20 | | - apt: |
21 | | - sources: |
22 | | - - ubuntu-toolchain-r-test |
23 | | - - llvm-toolchain-precise-3.5 |
24 | | - packages: |
25 | | - - g++-4.8 |
26 | | - - clang-3.5 |
27 | | - - llvm-3.5 |
28 | | - - cmake |
29 | | - |
30 | | -#before_install: |
31 | | -# - source <(curl -SLs https://raw.githubusercontent.com/fortyseveneffects/travis-ci-arduino/master/install.sh) |
| 34 | + apt: |
| 35 | + sources: |
| 36 | + - ubuntu-toolchain-r-test |
| 37 | + packages: |
| 38 | + - g++-4.8 |
| 39 | + - cmake |
32 | 40 |
|
33 | 41 | install: |
34 | | - # Enable coverage analysis only for GCC |
35 | | - - | |
36 | | - if [ "$CXX" = "g++" ]; then |
37 | | - # GCov 4.6 cannot handle the file structure |
38 | | - export CXX="g++-4.8" |
39 | | - export GCOV="gcov-4.8" |
40 | | -
|
41 | | - # Install newer lcov (1.9 seems to fail: http://gronlier.fr/blog/2015/01/adding-code-coverage-to-your-c-project/) |
42 | | - export LCOV_ROOT="$HOME/lcov" |
43 | | - mkdir -p "$LCOV_ROOT" |
44 | | - wget http://ftp.de.debian.org/debian/pool/main/l/lcov/lcov_1.12.orig.tar.gz --output-document="$LCOV_ROOT/lcov.tar.gz" |
45 | | - tar xf "$LCOV_ROOT/lcov.tar.gz" --strip-components=1 -C $LCOV_ROOT |
46 | | - export PATH="$LCOV_ROOT/bin:$PATH" |
47 | | - which lcov |
| 42 | + - | |
| 43 | + if [ "$BUILD_UNIT_TESTS" ]; then |
| 44 | + # GCov 4.6 cannot handle the file structure |
| 45 | + export CXX="g++-4.8" |
| 46 | + export GCOV="gcov-4.8" |
48 | 47 |
|
49 | | - # Install coveralls tool |
50 | | - gem install coveralls-lcov |
51 | | - export GENERATE_COVERAGE=1 |
| 48 | + # Install newer lcov (1.9 seems to fail: http://gronlier.fr/blog/2015/01/adding-code-coverage-to-your-c-project/) |
| 49 | + export LCOV_ROOT="$HOME/lcov" |
| 50 | + mkdir -p "$LCOV_ROOT" |
| 51 | + wget http://ftp.de.debian.org/debian/pool/main/l/lcov/lcov_1.12.orig.tar.gz --output-document="$LCOV_ROOT/lcov.tar.gz" |
| 52 | + tar xf "$LCOV_ROOT/lcov.tar.gz" --strip-components=1 -C $LCOV_ROOT |
| 53 | + export PATH="$LCOV_ROOT/bin:$PATH" |
| 54 | + which lcov |
52 | 55 |
|
| 56 | + # Install coveralls tool |
| 57 | + gem install coveralls-lcov |
| 58 | + export GENERATE_COVERAGE=1 |
53 | 59 | else |
54 | | - export GCOV="gcov" # Just to have anything valid |
55 | | - export GENERATE_COVERAGE=0 |
| 60 | + # Install PlatformIO |
| 61 | + pip install -U platformio |
56 | 62 | fi |
57 | | - # Use clang 3.5 |
58 | | - - if [ "$CXX" = "clang++" ]; then export CXX="clang++-3.5"; export CC="clang-3.5"; fi |
59 | | - # - arduino --install-library "MIDIUSB" |
60 | 63 |
|
61 | 64 | script: |
62 | | - # Build examples with Arduino IDE on each available platform / board |
63 | | - # - build_main_platforms |
| 65 | + # Build unit tests & generate code coverage |
| 66 | + - | |
| 67 | + if [ "${BUILD_UNIT_TESTS}" ]; then |
| 68 | + mkdir build && cd build |
| 69 | + cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DBUILDER_ENABLE_PROFILING=${GENERATE_COVERAGE} --generator="Unix Makefiles" .. |
| 70 | + make all |
| 71 | + ctest --verbose |
| 72 | + fi |
64 | 73 |
|
65 | | - # Build and run unit tests with regular C++ compiler |
66 | | - - mkdir build && cd build |
67 | | - - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DBUILDER_ENABLE_PROFILING=${GENERATE_COVERAGE} --generator="Unix Makefiles" .. |
68 | | - - make all |
69 | | - - ctest --verbose |
| 74 | + # Build current example |
| 75 | + - | |
| 76 | + if [ ! "${BUILD_UNIT_TESTS}" ]; then |
| 77 | + platformio ci --lib="." --board=uno --board="due" --board="zero" --board="leonardo" |
| 78 | + fi |
70 | 79 |
|
71 | 80 | after_success: |
72 | | - - | |
| 81 | + - | |
73 | 82 | if [ "${GENERATE_COVERAGE}" ]; then |
74 | | - # Generate code coverage information & send to Coveralls |
75 | | - lcov --gcov-tool $GCOV --directory . --capture --output-file coverage.info |
76 | | - lcov --gcov-tool $GCOV --remove coverage.info 'test/*' '/usr/*' 'external/*' --output-file coverage.info |
77 | | - lcov --list coverage.info |
78 | | - coveralls-lcov --repo-token ${COVERALLS_TOKEN} coverage.info |
| 83 | + # Generate code coverage information & send to Coveralls |
| 84 | + lcov --gcov-tool $GCOV --directory . --capture --output-file coverage.info |
| 85 | + lcov --gcov-tool $GCOV --remove coverage.info 'test/*' '/usr/*' 'external/*' --output-file coverage.info |
| 86 | + lcov --list coverage.info |
| 87 | + coveralls-lcov --repo-token ${COVERALLS_TOKEN} coverage.info |
79 | 88 | fi |
80 | 89 |
|
81 | 90 | notifications: |
82 | | - email: false |
| 91 | + email: false |
0 commit comments