Traxxas TQ 1st gen: try 2
[DIY-Multiprotocol-TX-Module.git] / _travis.yml
blob00fefc63e4b64f58c3a13418388b28c3d2d5302f
1 os: linux
2 dist: bionic
3 language: c
5 env:
6   jobs:
7     - BOARD="multi4in1:avr:multiatmega328p:bootloader=none"
8     - BOARD="multi4in1:avr:multiatmega328p:bootloader=optiboot"
9     - BOARD="multi4in1:avr:multixmega32d4"
10     - BOARD="multi4in1:STM32F1:multi5in1t18int"
11     - BOARD="multi4in1:STM32F1:multistm32f103cb:debug_option=none"
12     - BOARD="multi4in1:STM32F1:multistm32f103cb:debug_option=native"
13     - BOARD="multi4in1:STM32F1:multistm32f103cb:debug_option=ftdi"
14     - BOARD="multi4in1:STM32F1:multistm32f103c8:debug_option=none"
16 notifications:
17   email: false
19 before_install:
20   # Fetch the tag information for the current branch
21   - git fetch origin --tags
23   # Publish the buildroot script folder
24   - chmod +x ${TRAVIS_BUILD_DIR}/buildroot/bin/*
25   - export PATH=${TRAVIS_BUILD_DIR}/buildroot/bin/:${PATH}
27   # Helper functions for the builds
28   - buildMulti() { start_fold config_diff; travis_time_start; git diff Multiprotocol/_Config.h; end_fold config_diff; exitcode=0; BUILDCMD="arduino-cli compile -b $BOARD Multiprotocol/Multiprotocol.ino --build-path ${TRAVIS_BUILD_DIR}/build/"; echo $BUILDCMD; $BUILDCMD; if [ $? -ne 0 ]; then exitcode=1; fi; echo; return $exitcode; }
29   - buildProtocol() { exitcode=0; opt_disable $ALL_PROTOCOLS; opt_enable $1; buildMulti; if [ $? -ne 0 ]; then exitcode=1; fi; return $exitcode; }
30   - buildEachProtocol() { exitcodesum=0; for PROTOCOL in $ALL_PROTOCOLS ; do printf "\e[33;1mBuilding $PROTOCOL\e[0m"; buildProtocol $PROTOCOL; if [ $? -ne 0 ]; then exitcodesum=$((exitcodesum + 1)); fi; done; return $exitcodesum; }
31   - buildRFModule() { exitcode=0; opt_disable $ALL_RFMODULES; opt_enable $1; buildMulti; if [ $? -ne 0 ]; then exitcode=1; fi; return $exitcode; }
32   - buildEachRFModule() { exitcodesum=0; for RFMODULE in $ALL_RFMODULES; do printf "\e[33;1mBuilding $RFMODULE\e[0m"; buildRFModule $RFMODULE; if [ $? -ne 0 ]; then exitcodesum=$((exitcodesum + 1)); fi; done; return $exitcodesum; }
33   - buildDefault() { exitcode=0; printf "\n\e[33;1mBuilding default configuration\e[0m\n"; buildMulti; if [ $? -ne 0 ]; then exitcode=1; fi; return $exitcode; }
34   - buildSerialOnly() { exitcode=0; printf "\n\e[33;1mBuilding serial mode only\e[0m\n"; opt_disable ENABLE_PPM; opt_enable ENABLE_SERIAL; buildMulti; if [ $? -ne 0 ]; then exitcode=1; fi; return $exitcode; }
35   - buildPPMOnly() { exitcode=0; printf "\n\e[33;1mBuilding PPM mode only\e[0m\n"; opt_enable ENABLE_PPM; opt_disable ENABLE_SERIAL; buildMulti; if [ $? -ne 0 ]; then exitcode=1; fi; return $exitcode; }
36   - export -f buildMulti
38   # Function to build the release files - dependent on board type.
39   # Release build scripts are located in buildroot/bin.
40   - if [[ "$BOARD" == "multi4in1:avr:multixmega32d4" ]]; then
41       buildReleaseFiles(){
42         build_release_orx;
43       };
44     elif [[ "$BOARD" == "multi4in1:avr:multiatmega328p:bootloader=none" ]]; then
45       buildReleaseFiles(){
46         build_release_avr_noboot;
47       };
48     elif [[ "$BOARD" == "multi4in1:avr:multiatmega328p:bootloader=optiboot" ]]; then
49       buildReleaseFiles(){
50         build_release_avr_optiboot;
51       };
52     elif [[ "$BOARD" == "multi4in1:STM32F1:multistm32f103cb:debug_option=none" ]]; then
53       buildReleaseFiles(){
54         build_release_stm32f1_no_debug;
55       };
56     elif [[ "$BOARD" == "multi4in1:STM32F1:multistm32f103cb:debug_option=native" ]]; then
57       buildReleaseFiles(){
58         build_release_stm32f1_native_debug;
59       };
60     elif [[ "$BOARD" == "multi4in1:STM32F1:multistm32f103cb:debug_option=ftdi" ]]; then
61       buildReleaseFiles(){
62         build_release_stm32f1_serial_debug;
63       };
64     elif [[ "$BOARD" == "multi4in1:STM32F1:multi5in1t18int" ]]; then
65       buildReleaseFiles(){
66         build_release_stm32f1_t18int;
67       };
68     else
69       buildReleaseFiles() { printf "No release files for this board."; };
70     fi
72 install:
73   # Install Arduino CLI
74   - mkdir ~/arduino-cli
75   - curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR=~/arduino-cli sh -s 0.13.0;
76   - export PATH=$PATH:$HOME/arduino-cli
78   # Update the board url and package index
79   - arduino-cli core update-index --additional-urls https://raw.githubusercontent.com/pascallanger/DIY-Multiprotocol-TX-Module-Boards/master/package_multi_4in1_board_index.json
81   # Install the STM32 board if needed
82   - if [[ "$BOARD" =~ "multi4in1:STM32F1:" ]]; then
83       arduino-cli core install multi4in1:STM32F1 --additional-urls https://raw.githubusercontent.com/pascallanger/DIY-Multiprotocol-TX-Module-Boards/master/package_multi_4in1_board_index.json;
84     fi
86   # Install the AVR board if needed
87   - if [[ "$BOARD" =~ "multi4in1:avr:" ]]; then
88       arduino-cli core install arduino:avr;
89       arduino-cli core install multi4in1:avr --additional-urls https://raw.githubusercontent.com/pascallanger/DIY-Multiprotocol-TX-Module-Boards/master/package_multi_4in1_board_index.json;
90     fi
92 before_script:
93   # Export all the variables
94   - set -a
96   # Change current working directory to the build dir
97   - cd ${TRAVIS_BUILD_DIR}
99   # Create somwhere to put the exported binaries
100   - mkdir ./binaries
102   # Log the initial Multi config 
103   - cat Multiprotocol/_Config.h
105   # Back up the configuration
106   - cp Multiprotocol/_Config.h ./_Config.h.bak
108   # Get the firmware version number from the source
109   - MAJOR_VERSION=$(grep "VERSION_MAJOR" "Multiprotocol/Multiprotocol.h" | awk -v N=3 '{gsub(/\r/,""); print $N}')
110   - MINOR_VERSION=$(grep "VERSION_MINOR" "Multiprotocol/Multiprotocol.h" | awk -v N=3 '{gsub(/\r/,""); print $N}')
111   - REVISION_VERSION=$(grep "VERSION_REVISION" "Multiprotocol//Multiprotocol.h" | awk -v N=3 '{gsub(/\r/,""); print $N}')
112   - PATCH_VERSION=$(grep "VERSION_PATCH" "Multiprotocol//Multiprotocol.h" | awk -v N=3 '{gsub(/\r/,""); print $N}')
113   - MULTI_VERSION=$MAJOR_VERSION.$MINOR_VERSION.$REVISION_VERSION.$PATCH_VERSION
115   # Derive the Multi protocols from the Multi source
116   - A7105_PROTOCOLS=$(sed -n 's/[\/\/]*[[:blank:]]*#define[[:blank:]]*\([[:alnum:]_]*_A7105_INO\)\(.*\)/\1/p' Multiprotocol/_Config.h)
117   - CC2500_PROTOCOLS=$(sed -n 's/[\/\/]*[[:blank:]]*#define[[:blank:]]*\([[:alnum:]_]*_CC2500_INO\)\(.*\)/\1/p' Multiprotocol/_Config.h)
118   - CYRF6936_PROTOCOLS=$(sed -n 's/[\/\/]*[[:blank:]]*#define[[:blank:]]*\([[:alnum:]_]*_CYRF6936_INO\)\(.*\)/\1/p' Multiprotocol/_Config.h)
119   - NRF24L01_PROTOCOLS=$(sed -n 's/[\/\/]*[[:blank:]]*#define[[:blank:]]*\([[:alnum:]_]*_NRF24L01_INO\)\(.*\)/\1/p' Multiprotocol/_Config.h)
120   - SX1276_PROTOCOLS=$(sed -n 's/[\/\/]*[[:blank:]]*#define[[:blank:]]*\([[:alnum:]_]*_SX1276_INO\)\(.*\)/\1/p' Multiprotocol/_Config.h)
122   # Get the full set of protocols for each board
123   - if [[ "$BOARD" =~ "multi4in1:avr:multixmega32d4" ]]; then
124       ALL_PROTOCOLS=$(echo $CYRF6936_PROTOCOLS);
125     elif [[ "$BOARD" =~ "multi4in1:avr:multiatmega328p:" ]]; then
126       ALL_PROTOCOLS=$(echo $A7105_PROTOCOLS $CC2500_PROTOCOLS $CYRF6936_PROTOCOLS $NRF24L01_PROTOCOLS);
127     elif [[ "$BOARD" =~ "multi4in1:STM32F1:" ]]; then
128       ALL_PROTOCOLS=$(echo $A7105_PROTOCOLS $CC2500_PROTOCOLS $CYRF6936_PROTOCOLS $NRF24L01_PROTOCOLS $SX1276_PROTOCOLS);
129     fi
130   - echo $ALL_PROTOCOLS
132   # Declare all the installed modules
133   - if [[ "$BOARD" =~ "multi4in1:avr:multixmega32d4" ]]; then
134       ALL_RFMODULES=$(echo CYRF6936_INSTALLED);
135     elif [[ "$BOARD" =~ "multi4in1:avr:multiatmega328p:" ]]; then
136       ALL_RFMODULES=$(echo A7105_INSTALLED CYRF6936_INSTALLED CC2500_INSTALLED NRF24L01_INSTALLED);
137     elif [[ "$BOARD" =~ "multi4in1:STM32F1:" ]]; then
138       ALL_RFMODULES=$(echo A7105_INSTALLED CYRF6936_INSTALLED CC2500_INSTALLED NRF24L01_INSTALLED SX1276_INSTALLED);
139     fi
140   - echo $ALL_RFMODULES
142   # Disable CHECK_FOR_BOOTLOADER when not needed
143   - if [[ "$BOARD" == "multi4in1:avr:multiatmega328p:bootloader=none" ]]; then
144       opt_disable CHECK_FOR_BOOTLOADER;
145     fi
147   # Trim the enabled protocols down for the STM32F103CB board with debugging
148   - if [[ "$BOARD" == "multi4in1:STM32F1:multistm32f103cb:debug_option=ftdi" ]] || [[ "$BOARD" == "multi4in1:STM32F1:multistm32f103cb:debug_option=native" ]]; then
149       opt_disable $ALL_PROTOCOLS;
150       opt_enable FRSKYX_CC2500_INO AFHDS2A_A7105_INO MJXQ_NRF24L01_INO DSM_CYRF6936_INO;
151     fi
153   # Trim the enabled protocols down for the STM32F103C8 board
154   - if [[ "$BOARD" == "multi4in1:STM32F1:multistm32f103c8:debug_option=none" ]]; then
155       opt_disable $ALL_PROTOCOLS;
156       opt_enable FRSKYX_CC2500_INO AFHDS2A_A7105_INO MJXQ_NRF24L01_INO DSM_CYRF6936_INO;
157     fi
159   # Trim the enabled protocols down for the Atmega328p board
160   - if [[ "$BOARD" =~ "multi4in1:avr:multiatmega328p:" ]]; then
161       opt_disable $ALL_PROTOCOLS;
162       opt_enable FRSKYX_CC2500_INO AFHDS2A_A7105_INO MJXQ_NRF24L01_INO DSM_CYRF6936_INO;
163     fi
165   # Useful Travis functions
166   - export -f travis_fold
167   - export -f travis_nanoseconds
168   - export -f travis_time_start
169   - export -f travis_time_finish
170   - start_fold() { echo -e "travis_fold:start:$1"; }
171   - end_fold() { echo -e "\ntravis_fold:end:$1\r"; }
173 script:
174   # Build with default configuration - all protocols are enabled for STM32; a subset of protocols for Atmega or STM32 debugging
175   - buildDefault
177   # Serial only
178   - buildSerialOnly
180   # PPM only
181   - buildPPMOnly
183   # Re-enable PPM and serial
184   - opt_enable ENABLE_SERIAL
185   - opt_enable ENABLE_PPM
187   # Build for each RF module individually
188   - buildEachRFModule
190   # Restore the default configuration
191   - cp ./_Config.h.bak Multiprotocol/_Config.h
193   # Build each protocol individually
194   - buildEachProtocol
196   # Restore the default configuration
197   - cp ./_Config.h.bak Multiprotocol/_Config.h
199   # Builds the files for a release - always built, but only copied to Github if the test is tagged as a release
200   - buildReleaseFiles
202 deploy:
203   provider: releases
204   token:
205     secure: KGXaoqvd8rbZ3AZtL9Rrn1JYiocGsPaihRUyR8gM8vTfvH9WYAE1+h6SzROQOuJSwr89MvTo3SBOTlM/0PDBnEGLec9Irt7cwO0xf9xM2vPuUG8DYcUzmJJzME9dkn/7qHof1JGgRpp1duUAN1triE9NxhKxL1hbs+tUUbDPAejxwoFNfnta/T4PfD6xmkZNJbneIfYFuFgyLpwwFhuUy9JP7s1AFOiT+fCHxPaZrPn5GsXqAi95Cb7Q3w1iVSt3BmrGxL2j3CeNpWzFY1RrMdc8ay+ppOhSPEIl2vyM7VeLRRBL3EVeFWkiS4ywevqw70wOivTczluv3OeuIJAe5o2UU+w5+59c7+i44Nih23PDAZBhAG5JkLUYUN0XUJpXJ5ZlZsb8IS8sI1txlZa5tNVoXO9+soGEY4rKSpZaPptuENm792CzzAjcaUI9pOFJ/0CBoSCbu5MpM/plkJCMd8fY27EE8cNYvolMuRATNlXs7h9mURGR69pmcR1jFShH+A7Kyp1S1sH19sGCEU16rt2aAtf2FadFg/gKACC2y9rB3wBb4Qnapu2AwNRlTYNuU1+G+kb2FXRwMl04q+38S+cIBHH9NHfdftp9MRPf8Ekatojs92be/Ux21S+hcA7sx/DV22Dl45V6l4mXzR7U4x1nQcdn1SGuy5I4lL6IYCk=
206   skip_cleanup: true
207   file_glob: true
208   file: binaries/*
209   on:
210     tags: true