.travis.yml 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. # Environment variables
  2. env:
  3. global:
  4. - CFLAGS=-Werror
  5. # Common test script
  6. script:
  7. # make sure example can at least compile
  8. - sed -n '/``` c/,/```/{/```/d; p;}' README.md > test.c &&
  9. make all CFLAGS+="
  10. -Duser_provided_block_device_read=NULL
  11. -Duser_provided_block_device_prog=NULL
  12. -Duser_provided_block_device_erase=NULL
  13. -Duser_provided_block_device_sync=NULL
  14. -include stdio.h"
  15. # run tests
  16. - make test QUIET=1
  17. # run tests with a few different configurations
  18. - make test QUIET=1 CFLAGS+="-DLFS_READ_SIZE=1 -DLFS_PROG_SIZE=1"
  19. - make test QUIET=1 CFLAGS+="-DLFS_READ_SIZE=512 -DLFS_PROG_SIZE=512"
  20. - make test QUIET=1 CFLAGS+="-DLFS_BLOCK_COUNT=1023 -DLFS_LOOKAHEAD=2048"
  21. - make clean test QUIET=1 CFLAGS+="-DLFS_NO_INTRINSICS"
  22. # compile and find the code size with the smalles configuration
  23. - make clean size
  24. OBJ="$(ls lfs*.o | tr '\n' ' ')"
  25. CFLAGS+="-DLFS_NO{ASSERT,DEBUG,WARN,ERROR}"
  26. | tee sizes
  27. # update status if we succeeded, compare with master if possible
  28. - |
  29. if [ "$TRAVIS_TEST_RESULT" -eq 0 ]
  30. then
  31. CURR=$(tail -n1 sizes | awk '{print $1}')
  32. STATUS="Passed, code size is ${CURR}B"
  33. PREV=$(curl https://api.github.com/repos/$TRAVIS_REPO_SLUG/status/master \
  34. | jq -r ".statuses[] | select(.context == \"ci/$NAME\").description" \
  35. | sed 's/.*code size is \([0-9]*\).*/\1/' \
  36. || echo 0)
  37. if [ "$PREV" -ne 0 ]
  38. then
  39. STATUS="$STATUS ($(python -c "print '%+.2f' % (100*($CURR-$PREV)/$PREV.0)")%)"
  40. fi
  41. fi
  42. # CI matrix
  43. matrix:
  44. include:
  45. # native testing
  46. - env:
  47. - NAME=littlefs-x86
  48. # cross-compile with ARM (thumb mode)
  49. - env:
  50. - NAME=littlefs-arm
  51. - CC="arm-linux-gnueabi-gcc --static -mthumb"
  52. - EXEC="qemu-arm"
  53. install:
  54. - sudo apt-get install gcc-arm-linux-gnueabi qemu-user
  55. - arm-linux-gnueabi-gcc --version
  56. - qemu-arm -version
  57. # cross-compile with PowerPC
  58. - env:
  59. - NAME=littlefs-powerpc
  60. - CC="powerpc-linux-gnu-gcc --static"
  61. - EXEC="qemu-ppc"
  62. install:
  63. - sudo apt-get install gcc-powerpc-linux-gnu qemu-user
  64. - powerpc-linux-gnu-gcc --version
  65. - qemu-ppc -version
  66. # cross-compile with MIPS
  67. - env:
  68. - NAME=littlefs-mips
  69. - CC="mips-linux-gnu-gcc --static"
  70. - EXEC="qemu-mips"
  71. install:
  72. - sudo add-apt-repository -y "deb http://archive.ubuntu.com/ubuntu/ xenial main universe"
  73. - sudo apt-get -qq update
  74. - sudo apt-get install gcc-mips-linux-gnu qemu-user
  75. - mips-linux-gnu-gcc --version
  76. - qemu-mips -version
  77. # self-host with littlefs-fuse for fuzz test
  78. - env:
  79. - NAME=littlefs-fuse
  80. install:
  81. - sudo apt-get install libfuse-dev
  82. - git clone --depth 1 https://github.com/geky/littlefs-fuse
  83. - fusermount -V
  84. - gcc --version
  85. before_script:
  86. # setup disk for littlefs-fuse
  87. - rm -rf littlefs-fuse/littlefs/*
  88. - cp -r $(git ls-tree --name-only HEAD) littlefs-fuse/littlefs
  89. - mkdir mount
  90. - sudo chmod a+rw /dev/loop0
  91. - dd if=/dev/zero bs=512 count=2048 of=disk
  92. - losetup /dev/loop0 disk
  93. script:
  94. # self-host test
  95. - make -C littlefs-fuse
  96. - littlefs-fuse/lfs --format /dev/loop0
  97. - littlefs-fuse/lfs /dev/loop0 mount
  98. - ls mount
  99. - mkdir mount/littlefs
  100. - cp -r $(git ls-tree --name-only HEAD) mount/littlefs
  101. - cd mount/littlefs
  102. - ls
  103. - make -B test_dirs test_files QUIET=1
  104. # Manage statuses
  105. before_install:
  106. - |
  107. curl -u $GEKY_BOT_STATUSES -X POST \
  108. https://api.github.com/repos/$TRAVIS_REPO_SLUG/statuses/${TRAVIS_PULL_REQUEST_SHA:-$TRAVIS_COMMIT} \
  109. -d "{
  110. \"context\": \"ci/$NAME\",
  111. \"state\": \"pending\",
  112. \"description\": \"${STATUS:-In progress}\",
  113. \"target_url\": \"https://travis-ci.org/$TRAVIS_REPO_SLUG/jobs/$TRAVIS_JOB_ID\"
  114. }"
  115. after_failure:
  116. - |
  117. curl -u $GEKY_BOT_STATUSES -X POST \
  118. https://api.github.com/repos/$TRAVIS_REPO_SLUG/statuses/${TRAVIS_PULL_REQUEST_SHA:-$TRAVIS_COMMIT} \
  119. -d "{
  120. \"context\": \"ci/$NAME\",
  121. \"state\": \"failure\",
  122. \"description\": \"${STATUS:-Failed}\",
  123. \"target_url\": \"https://travis-ci.org/$TRAVIS_REPO_SLUG/jobs/$TRAVIS_JOB_ID\"
  124. }"
  125. after_success:
  126. - |
  127. curl -u $GEKY_BOT_STATUSES -X POST \
  128. https://api.github.com/repos/$TRAVIS_REPO_SLUG/statuses/${TRAVIS_PULL_REQUEST_SHA:-$TRAVIS_COMMIT} \
  129. -d "{
  130. \"context\": \"ci/$NAME\",
  131. \"state\": \"success\",
  132. \"description\": \"${STATUS:-Passed}\",
  133. \"target_url\": \"https://travis-ci.org/$TRAVIS_REPO_SLUG/jobs/$TRAVIS_JOB_ID\"
  134. }"
  135. # Automatically update releases
  136. deploy:
  137. # Let before_deploy take over
  138. provider: script
  139. script: 'true'
  140. on:
  141. branch: master
  142. before_deploy:
  143. - cd $TRAVIS_BUILD_DIR
  144. # Update tag for version defined in lfs.h
  145. - LFS_VERSION=$(grep -ox '#define LFS_VERSION .*' lfs.h | cut -d ' ' -f3)
  146. - LFS_VERSION_MAJOR=$((0xffff & ($LFS_VERSION >> 16)))
  147. - LFS_VERSION_MINOR=$((0xffff & ($LFS_VERSION >> 0)))
  148. - LFS_VERSION="v$LFS_VERSION_MAJOR.$LFS_VERSION_MINOR"
  149. - echo "littlefs version $LFS_VERSION"
  150. - |
  151. curl -u $GEKY_BOT_RELEASES -X POST \
  152. https://api.github.com/repos/$TRAVIS_REPO_SLUG/git/refs \
  153. -d "{
  154. \"ref\": \"refs/tags/$LFS_VERSION\",
  155. \"sha\": \"$TRAVIS_COMMIT\"
  156. }"
  157. - |
  158. curl -f -u $GEKY_BOT_RELEASES -X PATCH \
  159. https://api.github.com/repos/$TRAVIS_REPO_SLUG/git/refs/tags/$LFS_VERSION \
  160. -d "{
  161. \"sha\": \"$TRAVIS_COMMIT\"
  162. }"
  163. # Create release notes from commits
  164. - LFS_PREV_VERSION="v$LFS_VERSION_MAJOR.$(($LFS_VERSION_MINOR-1))"
  165. - |
  166. if [ $(git tag -l "$LFS_PREV_VERSION") ]
  167. then
  168. curl -u $GEKY_BOT_RELEASES -X POST \
  169. https://api.github.com/repos/$TRAVIS_REPO_SLUG/releases \
  170. -d "{
  171. \"tag_name\": \"$LFS_VERSION\",
  172. \"name\": \"$LFS_VERSION\"
  173. }"
  174. RELEASE=$(
  175. curl -f https://api.github.com/repos/$TRAVIS_REPO_SLUG/releases/tags/$LFS_VERSION
  176. )
  177. CHANGES=$(
  178. git log --oneline $LFS_PREV_VERSION.. --grep='^Merge' --invert-grep
  179. )
  180. curl -f -u $GEKY_BOT_RELEASES -X PATCH \
  181. https://api.github.com/repos/$TRAVIS_REPO_SLUG/releases/$(
  182. jq -r '.id' <<< "$RELEASE"
  183. ) \
  184. -d "$(
  185. jq -s '{
  186. "body": ((.[0] // "" | sub("(?<=\n)#+ Changes.*"; ""; "mi"))
  187. + "### Changes\n\n" + .[1])
  188. }' <(jq '.body' <<< "$RELEASE") <(jq -sR '.' <<< "$CHANGES")
  189. )"
  190. fi