language: c
env:
  - BD=esp8266:esp8266:nodemcuv2:CpuFrequency=80,FlashSize=4M3M
  - BD=esp8266:esp8266:d1_mini:CpuFrequency=80,FlashSize=4M3M
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-1.8.2-linux64.tar.xz
  - tar xf arduino-1.8.2-linux64.tar.xz
  - sudo mv arduino-1.8.2 /usr/local/share/arduino
  - sudo ln -s /usr/local/share/arduino/arduino /usr/local/bin/arduino
  - wget https://raw.githubusercontent.com/google/styleguide/gh-pages/cpplint/cpplint.py
install:
  - ln -s $PWD /usr/local/share/arduino/libraries/
  - git clone https://github.com/tzapu/WiFiManager.git /usr/local/share/arduino/libraries/WiFiManager
  - git clone https://github.com/knolleary/pubsubclient.git /usr/local/share/arduino/libraries/PubSubClient
  - arduino --pref "boardsmanager.additional.urls=http://arduino.esp8266.com/stable/package_esp8266com_index.json" --save-prefs
  - arduino --install-boards esp8266:esp8266
  - arduino --board $BD --save-prefs
  - arduino --pref "compiler.warning_level=all" --save-prefs
  - sudo apt-get install jq
  - sudo pip install pylint
script:
  # Check that everything compiles.
  - arduino --verify --board $BD $PWD/examples/IRrecvDemo/IRrecvDemo.ino
  - arduino --verify --board $BD $PWD/examples/IRGCSendDemo/IRGCSendDemo.ino
  - arduino --verify --board $BD $PWD/examples/IRGCTCPServer/IRGCTCPServer.ino
  - arduino --verify --board $BD $PWD/examples/IRServer/IRServer.ino
  - arduino --verify --board $BD $PWD/examples/IRrecvDumpV2/IRrecvDumpV2.ino
  - arduino --verify --board $BD $PWD/examples/IRsendDemo/IRsendDemo.ino
  - arduino --verify --board $BD $PWD/examples/JVCPanasonicSendDemo/JVCPanasonicSendDemo.ino
  - arduino --verify --board $BD $PWD/examples/TurnOnDaikinAC/TurnOnDaikinAC.ino
  - arduino --verify --board $BD $PWD/examples/TurnOnFujitsuAC/TurnOnFujitsuAC.ino
  - arduino --verify --board $BD $PWD/examples/TurnOnKelvinatorAC/TurnOnKelvinatorAC.ino
  - arduino --verify --board $BD $PWD/examples/TurnOnMitsubishiAC/TurnOnMitsubishiAC.ino
  - arduino --verify --board $BD $PWD/examples/IRsendProntoDemo/IRsendProntoDemo.ino
  - arduino --verify --board $BD $PWD/examples/TurnOnTrotecAC/TurnOnTrotecAC.ino
  - arduino --verify --board $BD $PWD/examples/LGACSend/LGACSend.ino
  - arduino --verify --board $BD $PWD/examples/TurnOnArgoAC/TurnOnArgoAC.ino
  - arduino --verify --board $BD $PWD/examples/IRMQTTServer/IRMQTTServer.ino
  - arduino --verify --board $BD $PWD/examples/TurnOnToshibaAC/TurnOnToshibaAC.ino
  # Also check the tools programs compile.
  - (cd tools; make all)
  # Check for lint issues.
  - shopt -s nullglob
  - python cpplint.py --extensions=c,cc,cpp,ino --headers=h,hpp {src,test,tools}/*.{h,c,cc,cpp,hpp,ino} examples/*/*.{h,c,cc,cpp,hpp,ino}
  - pylint {src,test,tools}/*.py
  - shopt -u nullglob
  # Build and run the unit tests.
  - (cd test; make run)
  - (cd tools; make run_tests)
  # Check the version numbers match.
  - LIB_VERSION=$(egrep "^#define\s+_IRREMOTEESP8266_VERSION_\s+" src/IRremoteESP8266.h  | cut -d\" -f2)
  - test ${LIB_VERSION} == "$(jq -r .version library.json)"
  - grep -q "^version=${LIB_VERSION}$" library.properties

notifications:
  email:
    on_success: change
    on_failure: change
