ci.yml 17 KB

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