.travis.yml 7.5 KB

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