test.yml 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776
  1. name: test
  2. on: [push, pull_request]
  3. defaults:
  4. run:
  5. shell: bash -euv -o pipefail {0}
  6. env:
  7. CFLAGS: -Werror
  8. MAKEFLAGS: -j
  9. TESTFLAGS: -k
  10. BENCHFLAGS:
  11. jobs:
  12. # run tests
  13. test:
  14. runs-on: ubuntu-22.04
  15. strategy:
  16. fail-fast: false
  17. matrix:
  18. arch: [x86_64, thumb, mips, powerpc]
  19. steps:
  20. - uses: actions/checkout@v2
  21. - name: install
  22. run: |
  23. # need a few things
  24. sudo apt-get update -qq
  25. sudo apt-get install -qq gcc python3 python3-pip
  26. pip3 install toml
  27. gcc --version
  28. python3 --version
  29. # cross-compile with ARM Thumb (32-bit, little-endian)
  30. - name: install-thumb
  31. if: ${{matrix.arch == 'thumb'}}
  32. run: |
  33. sudo apt-get install -qq \
  34. gcc-arm-linux-gnueabi \
  35. libc6-dev-armel-cross \
  36. qemu-user
  37. echo "CC=arm-linux-gnueabi-gcc -mthumb --static" >> $GITHUB_ENV
  38. echo "EXEC=qemu-arm" >> $GITHUB_ENV
  39. arm-linux-gnueabi-gcc --version
  40. qemu-arm -version
  41. # cross-compile with MIPS (32-bit, big-endian)
  42. - name: install-mips
  43. if: ${{matrix.arch == 'mips'}}
  44. run: |
  45. sudo apt-get install -qq \
  46. gcc-mips-linux-gnu \
  47. libc6-dev-mips-cross \
  48. qemu-user
  49. echo "CC=mips-linux-gnu-gcc --static" >> $GITHUB_ENV
  50. echo "EXEC=qemu-mips" >> $GITHUB_ENV
  51. mips-linux-gnu-gcc --version
  52. qemu-mips -version
  53. # cross-compile with PowerPC (32-bit, big-endian)
  54. - name: install-powerpc
  55. if: ${{matrix.arch == 'powerpc'}}
  56. run: |
  57. sudo apt-get install -qq \
  58. gcc-powerpc-linux-gnu \
  59. libc6-dev-powerpc-cross \
  60. qemu-user
  61. echo "CC=powerpc-linux-gnu-gcc --static" >> $GITHUB_ENV
  62. echo "EXEC=qemu-ppc" >> $GITHUB_ENV
  63. powerpc-linux-gnu-gcc --version
  64. qemu-ppc -version
  65. # does littlefs compile?
  66. - name: test-build
  67. run: |
  68. make clean
  69. make build
  70. # make sure example can at least compile
  71. - name: test-example
  72. run: |
  73. make clean
  74. sed -n '/``` c/,/```/{/```/d; p}' README.md > test.c
  75. CFLAGS="$CFLAGS \
  76. -Duser_provided_block_device_read=NULL \
  77. -Duser_provided_block_device_prog=NULL \
  78. -Duser_provided_block_device_erase=NULL \
  79. -Duser_provided_block_device_sync=NULL \
  80. -include stdio.h" \
  81. make all
  82. rm test.c
  83. # run the tests!
  84. - name: test
  85. run: |
  86. make clean
  87. # TODO include this by default?
  88. TESTFLAGS="$TESTFLAGS -Pnone,linear" make test
  89. # collect coverage info
  90. #
  91. # Note the goal is to maximize coverage in the small, easy-to-run
  92. # tests, so we intentionally exclude more aggressive powerloss testing
  93. # from coverage results
  94. - name: cov
  95. if: ${{matrix.arch == 'x86_64'}}
  96. run: |
  97. make lfs.cov.csv
  98. ./scripts/cov.py -u lfs.cov.csv
  99. mkdir -p cov
  100. cp lfs.cov.csv cov/cov.csv
  101. # find compile-time measurements
  102. - name: sizes
  103. run: |
  104. make clean
  105. CFLAGS="$CFLAGS \
  106. -DLFS_NO_ASSERT \
  107. -DLFS_NO_DEBUG \
  108. -DLFS_NO_WARN \
  109. -DLFS_NO_ERROR" \
  110. make lfs.code.csv lfs.data.csv lfs.stack.csv lfs.structs.csv
  111. ./scripts/structs.py -u lfs.structs.csv
  112. ./scripts/summary.py lfs.code.csv lfs.data.csv lfs.stack.csv \
  113. -bfunction \
  114. -fcode=code_size \
  115. -fdata=data_size \
  116. -fstack=stack_limit --max=stack_limit
  117. mkdir -p sizes
  118. cp lfs.code.csv sizes/${{matrix.arch}}.code.csv
  119. cp lfs.data.csv sizes/${{matrix.arch}}.data.csv
  120. cp lfs.stack.csv sizes/${{matrix.arch}}.stack.csv
  121. cp lfs.structs.csv sizes/${{matrix.arch}}.structs.csv
  122. - name: sizes-readonly
  123. run: |
  124. make clean
  125. CFLAGS="$CFLAGS \
  126. -DLFS_NO_ASSERT \
  127. -DLFS_NO_DEBUG \
  128. -DLFS_NO_WARN \
  129. -DLFS_NO_ERROR \
  130. -DLFS_READONLY" \
  131. make lfs.code.csv lfs.data.csv lfs.stack.csv lfs.structs.csv
  132. ./scripts/structs.py -u lfs.structs.csv
  133. ./scripts/summary.py lfs.code.csv lfs.data.csv lfs.stack.csv \
  134. -bfunction \
  135. -fcode=code_size \
  136. -fdata=data_size \
  137. -fstack=stack_limit --max=stack_limit
  138. mkdir -p sizes
  139. cp lfs.code.csv sizes/${{matrix.arch}}-readonly.code.csv
  140. cp lfs.data.csv sizes/${{matrix.arch}}-readonly.data.csv
  141. cp lfs.stack.csv sizes/${{matrix.arch}}-readonly.stack.csv
  142. cp lfs.structs.csv sizes/${{matrix.arch}}-readonly.structs.csv
  143. - name: sizes-threadsafe
  144. run: |
  145. make clean
  146. CFLAGS="$CFLAGS \
  147. -DLFS_NO_ASSERT \
  148. -DLFS_NO_DEBUG \
  149. -DLFS_NO_WARN \
  150. -DLFS_NO_ERROR \
  151. -DLFS_THREADSAFE" \
  152. make lfs.code.csv lfs.data.csv lfs.stack.csv lfs.structs.csv
  153. ./scripts/structs.py -u lfs.structs.csv
  154. ./scripts/summary.py lfs.code.csv lfs.data.csv lfs.stack.csv \
  155. -bfunction \
  156. -fcode=code_size \
  157. -fdata=data_size \
  158. -fstack=stack_limit --max=stack_limit
  159. mkdir -p sizes
  160. cp lfs.code.csv sizes/${{matrix.arch}}-threadsafe.code.csv
  161. cp lfs.data.csv sizes/${{matrix.arch}}-threadsafe.data.csv
  162. cp lfs.stack.csv sizes/${{matrix.arch}}-threadsafe.stack.csv
  163. cp lfs.structs.csv sizes/${{matrix.arch}}-threadsafe.structs.csv
  164. - name: sizes-migrate
  165. run: |
  166. make clean
  167. CFLAGS="$CFLAGS \
  168. -DLFS_NO_ASSERT \
  169. -DLFS_NO_DEBUG \
  170. -DLFS_NO_WARN \
  171. -DLFS_NO_ERROR \
  172. -DLFS_MIGRATE" \
  173. make lfs.code.csv lfs.data.csv lfs.stack.csv lfs.structs.csv
  174. ./scripts/structs.py -u lfs.structs.csv
  175. ./scripts/summary.py lfs.code.csv lfs.data.csv lfs.stack.csv \
  176. -bfunction \
  177. -fcode=code_size \
  178. -fdata=data_size \
  179. -fstack=stack_limit --max=stack_limit
  180. mkdir -p sizes
  181. cp lfs.code.csv sizes/${{matrix.arch}}-migrate.code.csv
  182. cp lfs.data.csv sizes/${{matrix.arch}}-migrate.data.csv
  183. cp lfs.stack.csv sizes/${{matrix.arch}}-migrate.stack.csv
  184. cp lfs.structs.csv sizes/${{matrix.arch}}-migrate.structs.csv
  185. - name: sizes-error-asserts
  186. run: |
  187. make clean
  188. CFLAGS="$CFLAGS \
  189. -DLFS_NO_DEBUG \
  190. -DLFS_NO_WARN \
  191. -DLFS_NO_ERROR \
  192. -D'LFS_ASSERT(test)=do {if(!(test)) {return -1;}} while(0)'" \
  193. make lfs.code.csv lfs.data.csv lfs.stack.csv lfs.structs.csv
  194. ./scripts/structs.py -u lfs.structs.csv
  195. ./scripts/summary.py lfs.code.csv lfs.data.csv lfs.stack.csv \
  196. -bfunction \
  197. -fcode=code_size \
  198. -fdata=data_size \
  199. -fstack=stack_limit --max=stack_limit
  200. mkdir -p sizes
  201. cp lfs.code.csv sizes/${{matrix.arch}}-error-asserts.code.csv
  202. cp lfs.data.csv sizes/${{matrix.arch}}-error-asserts.data.csv
  203. cp lfs.stack.csv sizes/${{matrix.arch}}-error-asserts.stack.csv
  204. cp lfs.structs.csv sizes/${{matrix.arch}}-error-asserts.structs.csv
  205. # create size statuses
  206. - name: upload-sizes
  207. uses: actions/upload-artifact@v2
  208. with:
  209. name: sizes
  210. path: sizes
  211. - name: status-sizes
  212. run: |
  213. mkdir -p status
  214. for f in $(shopt -s nullglob ; echo sizes/*.csv)
  215. do
  216. # skip .data.csv as it should always be zero
  217. [[ $f == *.data.csv ]] && continue
  218. export STEP="sizes$(echo $f \
  219. | sed -n 's/[^-.]*-\([^.]*\)\..*csv/-\1/p')"
  220. export CONTEXT="sizes (${{matrix.arch}}$(echo $f \
  221. | sed -n 's/[^-.]*-\([^.]*\)\..*csv/, \1/p')) / $(echo $f \
  222. | sed -n 's/[^.]*\.\(.*\)\.csv/\1/p')"
  223. export PREV="$(curl -sS \
  224. "$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/status/master`
  225. `?per_page=100" \
  226. | jq -re 'select(.sha != env.GITHUB_SHA) | .statuses[]
  227. | select(.context == env.CONTEXT).description
  228. | capture("(?<prev>[0-9∞]+)").prev' \
  229. || echo 0)"
  230. export DESCRIPTION="$(./scripts/summary.py $f --max=stack_limit -Y \
  231. | awk '
  232. NR==2 {$1=0; printf "%s B",$NF}
  233. NR==2 && ENVIRON["PREV"]+0 != 0 {
  234. printf " (%+.1f%%)",100*($NF-ENVIRON["PREV"])/ENVIRON["PREV"]
  235. }')"
  236. jq -n '{
  237. state: "success",
  238. context: env.CONTEXT,
  239. description: env.DESCRIPTION,
  240. target_job: "${{github.job}} (${{matrix.arch}})",
  241. target_step: env.STEP,
  242. }' | tee status/$(basename $f .csv).json
  243. done
  244. - name: upload-status-sizes
  245. uses: actions/upload-artifact@v2
  246. with:
  247. name: status
  248. path: status
  249. retention-days: 1
  250. # create cov statuses
  251. - name: upload-cov
  252. if: ${{matrix.arch == 'x86_64'}}
  253. uses: actions/upload-artifact@v2
  254. with:
  255. name: cov
  256. path: cov
  257. - name: status-cov
  258. if: ${{matrix.arch == 'x86_64'}}
  259. run: |
  260. mkdir -p status
  261. f=cov/cov.csv
  262. for s in lines branches
  263. do
  264. export STEP="cov"
  265. export CONTEXT="cov / $s"
  266. export PREV="$(curl -sS \
  267. "$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/status/master`
  268. `?per_page=100" \
  269. | jq -re 'select(.sha != env.GITHUB_SHA) | .statuses[]
  270. | select(.context == env.CONTEXT).description
  271. | capture("(?<prev_a>[0-9]+)/(?<prev_b>[0-9]+)")
  272. | 100*((.prev_a|tonumber) / (.prev_b|tonumber))' \
  273. || echo 0)"
  274. export DESCRIPTION="$(./scripts/cov.py -u $f -f$s -Y \
  275. | awk -F '[ /%]+' -v s=$s '
  276. NR==2 {$1=0; printf "%d/%d %s",$2,$3,s}
  277. NR==2 && ENVIRON["PREV"]+0 != 0 {
  278. printf " (%+.1f%%)",$4-ENVIRON["PREV"]
  279. }')"
  280. jq -n '{
  281. state: "success",
  282. context: env.CONTEXT,
  283. description: env.DESCRIPTION,
  284. target_job: "${{github.job}} (${{matrix.arch}})",
  285. target_step: env.STEP,
  286. }' | tee status/$(basename $f .csv)-$s.json
  287. done
  288. - name: upload-status-sizes
  289. if: ${{matrix.arch == 'x86_64'}}
  290. uses: actions/upload-artifact@v2
  291. with:
  292. name: status
  293. path: status
  294. retention-days: 1
  295. # run as many exhaustive tests as fits in GitHub's time limits
  296. #
  297. # this grows exponentially, so it doesn't turn out to be that many
  298. test-pls:
  299. runs-on: ubuntu-22.04
  300. strategy:
  301. fail-fast: false
  302. matrix:
  303. pls: [1, 2]
  304. steps:
  305. - uses: actions/checkout@v2
  306. - name: install
  307. run: |
  308. # need a few things
  309. sudo apt-get update -qq
  310. sudo apt-get install -qq gcc python3 python3-pip
  311. pip3 install toml
  312. gcc --version
  313. python3 --version
  314. - name: test-pls
  315. if: ${{matrix.pls <= 1}}
  316. run: |
  317. TESTFLAGS="$TESTFLAGS -P${{matrix.pls}}" make test
  318. # >=2pls takes multiple days to run fully, so we can only
  319. # run a subset of tests, these are the most important
  320. - name: test-limited-pls
  321. if: ${{matrix.pls > 1}}
  322. run: |
  323. TESTFLAGS="$TESTFLAGS -P${{matrix.pls}} test_dirs test_relocations" \
  324. make test
  325. # run with LFS_NO_INTRINSICS to make sure that works
  326. test-no-intrinsics:
  327. runs-on: ubuntu-22.04
  328. steps:
  329. - uses: actions/checkout@v2
  330. - name: install
  331. run: |
  332. # need a few things
  333. sudo apt-get update -qq
  334. sudo apt-get install -qq gcc python3 python3-pip
  335. pip3 install toml
  336. gcc --version
  337. python3 --version
  338. - name: test-no-intrinsics
  339. run: |
  340. CFLAGS="$CFLAGS -DLFS_NO_INTRINSICS" make test
  341. # run under Valgrind to check for memory errors
  342. test-valgrind:
  343. runs-on: ubuntu-22.04
  344. steps:
  345. - uses: actions/checkout@v2
  346. - name: install
  347. run: |
  348. # need a few things
  349. sudo apt-get update -qq
  350. sudo apt-get install -qq gcc python3 python3-pip valgrind
  351. pip3 install toml
  352. gcc --version
  353. python3 --version
  354. valgrind --version
  355. # Valgrind takes a while with diminishing value, so only test
  356. # on one geometry
  357. - name: test-valgrind
  358. run: |
  359. TESTFLAGS="$TESTFLAGS -Gdefault --valgrind" make test
  360. # test that compilation is warning free under clang
  361. # run with Clang, mostly to check for Clang-specific warnings
  362. test-clang:
  363. runs-on: ubuntu-22.04
  364. steps:
  365. - uses: actions/checkout@v2
  366. - name: install
  367. run: |
  368. # need a few things
  369. sudo apt-get install -qq clang python3 python3-pip
  370. pip3 install toml
  371. clang --version
  372. python3 --version
  373. - name: test-clang
  374. run: |
  375. # override CFLAGS since Clang does not support -fcallgraph-info
  376. # and -ftrack-macro-expansions
  377. make \
  378. CC=clang \
  379. CFLAGS="$CFLAGS -MMD -g3 -I. -std=c99 -Wall -Wextra -pedantic" \
  380. test
  381. # run benchmarks
  382. #
  383. # note there's no real benefit to running these on multiple archs
  384. bench:
  385. runs-on: ubuntu-22.04
  386. steps:
  387. - uses: actions/checkout@v2
  388. - name: install
  389. run: |
  390. # need a few things
  391. sudo apt-get update -qq
  392. sudo apt-get install -qq gcc python3 python3-pip valgrind
  393. pip3 install toml
  394. gcc --version
  395. python3 --version
  396. valgrind --version
  397. - name: bench
  398. run: |
  399. BENCHFLAGS="$BENCHFLAGS -o lfs.bench.csv" make bench
  400. # find bench results
  401. ./scripts/summary.py lfs.bench.csv \
  402. -bsuite \
  403. -freaded=bench_readed \
  404. -fproged=bench_proged \
  405. -ferased=bench_erased
  406. mkdir -p bench
  407. cp lfs.bench.csv bench/bench.csv
  408. # find perfbd results
  409. make lfs.perfbd.csv
  410. ./scripts/perfbd.py -u lfs.perfbd.csv
  411. mkdir -p bench
  412. cp lfs.perfbd.csv bench/perfbd.csv
  413. # create bench statuses
  414. - name: upload-bench
  415. uses: actions/upload-artifact@v2
  416. with:
  417. name: bench
  418. path: bench
  419. - name: status-bench
  420. run: |
  421. mkdir -p status
  422. f=bench/bench.csv
  423. for s in readed proged erased
  424. do
  425. export STEP="bench"
  426. export CONTEXT="bench / $s"
  427. export PREV="$(curl -sS \
  428. "$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/status/master`
  429. `?per_page=100" \
  430. | jq -re 'select(.sha != env.GITHUB_SHA) | .statuses[]
  431. | select(.context == env.CONTEXT).description
  432. | capture("(?<prev>[0-9]+)").prev' \
  433. || echo 0)"
  434. export DESCRIPTION="$(./scripts/summary.py $f -f$s=bench_$s -Y \
  435. | awk '
  436. NR==2 {$1=0; printf "%s B",$NF}
  437. NR==2 && ENVIRON["PREV"]+0 != 0 {
  438. printf " (%+.1f%%)",100*($NF-ENVIRON["PREV"])/ENVIRON["PREV"]
  439. }')"
  440. jq -n '{
  441. state: "success",
  442. context: env.CONTEXT,
  443. description: env.DESCRIPTION,
  444. target_job: "${{github.job}}",
  445. target_step: env.STEP,
  446. }' | tee status/$(basename $f .csv)-$s.json
  447. done
  448. - name: upload-status-bench
  449. uses: actions/upload-artifact@v2
  450. with:
  451. name: status
  452. path: status
  453. retention-days: 1
  454. # self-host with littlefs-fuse for a fuzz-like test
  455. fuse:
  456. runs-on: ubuntu-22.04
  457. if: ${{!endsWith(github.ref, '-prefix')}}
  458. steps:
  459. - uses: actions/checkout@v2
  460. - name: install
  461. run: |
  462. # need a few things
  463. sudo apt-get update -qq
  464. sudo apt-get install -qq gcc python3 python3-pip libfuse-dev
  465. sudo pip3 install toml
  466. gcc --version
  467. python3 --version
  468. fusermount -V
  469. - uses: actions/checkout@v2
  470. with:
  471. repository: littlefs-project/littlefs-fuse
  472. ref: v2
  473. path: littlefs-fuse
  474. - name: setup
  475. run: |
  476. # copy our new version into littlefs-fuse
  477. rm -rf littlefs-fuse/littlefs/*
  478. cp -r $(git ls-tree --name-only HEAD) littlefs-fuse/littlefs
  479. # setup disk for littlefs-fuse
  480. mkdir mount
  481. LOOP=$(sudo losetup -f)
  482. sudo chmod a+rw $LOOP
  483. dd if=/dev/zero bs=512 count=128K of=disk
  484. losetup $LOOP disk
  485. echo "LOOP=$LOOP" >> $GITHUB_ENV
  486. - name: test
  487. run: |
  488. # self-host test
  489. make -C littlefs-fuse
  490. littlefs-fuse/lfs --format $LOOP
  491. littlefs-fuse/lfs $LOOP mount
  492. ls mount
  493. mkdir mount/littlefs
  494. cp -r $(git ls-tree --name-only HEAD) mount/littlefs
  495. cd mount/littlefs
  496. stat .
  497. ls -flh
  498. make -B test-runner
  499. make -B test
  500. # test migration using littlefs-fuse
  501. migrate:
  502. runs-on: ubuntu-22.04
  503. if: ${{!endsWith(github.ref, '-prefix')}}
  504. steps:
  505. - uses: actions/checkout@v2
  506. - name: install
  507. run: |
  508. # need a few things
  509. sudo apt-get update -qq
  510. sudo apt-get install -qq gcc python3 python3-pip libfuse-dev
  511. sudo pip3 install toml
  512. gcc --version
  513. python3 --version
  514. fusermount -V
  515. - uses: actions/checkout@v2
  516. with:
  517. repository: littlefs-project/littlefs-fuse
  518. ref: v2
  519. path: v2
  520. - uses: actions/checkout@v2
  521. with:
  522. repository: littlefs-project/littlefs-fuse
  523. ref: v1
  524. path: v1
  525. - name: setup
  526. run: |
  527. # copy our new version into littlefs-fuse
  528. rm -rf v2/littlefs/*
  529. cp -r $(git ls-tree --name-only HEAD) v2/littlefs
  530. # setup disk for littlefs-fuse
  531. mkdir mount
  532. LOOP=$(sudo losetup -f)
  533. sudo chmod a+rw $LOOP
  534. dd if=/dev/zero bs=512 count=128K of=disk
  535. losetup $LOOP disk
  536. echo "LOOP=$LOOP" >> $GITHUB_ENV
  537. - name: test
  538. run: |
  539. # compile v1 and v2
  540. make -C v1
  541. make -C v2
  542. # run self-host test with v1
  543. v1/lfs --format $LOOP
  544. v1/lfs $LOOP mount
  545. ls mount
  546. mkdir mount/littlefs
  547. cp -r $(git ls-tree --name-only HEAD) mount/littlefs
  548. cd mount/littlefs
  549. stat .
  550. ls -flh
  551. make -B test-runner
  552. make -B test
  553. # attempt to migrate
  554. cd ../..
  555. fusermount -u mount
  556. v2/lfs --migrate $LOOP
  557. v2/lfs $LOOP mount
  558. # run self-host test with v2 right where we left off
  559. ls mount
  560. cd mount/littlefs
  561. stat .
  562. ls -flh
  563. make -B test-runner
  564. make -B test
  565. # status related tasks that run after tests
  566. status:
  567. runs-on: ubuntu-22.04
  568. needs: [test, bench]
  569. steps:
  570. - uses: actions/checkout@v2
  571. if: ${{github.event_name == 'pull_request'}}
  572. - name: install
  573. if: ${{github.event_name == 'pull_request'}}
  574. run: |
  575. # need a few things
  576. sudo apt-get install -qq gcc python3 python3-pip
  577. pip3 install toml
  578. gcc --version
  579. python3 --version
  580. - uses: actions/download-artifact@v2
  581. if: ${{github.event_name == 'pull_request'}}
  582. continue-on-error: true
  583. with:
  584. name: sizes
  585. path: sizes
  586. - uses: actions/download-artifact@v2
  587. if: ${{github.event_name == 'pull_request'}}
  588. continue-on-error: true
  589. with:
  590. name: cov
  591. path: cov
  592. - uses: actions/download-artifact@v2
  593. if: ${{github.event_name == 'pull_request'}}
  594. continue-on-error: true
  595. with:
  596. name: bench
  597. path: bench
  598. # try to find results from tests
  599. - name: create-table
  600. if: ${{github.event_name == 'pull_request'}}
  601. run: |
  602. # compare against pull-request target
  603. curl -sS \
  604. "$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/status/`
  605. `${{github.event.pull_request.base.ref}}`
  606. `?per_page=100" \
  607. | jq -re 'select(.sha != env.GITHUB_SHA) | .statuses[]' \
  608. >> prev-status.json \
  609. || true
  610. # build table for GitHub
  611. declare -A table
  612. # sizes table
  613. i=0
  614. j=0
  615. for c in "" readonly threadsafe migrate error-asserts
  616. do
  617. # per-config results
  618. c_or_default=${c:-default}
  619. c_camel=${c_or_default^}
  620. table[$i,$j]=$c_camel
  621. ((j+=1))
  622. for s in code stack structs
  623. do
  624. f=sizes/thumb${c:+-$c}.$s.csv
  625. [ -e $f ] && table[$i,$j]=$( \
  626. export PREV="$(jq -re '
  627. select(.context == "'"sizes (thumb${c:+, $c}) / $s"'").description
  628. | capture("(?<prev>[0-9∞]+)").prev' \
  629. prev-status.json || echo 0)"
  630. ./scripts/summary.py $f --max=stack_limit -Y \
  631. | awk '
  632. NR==2 {$1=0; printf "%s B",$NF}
  633. NR==2 && ENVIRON["PREV"]+0 != 0 {
  634. printf " (%+.1f%%)",100*($NF-ENVIRON["PREV"])/ENVIRON["PREV"]
  635. }' \
  636. | sed -e 's/ /\&nbsp;/g')
  637. ((j+=1))
  638. done
  639. ((j=0, i+=1))
  640. done
  641. # coverage table
  642. i=0
  643. j=4
  644. for s in lines branches
  645. do
  646. table[$i,$j]=${s^}
  647. ((j+=1))
  648. f=cov/cov.csv
  649. [ -e $f ] && table[$i,$j]=$( \
  650. export PREV="$(jq -re '
  651. select(.context == "'"cov / $s"'").description
  652. | capture("(?<prev_a>[0-9]+)/(?<prev_b>[0-9]+)")
  653. | 100*((.prev_a|tonumber) / (.prev_b|tonumber))' \
  654. prev-status.json || echo 0)"
  655. ./scripts/cov.py -u $f -f$s -Y \
  656. | awk -F '[ /%]+' -v s=$s '
  657. NR==2 {$1=0; printf "%d/%d %s",$2,$3,s}
  658. NR==2 && ENVIRON["PREV"]+0 != 0 {
  659. printf " (%+.1f%%)",$4-ENVIRON["PREV"]
  660. }' \
  661. | sed -e 's/ /\&nbsp;/g')
  662. ((j=4, i+=1))
  663. done
  664. # benchmark table
  665. i=3
  666. j=4
  667. for s in readed proged erased
  668. do
  669. table[$i,$j]=${s^}
  670. ((j+=1))
  671. f=bench/bench.csv
  672. [ -e $f ] && table[$i,$j]=$( \
  673. export PREV="$(jq -re '
  674. select(.context == "'"bench / $s"'").description
  675. | capture("(?<prev>[0-9]+)").prev' \
  676. prev-status.json || echo 0)"
  677. ./scripts/summary.py $f -f$s=bench_$s -Y \
  678. | awk '
  679. NR==2 {$1=0; printf "%s B",$NF}
  680. NR==2 && ENVIRON["PREV"]+0 != 0 {
  681. printf " (%+.1f%%)",100*($NF-ENVIRON["PREV"])/ENVIRON["PREV"]
  682. }' \
  683. | sed -e 's/ /\&nbsp;/g')
  684. ((j=4, i+=1))
  685. done
  686. # build the actual table
  687. echo "| | Code | Stack | Structs | | Coverage |" >> table.txt
  688. echo "|:--|-----:|------:|--------:|:--|---------:|" >> table.txt
  689. for ((i=0; i<6; i++))
  690. do
  691. echo -n "|" >> table.txt
  692. for ((j=0; j<6; j++))
  693. do
  694. echo -n " " >> table.txt
  695. [[ i -eq 2 && j -eq 5 ]] && echo -n "**Benchmarks**" >> table.txt
  696. echo -n "${table[$i,$j]:-}" >> table.txt
  697. echo -n " |" >> table.txt
  698. done
  699. echo >> table.txt
  700. done
  701. cat table.txt
  702. # create a bot comment for successful runs on pull requests
  703. - name: create-comment
  704. if: ${{github.event_name == 'pull_request'}}
  705. run: |
  706. touch comment.txt
  707. echo "<details>" >> comment.txt
  708. echo "<summary>" >> comment.txt
  709. echo "Tests passed ✓, `
  710. `Code: $(awk 'NR==3 {print $4}' table.txt || true), `
  711. `Stack: $(awk 'NR==3 {print $6}' table.txt || true), `
  712. `Structs: $(awk 'NR==3 {print $8}' table.txt || true)" \
  713. >> comment.txt
  714. echo "</summary>" >> comment.txt
  715. echo >> comment.txt
  716. [ -e table.txt ] && cat table.txt >> comment.txt
  717. echo >> comment.txt
  718. echo "</details>" >> comment.txt
  719. cat comment.txt
  720. mkdir -p comment
  721. jq -n --rawfile comment comment.txt '{
  722. number: ${{github.event.number}},
  723. body: $comment,
  724. }' | tee comment/comment.json
  725. - name: upload-comment
  726. uses: actions/upload-artifact@v2
  727. with:
  728. name: comment
  729. path: comment
  730. retention-days: 1