.travis.yml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  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 -DLFS_BLOCK_CYCLES=16"
  20. - make test QUIET=1 CFLAGS+="-DLFS_BLOCK_COUNT=1023 -DLFS_LOOKAHEAD_SIZE=256"
  21. - make clean test QUIET=1 CFLAGS+="-DLFS_INLINE_MAX=0"
  22. - make clean test QUIET=1 CFLAGS+="-DLFS_EMUBD_ERASE_VALUE=0xff"
  23. - make clean test QUIET=1 CFLAGS+="-DLFS_NO_INTRINSICS"
  24. # additional configurations that don't support all tests (this should be
  25. # fixed but at the moment it is what it is)
  26. - make test_files QUIET=1
  27. CFLAGS+="-DLFS_READ_SIZE=1 -DLFS_BLOCK_SIZE=4096"
  28. - make test_files QUIET=1
  29. CFLAGS+="-DLFS_READ_SIZE=\(2*1024\) -DLFS_BLOCK_SIZE=\(64*1024\)"
  30. - make test_files QUIET=1
  31. CFLAGS+="-DLFS_READ_SIZE=\(8*1024\) -DLFS_BLOCK_SIZE=\(64*1024\)"
  32. - make test_files QUIET=1
  33. CFLAGS+="-DLFS_READ_SIZE=11 -DLFS_BLOCK_SIZE=704"
  34. # compile and find the code size with the smallest configuration
  35. - make clean size
  36. OBJ="$(ls lfs*.o | tr '\n' ' ')"
  37. CFLAGS+="-DLFS_NO_ASSERT -DLFS_NO_DEBUG -DLFS_NO_WARN -DLFS_NO_ERROR"
  38. | tee sizes
  39. # update status if we succeeded, compare with master if possible
  40. - |
  41. if [ "$TRAVIS_TEST_RESULT" -eq 0 ]
  42. then
  43. CURR=$(tail -n1 sizes | awk '{print $1}')
  44. PREV=$(curl -u "$GEKY_BOT_STATUSES" https://api.github.com/repos/$TRAVIS_REPO_SLUG/status/master \
  45. | jq -re "select(.sha != \"$TRAVIS_COMMIT\")
  46. | .statuses[] | select(.context == \"$STAGE/$NAME\").description
  47. | capture(\"code size is (?<size>[0-9]+)\").size" \
  48. || echo 0)
  49. STATUS="Passed, code size is ${CURR}B"
  50. if [ "$PREV" -ne 0 ]
  51. then
  52. STATUS="$STATUS ($(python -c "print '%+.2f' % (100*($CURR-$PREV)/$PREV.0)")%)"
  53. fi
  54. fi
  55. # CI matrix
  56. jobs:
  57. include:
  58. # native testing
  59. - stage: test
  60. env:
  61. - STAGE=test
  62. - NAME=littlefs-x86
  63. # cross-compile with ARM (thumb mode)
  64. - stage: test
  65. env:
  66. - STAGE=test
  67. - NAME=littlefs-arm
  68. - CC="arm-linux-gnueabi-gcc --static -mthumb"
  69. - EXEC="qemu-arm"
  70. install:
  71. - sudo apt-get install
  72. gcc-arm-linux-gnueabi
  73. libc6-dev-armel-cross
  74. qemu-user
  75. - arm-linux-gnueabi-gcc --version
  76. - qemu-arm -version
  77. # cross-compile with PowerPC
  78. - stage: test
  79. env:
  80. - STAGE=test
  81. - NAME=littlefs-powerpc
  82. - CC="powerpc-linux-gnu-gcc --static"
  83. - EXEC="qemu-ppc"
  84. install:
  85. - sudo apt-get install
  86. gcc-powerpc-linux-gnu
  87. libc6-dev-powerpc-cross
  88. qemu-user
  89. - powerpc-linux-gnu-gcc --version
  90. - qemu-ppc -version
  91. # cross-compile with MIPS
  92. - stage: test
  93. env:
  94. - STAGE=test
  95. - NAME=littlefs-mips
  96. - CC="mips-linux-gnu-gcc --static"
  97. - EXEC="qemu-mips"
  98. install:
  99. - sudo apt-get install
  100. gcc-mips-linux-gnu
  101. libc6-dev-mips-cross
  102. qemu-user
  103. - mips-linux-gnu-gcc --version
  104. - qemu-mips -version
  105. # self-host with littlefs-fuse for fuzz test
  106. - stage: test
  107. env:
  108. - STAGE=test
  109. - NAME=littlefs-fuse
  110. if: branch !~ -prefix$
  111. install:
  112. - sudo apt-get install libfuse-dev
  113. - git clone --depth 1 https://github.com/geky/littlefs-fuse -b v2
  114. - fusermount -V
  115. - gcc --version
  116. before_script:
  117. # setup disk for littlefs-fuse
  118. - rm -rf littlefs-fuse/littlefs/*
  119. - cp -r $(git ls-tree --name-only HEAD) littlefs-fuse/littlefs
  120. - mkdir mount
  121. - sudo chmod a+rw /dev/loop0
  122. - dd if=/dev/zero bs=512 count=4096 of=disk
  123. - losetup /dev/loop0 disk
  124. script:
  125. # self-host test
  126. - make -C littlefs-fuse
  127. - littlefs-fuse/lfs --format /dev/loop0
  128. - littlefs-fuse/lfs /dev/loop0 mount
  129. - ls mount
  130. - mkdir mount/littlefs
  131. - cp -r $(git ls-tree --name-only HEAD) mount/littlefs
  132. - cd mount/littlefs
  133. - stat .
  134. - ls -flh
  135. - make -B test_dirs test_files QUIET=1
  136. # self-host with littlefs-fuse for fuzz test
  137. - stage: test
  138. env:
  139. - STAGE=test
  140. - NAME=littlefs-migration
  141. if: branch !~ -prefix$
  142. install:
  143. - sudo apt-get install libfuse-dev
  144. - git clone --depth 1 https://github.com/geky/littlefs-fuse -b v2 v2
  145. - git clone --depth 1 https://github.com/geky/littlefs-fuse -b v1 v1
  146. - fusermount -V
  147. - gcc --version
  148. before_script:
  149. # setup disk for littlefs-fuse
  150. - rm -rf v2/littlefs/*
  151. - cp -r $(git ls-tree --name-only HEAD) v2/littlefs
  152. - mkdir mount
  153. - sudo chmod a+rw /dev/loop0
  154. - dd if=/dev/zero bs=512 count=4096 of=disk
  155. - losetup /dev/loop0 disk
  156. script:
  157. # compile v1 and v2
  158. - make -C v1
  159. - make -C v2
  160. # run self-host test with v1
  161. - v1/lfs --format /dev/loop0
  162. - v1/lfs /dev/loop0 mount
  163. - ls mount
  164. - mkdir mount/littlefs
  165. - cp -r $(git ls-tree --name-only HEAD) mount/littlefs
  166. - cd mount/littlefs
  167. - stat .
  168. - ls -flh
  169. - make -B test_dirs test_files QUIET=1
  170. # attempt to migrate
  171. - cd ../..
  172. - fusermount -u mount
  173. - v2/lfs --migrate /dev/loop0
  174. - v2/lfs /dev/loop0 mount
  175. # run self-host test with v2 right where we left off
  176. - ls mount
  177. - cd mount/littlefs
  178. - stat .
  179. - ls -flh
  180. - make -B test_dirs test_files QUIET=1
  181. # Automatically create releases
  182. - stage: deploy
  183. env:
  184. - STAGE=deploy
  185. - NAME=deploy
  186. script:
  187. - |
  188. bash << 'SCRIPT'
  189. set -ev
  190. # Find version defined in lfs.h
  191. LFS_VERSION=$(grep -ox '#define LFS_VERSION .*' lfs.h | cut -d ' ' -f3)
  192. LFS_VERSION_MAJOR=$((0xffff & ($LFS_VERSION >> 16)))
  193. LFS_VERSION_MINOR=$((0xffff & ($LFS_VERSION >> 0)))
  194. # Grab latests patch from repo tags, default to 0, needs finagling
  195. # to get past github's pagination api
  196. PREV_URL=https://api.github.com/repos/$TRAVIS_REPO_SLUG/git/refs/tags/v$LFS_VERSION_MAJOR.$LFS_VERSION_MINOR.
  197. PREV_URL=$(curl -u "$GEKY_BOT_RELEASES" "$PREV_URL" -I \
  198. | sed -n '/^Link/{s/.*<\(.*\)>; rel="last"/\1/;p;q0};$q1' \
  199. || echo $PREV_URL)
  200. LFS_VERSION_PATCH=$(curl -u "$GEKY_BOT_RELEASES" "$PREV_URL" \
  201. | jq 'map(.ref | match("\\bv.*\\..*\\.(.*)$";"g")
  202. .captures[].string | tonumber) | max + 1' \
  203. || echo 0)
  204. # We have our new version
  205. LFS_VERSION="v$LFS_VERSION_MAJOR.$LFS_VERSION_MINOR.$LFS_VERSION_PATCH"
  206. echo "VERSION $LFS_VERSION"
  207. # Check that we're the most recent commit
  208. CURRENT_COMMIT=$(curl -f -u "$GEKY_BOT_RELEASES" \
  209. https://api.github.com/repos/$TRAVIS_REPO_SLUG/commits/master \
  210. | jq -re '.sha')
  211. [ "$TRAVIS_COMMIT" == "$CURRENT_COMMIT" ] || exit 0
  212. # Create major branch
  213. git branch v$LFS_VERSION_MAJOR HEAD
  214. # Create major prefix branch
  215. git config user.name "geky bot"
  216. git config user.email "bot@geky.net"
  217. git fetch https://github.com/$TRAVIS_REPO_SLUG.git \
  218. --depth=50 v$LFS_VERSION_MAJOR-prefix || true
  219. ./scripts/prefix.py lfs$LFS_VERSION_MAJOR
  220. git branch v$LFS_VERSION_MAJOR-prefix $( \
  221. git commit-tree $(git write-tree) \
  222. $(git rev-parse --verify -q FETCH_HEAD | sed -e 's/^/-p /') \
  223. -p HEAD \
  224. -m "Generated v$LFS_VERSION_MAJOR prefixes")
  225. git reset --hard
  226. # Update major version branches (vN and vN-prefix)
  227. git push --atomic https://$GEKY_BOT_RELEASES@github.com/$TRAVIS_REPO_SLUG.git \
  228. v$LFS_VERSION_MAJOR \
  229. v$LFS_VERSION_MAJOR-prefix
  230. # Build release notes
  231. PREV=$(git tag --sort=-v:refname -l "v*" | head -1)
  232. if [ ! -z "$PREV" ]
  233. then
  234. echo "PREV $PREV"
  235. CHANGES=$(git log --oneline $PREV.. --grep='^Merge' --invert-grep)
  236. printf "CHANGES\n%s\n\n" "$CHANGES"
  237. fi
  238. case ${GEKY_BOT_DRAFT:-minor} in
  239. true) DRAFT=true ;;
  240. minor) DRAFT=$(jq -R 'endswith(".0")' <<< "$LFS_VERSION") ;;
  241. false) DRAFT=false ;;
  242. esac
  243. # Create the release and patch version tag (vN.N.N)
  244. curl -f -u "$GEKY_BOT_RELEASES" -X POST \
  245. https://api.github.com/repos/$TRAVIS_REPO_SLUG/releases \
  246. -d "{
  247. \"tag_name\": \"$LFS_VERSION\",
  248. \"name\": \"${LFS_VERSION%.0}\",
  249. \"target_commitish\": \"$TRAVIS_COMMIT\",
  250. \"draft\": $DRAFT,
  251. \"body\": $(jq -sR '.' <<< "$CHANGES")
  252. }" #"
  253. SCRIPT
  254. # Manage statuses
  255. before_install:
  256. - |
  257. curl -u "$GEKY_BOT_STATUSES" -X POST \
  258. https://api.github.com/repos/$TRAVIS_REPO_SLUG/statuses/${TRAVIS_PULL_REQUEST_SHA:-$TRAVIS_COMMIT} \
  259. -d "{
  260. \"context\": \"$STAGE/$NAME\",
  261. \"state\": \"pending\",
  262. \"description\": \"${STATUS:-In progress}\",
  263. \"target_url\": \"https://travis-ci.org/$TRAVIS_REPO_SLUG/jobs/$TRAVIS_JOB_ID\"
  264. }"
  265. after_failure:
  266. - |
  267. curl -u "$GEKY_BOT_STATUSES" -X POST \
  268. https://api.github.com/repos/$TRAVIS_REPO_SLUG/statuses/${TRAVIS_PULL_REQUEST_SHA:-$TRAVIS_COMMIT} \
  269. -d "{
  270. \"context\": \"$STAGE/$NAME\",
  271. \"state\": \"failure\",
  272. \"description\": \"${STATUS:-Failed}\",
  273. \"target_url\": \"https://travis-ci.org/$TRAVIS_REPO_SLUG/jobs/$TRAVIS_JOB_ID\"
  274. }"
  275. after_success:
  276. - |
  277. curl -u "$GEKY_BOT_STATUSES" -X POST \
  278. https://api.github.com/repos/$TRAVIS_REPO_SLUG/statuses/${TRAVIS_PULL_REQUEST_SHA:-$TRAVIS_COMMIT} \
  279. -d "{
  280. \"context\": \"$STAGE/$NAME\",
  281. \"state\": \"success\",
  282. \"description\": \"${STATUS:-Passed}\",
  283. \"target_url\": \"https://travis-ci.org/$TRAVIS_REPO_SLUG/jobs/$TRAVIS_JOB_ID\"
  284. }"
  285. # Job control
  286. stages:
  287. - name: test
  288. - name: deploy
  289. if: branch = master AND type = push