.travis.yml 7.9 KB

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