Skip to content

Commit 453a1b6

Browse files
committed
Merge commit '451c3d137fbd49ce5e00e765af66c16bb5169ee9' into lfs-update
2 parents 6e67794 + 451c3d1 commit 453a1b6

File tree

14 files changed

+839
-256
lines changed

14 files changed

+839
-256
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Compilation output
2+
*.o
3+
*.d
4+
*.a
5+
6+
# Testing things
7+
blocks/
8+
lfs
9+
test.c
Lines changed: 207 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,223 @@
1+
# Environment variables
2+
env:
3+
global:
4+
- CFLAGS=-Werror
5+
6+
# Common test script
17
script:
2-
# make sure example can at least compile
3-
- sed -n '/``` c/,/```/{/```/d; p;}' README.md > test.c &&
4-
CFLAGS='
8+
# make sure example can at least compile
9+
- sed -n '/``` c/,/```/{/```/d; p;}' README.md > test.c &&
10+
make all CFLAGS+="
511
-Duser_provided_block_device_read=NULL
612
-Duser_provided_block_device_prog=NULL
713
-Duser_provided_block_device_erase=NULL
814
-Duser_provided_block_device_sync=NULL
9-
-include stdio.h -Werror' make all size
15+
-include stdio.h"
16+
17+
# run tests
18+
- make test QUIET=1
19+
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"
24+
25+
- make clean test QUIET=1 CFLAGS+="-DLFS_NO_INTRINSICS"
26+
27+
# compile and find the code size with the smallest configuration
28+
- make clean size
29+
OBJ="$(ls lfs*.o | tr '\n' ' ')"
30+
CFLAGS+="-DLFS_NO{ASSERT,DEBUG,WARN,ERROR}"
31+
| tee sizes
32+
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+
PREV=$(curl https://api.github.com/repos/$TRAVIS_REPO_SLUG/status/master \
39+
| jq -re "select(.sha != \"$TRAVIS_COMMIT\")
40+
| .statuses[] | select(.context == \"$STAGE/$NAME\").description
41+
| capture(\"code size is (?<size>[0-9]+)\").size" \
42+
|| echo 0)
1043
11-
# run tests
12-
- make test QUIET=1
44+
STATUS="Passed, code size is ${CURR}B"
45+
if [ "$PREV" -ne 0 ]
46+
then
47+
STATUS="$STATUS ($(python -c "print '%+.2f' % (100*($CURR-$PREV)/$PREV.0)")%)"
48+
fi
49+
fi
1350
14-
# run tests with a few different configurations
15-
- CFLAGS="-DLFS_READ_SIZE=1 -DLFS_PROG_SIZE=1" make test QUIET=1
16-
- CFLAGS="-DLFS_READ_SIZE=512 -DLFS_PROG_SIZE=512" make test QUIET=1
17-
- CFLAGS="-DLFS_BLOCK_COUNT=1023 -DLFS_LOOKAHEAD=2048" make test QUIET=1
51+
# CI matrix
52+
jobs:
53+
include:
54+
# native testing
55+
- stage: test
56+
env:
57+
- STAGE=test
58+
- NAME=littlefs-x86
59+
60+
# cross-compile with ARM (thumb mode)
61+
- stage: test
62+
env:
63+
- STAGE=test
64+
- NAME=littlefs-arm
65+
- CC="arm-linux-gnueabi-gcc --static -mthumb"
66+
- EXEC="qemu-arm"
67+
install:
68+
- sudo apt-get install gcc-arm-linux-gnueabi qemu-user
69+
- arm-linux-gnueabi-gcc --version
70+
- qemu-arm -version
71+
72+
# cross-compile with PowerPC
73+
- stage: test
74+
env:
75+
- STAGE=test
76+
- NAME=littlefs-powerpc
77+
- CC="powerpc-linux-gnu-gcc --static"
78+
- EXEC="qemu-ppc"
79+
install:
80+
- sudo apt-get install gcc-powerpc-linux-gnu qemu-user
81+
- powerpc-linux-gnu-gcc --version
82+
- qemu-ppc -version
83+
84+
# cross-compile with MIPS
85+
- stage: test
86+
env:
87+
- STAGE=test
88+
- NAME=littlefs-mips
89+
- CC="mips-linux-gnu-gcc --static"
90+
- EXEC="qemu-mips"
91+
install:
92+
- sudo add-apt-repository -y "deb http://archive.ubuntu.com/ubuntu/ xenial main universe"
93+
- sudo apt-get -qq update
94+
- sudo apt-get install gcc-mips-linux-gnu qemu-user
95+
- mips-linux-gnu-gcc --version
96+
- qemu-mips -version
1897

1998
# self-host with littlefs-fuse for fuzz test
20-
- make -C littlefs-fuse
99+
- stage: test
100+
env:
101+
- STAGE=test
102+
- NAME=littlefs-fuse
103+
install:
104+
- sudo apt-get install libfuse-dev
105+
- git clone --depth 1 https://github.com/geky/littlefs-fuse
106+
- fusermount -V
107+
- gcc --version
108+
before_script:
109+
# setup disk for littlefs-fuse
110+
- rm -rf littlefs-fuse/littlefs/*
111+
- cp -r $(git ls-tree --name-only HEAD) littlefs-fuse/littlefs
112+
113+
- mkdir mount
114+
- sudo chmod a+rw /dev/loop0
115+
- dd if=/dev/zero bs=512 count=2048 of=disk
116+
- losetup /dev/loop0 disk
117+
script:
118+
# self-host test
119+
- make -C littlefs-fuse
120+
121+
- littlefs-fuse/lfs --format /dev/loop0
122+
- littlefs-fuse/lfs /dev/loop0 mount
21123

22-
- littlefs-fuse/lfs --format /dev/loop0
23-
- littlefs-fuse/lfs /dev/loop0 mount
124+
- ls mount
125+
- mkdir mount/littlefs
126+
- cp -r $(git ls-tree --name-only HEAD) mount/littlefs
127+
- cd mount/littlefs
128+
- ls
129+
- make -B test_dirs test_files QUIET=1
24130

25-
- ls mount
26-
- mkdir mount/littlefs
27-
- cp -r $(git ls-tree --name-only HEAD) mount/littlefs
28-
- cd mount/littlefs
29-
- ls
30-
- make -B test_dirs QUIET=1
131+
# Automatically update releases
132+
- stage: deploy
133+
env:
134+
- STAGE=deploy
135+
- NAME=deploy
136+
script:
137+
# Update tag for version defined in lfs.h
138+
- LFS_VERSION=$(grep -ox '#define LFS_VERSION .*' lfs.h | cut -d ' ' -f3)
139+
- LFS_VERSION_MAJOR=$((0xffff & ($LFS_VERSION >> 16)))
140+
- LFS_VERSION_MINOR=$((0xffff & ($LFS_VERSION >> 0)))
141+
- LFS_VERSION="v$LFS_VERSION_MAJOR.$LFS_VERSION_MINOR"
142+
- echo "littlefs version $LFS_VERSION"
143+
- |
144+
curl -u $GEKY_BOT_RELEASES -X POST \
145+
https://api.github.com/repos/$TRAVIS_REPO_SLUG/git/refs \
146+
-d "{
147+
\"ref\": \"refs/tags/$LFS_VERSION\",
148+
\"sha\": \"$TRAVIS_COMMIT\"
149+
}"
150+
- |
151+
curl -f -u $GEKY_BOT_RELEASES -X PATCH \
152+
https://api.github.com/repos/$TRAVIS_REPO_SLUG/git/refs/tags/$LFS_VERSION \
153+
-d "{
154+
\"sha\": \"$TRAVIS_COMMIT\"
155+
}"
156+
# Create release notes from commits
157+
- LFS_PREV_VERSION="v$LFS_VERSION_MAJOR.$(($LFS_VERSION_MINOR-1))"
158+
- |
159+
if [ $(git tag -l "$LFS_PREV_VERSION") ]
160+
then
161+
curl -u $GEKY_BOT_RELEASES -X POST \
162+
https://api.github.com/repos/$TRAVIS_REPO_SLUG/releases \
163+
-d "{
164+
\"tag_name\": \"$LFS_VERSION\",
165+
\"name\": \"$LFS_VERSION\"
166+
}"
167+
RELEASE=$(
168+
curl -f https://api.github.com/repos/$TRAVIS_REPO_SLUG/releases/tags/$LFS_VERSION
169+
)
170+
CHANGES=$(
171+
git log --oneline $LFS_PREV_VERSION.. --grep='^Merge' --invert-grep
172+
)
173+
curl -f -u $GEKY_BOT_RELEASES -X PATCH \
174+
https://api.github.com/repos/$TRAVIS_REPO_SLUG/releases/$(
175+
jq -r '.id' <<< "$RELEASE"
176+
) \
177+
-d "$(
178+
jq -s '{
179+
"body": ((.[0] // "" | sub("(?<=\n)#+ Changes.*"; ""; "mi"))
180+
+ "### Changes\n\n" + .[1])
181+
}' <(jq '.body' <<< "$RELEASE") <(jq -sR '.' <<< "$CHANGES")
182+
)"
183+
fi
31184
185+
# Manage statuses
32186
before_install:
33-
- fusermount -V
34-
- gcc --version
187+
- |
188+
curl -u $GEKY_BOT_STATUSES -X POST \
189+
https://api.github.com/repos/$TRAVIS_REPO_SLUG/statuses/${TRAVIS_PULL_REQUEST_SHA:-$TRAVIS_COMMIT} \
190+
-d "{
191+
\"context\": \"$STAGE/$NAME\",
192+
\"state\": \"pending\",
193+
\"description\": \"${STATUS:-In progress}\",
194+
\"target_url\": \"https://travis-ci.org/$TRAVIS_REPO_SLUG/jobs/$TRAVIS_JOB_ID\"
195+
}"
35196
36-
install:
37-
- sudo apt-get install libfuse-dev
38-
- git clone --depth 1 https://github.com/geky/littlefs-fuse
197+
after_failure:
198+
- |
199+
curl -u $GEKY_BOT_STATUSES -X POST \
200+
https://api.github.com/repos/$TRAVIS_REPO_SLUG/statuses/${TRAVIS_PULL_REQUEST_SHA:-$TRAVIS_COMMIT} \
201+
-d "{
202+
\"context\": \"$STAGE/$NAME\",
203+
\"state\": \"failure\",
204+
\"description\": \"${STATUS:-Failed}\",
205+
\"target_url\": \"https://travis-ci.org/$TRAVIS_REPO_SLUG/jobs/$TRAVIS_JOB_ID\"
206+
}"
39207
40-
before_script:
41-
- rm -rf littlefs-fuse/littlefs/*
42-
- cp -r $(git ls-tree --name-only HEAD) littlefs-fuse/littlefs
208+
after_success:
209+
- |
210+
curl -u $GEKY_BOT_STATUSES -X POST \
211+
https://api.github.com/repos/$TRAVIS_REPO_SLUG/statuses/${TRAVIS_PULL_REQUEST_SHA:-$TRAVIS_COMMIT} \
212+
-d "{
213+
\"context\": \"$STAGE/$NAME\",
214+
\"state\": \"success\",
215+
\"description\": \"${STATUS:-Passed}\",
216+
\"target_url\": \"https://travis-ci.org/$TRAVIS_REPO_SLUG/jobs/$TRAVIS_JOB_ID\"
217+
}"
43218
44-
- mkdir mount
45-
- sudo chmod a+rw /dev/loop0
46-
- dd if=/dev/zero bs=512 count=2048 of=disk
47-
- losetup /dev/loop0 disk
219+
# Job control
220+
stages:
221+
- name: test
222+
- name: deploy
223+
if: branch = master

0 commit comments

Comments
 (0)