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