ci.yml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  1. name: Continuous Integration
  2. on: [push, pull_request]
  3. jobs:
  4. lint:
  5. name: Lint
  6. runs-on: ubuntu-20.04
  7. steps:
  8. - name: Install
  9. run: sudo apt-get install -y clang-format
  10. - name: Checkout
  11. uses: actions/checkout@v2
  12. - name: Symlinks
  13. run: find * -type l -printf "::error::%p is a symlink. This is forbidden by the Arduino Library Specification." -exec false {} +
  14. - name: Clang-format
  15. run: |
  16. find src/ extras/ -name '*.[ch]pp' | xargs clang-format -i --verbose --style=file
  17. git diff --exit-code
  18. gcc:
  19. name: GCC
  20. needs: lint
  21. runs-on: ubuntu-20.04
  22. strategy:
  23. fail-fast: false
  24. matrix:
  25. include:
  26. - gcc: "4.4"
  27. - gcc: "4.6"
  28. - gcc: "4.7"
  29. - gcc: "4.8"
  30. - gcc: "4.9"
  31. - gcc: "5"
  32. - gcc: "6"
  33. - gcc: "7"
  34. cxxflags: -fsanitize=leak -fno-sanitize-recover=all
  35. - gcc: "8"
  36. cxxflags: -fsanitize=undefined -fno-sanitize-recover=all
  37. - gcc: "9"
  38. cxxflags: -fsanitize=address -fno-sanitize-recover=all
  39. - gcc: "10"
  40. steps:
  41. - name: Install
  42. run: |
  43. sudo add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ trusty main'
  44. sudo add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ trusty universe'
  45. sudo add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ xenial main'
  46. sudo add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ xenial universe'
  47. sudo add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ bionic main'
  48. sudo add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ bionic universe'
  49. sudo apt-get update
  50. sudo apt-get install -y gcc-${{ matrix.gcc }} g++-${{ matrix.gcc }}
  51. - name: Checkout
  52. uses: actions/checkout@v2
  53. - name: Configure
  54. run: cmake -DCMAKE_BUILD_TYPE=Debug .
  55. env:
  56. CC: gcc-${{ matrix.gcc }}
  57. CXX: g++-${{ matrix.gcc }}
  58. CXXFLAGS: ${{ matrix.cxxflags }}
  59. - name: Build
  60. run: cmake --build .
  61. - name: Test
  62. run: ctest --output-on-failure -C Debug .
  63. env:
  64. UBSAN_OPTIONS: print_stacktrace=1
  65. clang:
  66. name: Clang
  67. needs: lint
  68. runs-on: ubuntu-20.04
  69. strategy:
  70. fail-fast: false
  71. matrix:
  72. include:
  73. - clang: "3.5"
  74. cxxflags: "-stdlib=libc++"
  75. - clang: "3.6"
  76. cxxflags: "-stdlib=libc++"
  77. - clang: "3.7"
  78. cxxflags: "-stdlib=libc++"
  79. - clang: "3.8"
  80. cxxflags: "-stdlib=libc++"
  81. - clang: "3.9"
  82. cxxflags: "-stdlib=libc++"
  83. - clang: "4.0"
  84. cxxflags: "-stdlib=libc++"
  85. - clang: "5.0"
  86. - clang: "6.0"
  87. - clang: "7"
  88. - clang: "8"
  89. cxxflags: -fsanitize=leak -fno-sanitize-recover=all
  90. - clang: "9"
  91. cxxflags: -fsanitize=undefined -fno-sanitize-recover=all
  92. - clang: "10"
  93. cxxflags: -fsanitize=address -fno-sanitize-recover=all
  94. steps:
  95. - name: Install
  96. run: |
  97. sudo add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ trusty main'
  98. sudo add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ trusty universe'
  99. sudo add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ xenial main'
  100. sudo add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ xenial universe'
  101. sudo add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ bionic main'
  102. sudo add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ bionic universe'
  103. sudo apt-get update
  104. sudo apt-get install -y clang-${{ matrix.clang }}
  105. - name: Checkout
  106. uses: actions/checkout@v2
  107. - name: Configure
  108. run: cmake -DCMAKE_BUILD_TYPE=Debug .
  109. env:
  110. CC: clang-${{ matrix.clang }}
  111. CXX: clang++-${{ matrix.clang }}
  112. CXXFLAGS: >-
  113. ${{ matrix.cxxflags }}
  114. ${{ contains(matrix.cxxflags, 'libc++') && '-I/usr/lib/llvm-10/include/c++/v1/' || '' }}
  115. - name: Build
  116. run: cmake --build .
  117. - name: Test
  118. run: ctest --output-on-failure -C Debug .
  119. env:
  120. UBSAN_OPTIONS: print_stacktrace=1
  121. xcode:
  122. name: XCode
  123. needs: clang
  124. runs-on: macos-10.15
  125. strategy:
  126. fail-fast: false
  127. matrix:
  128. include:
  129. - xcode: "10.3"
  130. - xcode: "11.7"
  131. - xcode: "12.4"
  132. steps:
  133. - name: Checkout
  134. uses: actions/checkout@v2
  135. - name: Select XCode version
  136. run: sudo xcode-select --switch /Applications/Xcode_${{ matrix.xcode }}.app
  137. - name: Configure
  138. run: cmake -DCMAKE_BUILD_TYPE=Debug .
  139. - name: Build
  140. run: cmake --build .
  141. - name: Test
  142. run: ctest --output-on-failure -C Debug .
  143. # DISABLED: Running on AppVeyor instead because it supports older versions of the compiler
  144. # msvc:
  145. # name: Visual Studio
  146. # strategy:
  147. # fail-fast: false
  148. # matrix:
  149. # include:
  150. # - os: windows-2016
  151. # - os: windows-2019
  152. # runs-on: ${{ matrix.os }}
  153. # steps:
  154. # - name: Checkout
  155. # uses: actions/checkout@v2
  156. # - name: Configure
  157. # run: cmake -DCMAKE_BUILD_TYPE=Debug .
  158. # - name: Build
  159. # run: cmake --build .
  160. # - name: Test
  161. # run: ctest --output-on-failure -C Debug .
  162. arduino:
  163. name: Arduino
  164. needs: gcc
  165. strategy:
  166. fail-fast: false
  167. matrix:
  168. include:
  169. - arduino: "1.6.7"
  170. os: ubuntu-18.04 # java.lang.Error: Cannot load com.sun.java.swing.plaf.gtk.GTKLookAndFeel
  171. board: arduino:avr:uno
  172. - arduino: "1.8.2"
  173. board: arduino:samd:mkr1000
  174. runs-on: ${{ matrix.os || 'ubuntu-latest' }}
  175. steps:
  176. - name: Checkout
  177. uses: actions/checkout@v2
  178. - name: Build
  179. run: extras/ci/arduino.sh ${{ matrix.board }}
  180. env:
  181. BOARD: ${{ matrix.board }}
  182. VERSION: ${{ matrix.arduino }}
  183. platformio:
  184. name: PlatformIO
  185. needs: gcc
  186. runs-on: ubuntu-latest
  187. strategy:
  188. fail-fast: false
  189. matrix:
  190. include:
  191. - platform: atmelavr
  192. board: leonardo
  193. libraries:
  194. - SD
  195. - Ethernet
  196. - platform: espressif8266
  197. board: huzzah
  198. - platform: espressif32
  199. board: esp32dev
  200. libraries:
  201. - Ethernet
  202. - platform: atmelsam
  203. board: mkr1000USB
  204. libraries:
  205. - SD
  206. - Ethernet
  207. - platform: teensy
  208. board: teensy31
  209. - platform: ststm32
  210. board: adafruit_feather_f405
  211. libraries:
  212. - SD
  213. - Ethernet
  214. - platform: nordicnrf52
  215. board: adafruit_feather_nrf52840
  216. libraries:
  217. - SD
  218. - Ethernet
  219. steps:
  220. - name: Checkout
  221. uses: actions/checkout@v2
  222. - name: Set up cache for pip
  223. uses: actions/cache@v2
  224. with:
  225. path: ~/.cache/pip
  226. key: ${{ runner.os }}-pip
  227. - name: Set up Python 3.x
  228. uses: actions/setup-python@v2
  229. with:
  230. python-version: "3.x"
  231. - name: Install PlatformIO
  232. run: pip install platformio
  233. - name: Install adafruit-nrfutil
  234. if: ${{ matrix.platform == 'nordicnrf52' }}
  235. run: pip install adafruit-nrfutil
  236. - name: Set up cache for platformio
  237. uses: actions/cache@v2
  238. with:
  239. path: ~/.platformio
  240. key: ${{ runner.os }}-platformio-${{ matrix.platform }}
  241. - name: Install platform "${{ matrix.platform }}"
  242. run: platformio platform install ${{ matrix.platform }}
  243. - name: Install libraries
  244. if: ${{ matrix.libraries }}
  245. run: platformio lib install arduino-libraries/${{ join(matrix.libraries, ' arduino-libraries/') }}
  246. - name: Build JsonConfigFile
  247. run: platformio ci "examples/JsonConfigFile/JsonConfigFile.ino" -l '.' -b ${{ matrix.board }}
  248. - name: Build JsonFilterExample
  249. run: platformio ci "examples/JsonFilterExample/JsonFilterExample.ino" -l '.' -b ${{ matrix.board }}
  250. - name: Build JsonGeneratorExample
  251. run: platformio ci "examples/JsonGeneratorExample/JsonGeneratorExample.ino" -l '.' -b ${{ matrix.board }}
  252. - name: Build JsonHttpClient
  253. run: platformio ci "examples/JsonHttpClient/JsonHttpClient.ino" -l '.' -b ${{ matrix.board }}
  254. - name: Build JsonParserExample
  255. run: platformio ci "examples/JsonParserExample/JsonParserExample.ino" -l '.' -b ${{ matrix.board }}
  256. - name: Build JsonServer
  257. if: ${{ matrix.platform != 'espressif32' }}
  258. run: platformio ci "examples/JsonServer/JsonServer.ino" -l '.' -b ${{ matrix.board }}
  259. - name: Build JsonUdpBeacon
  260. run: platformio ci "examples/JsonUdpBeacon/JsonUdpBeacon.ino" -l '.' -b ${{ matrix.board }}
  261. - name: Build MsgPackParser
  262. run: platformio ci "examples/MsgPackParser/MsgPackParser.ino" -l '.' -b ${{ matrix.board }}
  263. - name: Build ProgmemExample
  264. run: platformio ci "examples/ProgmemExample/ProgmemExample.ino" -l '.' -b ${{ matrix.board }}
  265. - name: Build StringExample
  266. run: platformio ci "examples/StringExample/StringExample.ino" -l '.' -b ${{ matrix.board }}
  267. - name: PlatformIO prune
  268. if: ${{ always() }}
  269. run: platformio system prune -f
  270. particle:
  271. name: Particle
  272. needs: gcc
  273. runs-on: ubuntu-latest
  274. if: github.event_name == 'push'
  275. strategy:
  276. fail-fast: false
  277. matrix:
  278. include:
  279. - board: argon
  280. steps:
  281. - name: Checkout
  282. uses: actions/checkout@v2
  283. - name: Install Particle CLI
  284. run: sudo npm install -g particle-cli
  285. - name: Login to Particle
  286. run: particle login -t "${{ secrets.PARTICLE_TOKEN }}"
  287. - name: Compile
  288. run: extras/ci/particle.sh ${{ matrix.board }}
  289. arm:
  290. name: GCC for ARM processor
  291. needs: gcc
  292. runs-on: ubuntu-20.04
  293. steps:
  294. - name: Install
  295. run: |
  296. sudo apt-get update
  297. sudo apt-get install -y g++-arm-linux-gnueabihf
  298. - name: Checkout
  299. uses: actions/checkout@v2
  300. - name: Configure
  301. run: cmake .
  302. env:
  303. CC: arm-linux-gnueabihf-gcc
  304. CXX: arm-linux-gnueabihf-g++
  305. - name: Build
  306. run: cmake --build .
  307. coverage:
  308. needs: gcc
  309. name: Coverage
  310. runs-on: ubuntu-20.04
  311. steps:
  312. - name: Install
  313. run: sudo apt-get install -y lcov ninja-build
  314. - name: Checkout
  315. uses: actions/checkout@v2
  316. - name: Configure
  317. run: cmake -G Ninja -DCOVERAGE=true .
  318. - name: Build
  319. run: ninja
  320. - name: Test
  321. run: ctest -LE 'WillFail|Fuzzing' -T test
  322. - name: lcov --capture
  323. run: lcov --capture --no-external --directory . --output-file coverage.info
  324. - name: lcov --remove
  325. run: lcov --remove coverage.info "$(pwd)/extras/*" --output-file coverage_filtered.info
  326. - name: genhtml
  327. run: mkdir coverage && genhtml coverage_filtered.info -o coverage -t ArduinoJson
  328. - name: Upload HTML report
  329. uses: actions/upload-artifact@v2
  330. with:
  331. name: Coverage report
  332. path: coverage
  333. - name: Upload to Coveralls
  334. uses: coverallsapp/github-action@master
  335. with:
  336. github-token: ${{ secrets.GITHUB_TOKEN }}
  337. path-to-lcov: coverage_filtered.info
  338. valgrind:
  339. needs: gcc
  340. name: Valgrind
  341. runs-on: ubuntu-20.04
  342. steps:
  343. - name: Install
  344. run: sudo apt-get install -y valgrind ninja-build
  345. - name: Checkout
  346. uses: actions/checkout@v2
  347. - name: Configure
  348. run: cmake -G Ninja -D MEMORYCHECK_COMMAND_OPTIONS="--error-exitcode=1 --leak-check=full" .
  349. - name: Build
  350. run: ninja
  351. - name: Memcheck
  352. run: ctest -LE WillFail -T memcheck
  353. id: memcheck
  354. - name: MemoryChecker.*.log
  355. run: cat Testing/Temporary/MemoryChecker.*.log
  356. if: failure()
  357. clang-tidy:
  358. needs: clang
  359. name: Clang-Tidy
  360. runs-on: ubuntu-20.04
  361. steps:
  362. - name: Install
  363. run: sudo apt-get install -y clang-tidy cmake ninja-build
  364. - name: Checkout
  365. uses: actions/checkout@v2
  366. - name: Configure
  367. run: cmake -G Ninja -DCMAKE_CXX_CLANG_TIDY="clang-tidy-10;--warnings-as-errors=*" -DCMAKE_BUILD_TYPE=Debug .
  368. env:
  369. CC: clang-10
  370. CXX: clang++-10
  371. - name: Check
  372. run: cmake --build . -- -k 0
  373. amalgamate-h:
  374. needs: gcc
  375. name: Amalgamate ArduinoJson.h
  376. runs-on: ubuntu-20.04
  377. steps:
  378. - name: Checkout
  379. uses: actions/checkout@v2
  380. - name: Amalgamate
  381. id: amalgamate
  382. run: |
  383. if [[ $GITHUB_REF == refs/tags/* ]]; then
  384. VERSION=${GITHUB_REF#refs/tags/}
  385. else
  386. VERSION=${GITHUB_SHA::7}
  387. fi
  388. INPUT=src/ArduinoJson.h
  389. OUTPUT=ArduinoJson-$VERSION.h
  390. extras/scripts/build-single-header.sh "$INPUT" "$OUTPUT"
  391. echo ::set-output name=filename::${OUTPUT}
  392. - name: Smoke test
  393. run: |
  394. g++ -x c++ - <<END
  395. #include "${{ steps.amalgamate.outputs.filename }}"
  396. int main() {
  397. StaticJsonDocument<300> doc;
  398. deserializeJson(doc, "{}");
  399. }
  400. END
  401. - name: Upload artifact
  402. uses: actions/upload-artifact@v2
  403. with:
  404. name: Single headers
  405. path: ${{ steps.amalgamate.outputs.filename }}
  406. amalgamate-hpp:
  407. needs: gcc
  408. name: Amalgamate ArduinoJson.hpp
  409. runs-on: ubuntu-20.04
  410. steps:
  411. - name: Checkout
  412. uses: actions/checkout@v2
  413. - name: Amalgamate
  414. id: amalgamate
  415. run: |
  416. if [[ $GITHUB_REF == refs/tags/* ]]; then
  417. VERSION=${GITHUB_REF#refs/tags/}
  418. else
  419. VERSION=${GITHUB_SHA::7}
  420. fi
  421. INPUT=src/ArduinoJson.hpp
  422. OUTPUT=ArduinoJson-$VERSION.hpp
  423. extras/scripts/build-single-header.sh "$INPUT" "$OUTPUT"
  424. echo ::set-output name=filename::${OUTPUT}
  425. - name: Smoke test
  426. run: |
  427. g++ -x c++ - <<END
  428. #include "${{ steps.amalgamate.outputs.filename }}"
  429. int main() {
  430. ArduinoJson::StaticJsonDocument<300> doc;
  431. deserializeJson(doc, "{}");
  432. }
  433. END
  434. - name: Upload artifact
  435. uses: actions/upload-artifact@v2
  436. with:
  437. name: Single headers
  438. path: ${{ steps.amalgamate.outputs.filename }}
  439. esp-idf:
  440. needs: gcc
  441. name: ESP-IDF
  442. runs-on: ubuntu-latest
  443. steps:
  444. - name: Setup cache
  445. uses: actions/cache@v2
  446. with:
  447. path: ~/.espressif
  448. key: ${{ runner.os }}-esp-idf
  449. - name: Checkout ArduinoJson
  450. uses: actions/checkout@v2
  451. - name: Checkout ESP-IDF
  452. uses: actions/checkout@v2
  453. with:
  454. repository: espressif/esp-idf
  455. path: esp-idf
  456. submodules: true
  457. - name: Install ESP-IDF
  458. run: ./esp-idf/install.sh
  459. - name: Add component
  460. # NOTE: we cannot commit the symlink because the Arduino Library Specification forbids it.
  461. run: |
  462. mkdir -p extras/ci/espidf/components
  463. ln -s $PWD extras/ci/espidf/components/ArduinoJson
  464. - name: Build example
  465. run: |
  466. source esp-idf/export.sh
  467. cd extras/ci/espidf
  468. idf.py build