.travis.yml 11 KB

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