language: generic
env:
  global:
    - IDE_VERSION=1.8.13
  matrix:
    - EXAMPLE="AdafruitHuzzahESP8266" BOARD="esp8266:esp8266:huzzah:eesz=4M3M,xtal=80"
    - EXAMPLE="AdafruitHuzzahESP8266Secure" BOARD="esp8266:esp8266:huzzah:eesz=4M3M,xtal=80"
    - EXAMPLE="ArduinoEthernetShield" BOARD="arduino:avr:uno"
    - EXAMPLE="ArduinoMKRGSM1400" BOARD="arduino:samd:mkrgsm1400"
    - EXAMPLE="ArduinoMKRGSM1400Secure" BOARD="arduino:samd:mkrgsm1400"
    - EXAMPLE="ArduinoWiFi101Secure" BOARD="arduino:avr:uno"
    - EXAMPLE="ArduinoWiFiShield" BOARD="arduino:avr:uno"
    - EXAMPLE="ArduinoYun" BOARD="arduino:avr:yun"
    - EXAMPLE="ArduinoYunSecure" BOARD="arduino:avr:yun"
    - EXAMPLE="ESP32DevelopmentBoard" BOARD="espressif:esp32:esp32:FlashFreq=80"
    - EXAMPLE="ESP32DevelopmentBoardSecure" BOARD="espressif:esp32:esp32:FlashFreq=80"
before_install:
  - /sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_1.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :1 -ac -screen 0 1280x1024x16
  - sleep 3
  - export DISPLAY=:1.0
  - wget http://downloads.arduino.cc/arduino-$IDE_VERSION-linux64.tar.xz
  - tar xf arduino-$IDE_VERSION-linux64.tar.xz
  - mv arduino-$IDE_VERSION ~/arduino-ide
  - export PATH=$PATH:~/arduino-ide
  - if [[ "$BOARD" =~ "esp8266:esp8266:" ]]; then
      arduino --pref "boardsmanager.additional.urls=http://arduino.esp8266.com/stable/package_esp8266com_index.json" --install-boards esp8266:esp8266;
      arduino --pref "boardsmanager.additional.urls=" --save-prefs;
    fi
  - if [[ "$BOARD" =~ "espressif:esp32:" ]]; then
      mkdir -p ~/Arduino/hardware/espressif &&
      cd ~/Arduino/hardware/espressif &&
      git clone https://github.com/espressif/arduino-esp32.git esp32 &&
      cd esp32/tools/ &&
      python get.py &&
      cd $TRAVIS_BUILD_DIR;
    fi
  - if [[ "$BOARD" =~ "arduino:samd:mkrgsm1400" ]]; then
      arduino --install-boards arduino:samd;
      arduino --install-library MKRGSM;
    fi
  - arduino --install-library WiFi101
install:
  - mkdir -p ~/Arduino/libraries
  - ln -s $PWD ~/Arduino/libraries/.
script:
  - arduino --verbose-build --verify --board $BOARD $PWD/examples/$EXAMPLE/$EXAMPLE.ino;
