forked from geky/littlefs-fuse-test-repo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
90 lines (86 loc) · 2.97 KB
/
.travis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# Environment variables
env:
global:
- CFLAGS=-Werror
cache:
pip: true
directories:
- $HOME/.cache/apt
# CI Jobs
jobs:
include:
# Test stage
- stage: test
env:
- STAGE=test
install:
- sudo apt-get install python3 python3-pip
- sudo pip3 install toml
- sudo apt-get install libfuse-dev
- fusermount -V
- gcc --version
before_script:
- mkdir mount
- sudo chmod a+rw /dev/loop0
- dd if=/dev/zero bs=512 count=128K of=disk
- losetup /dev/loop0 disk
script:
# Build
- make
# Format and mount
- ./lfs --format /dev/loop0
- ./lfs /dev/loop0 mount
# Some simple operations than self hosting test
- ls mount
- cp -r littlefs mount/littlefs
- cd mount/littlefs
- stat .
- ls -flh
- make -B test
# Deploy stage for updating versions and tags
- stage: deploy
env:
- STAGE=deploy
script:
- |
bash << 'SCRIPT'
set -ev
# Find version defined in lfs.h
LFS_VERSION=$(grep -ox '#define LFS_VERSION .*' littlefs/lfs.h | cut -d ' ' -f3)
LFS_VERSION_MAJOR=$((0xffff & ($LFS_VERSION >> 16)))
LFS_VERSION_MINOR=$((0xffff & ($LFS_VERSION >> 0)))
# Grab latest patch from repo tags, default to 0, needs finagling
# to get past GitHub's pagination API
PREV_URL=https://api.github.com/repos/$TRAVIS_REPO_SLUG/git/refs/tags/v$LFS_VERSION_MAJOR.$LFS_VERSION_MINOR.
PREV_URL=$(curl -u "$GEKY_BOT_RELEASES" "$PREV_URL" -I \
| sed -n '/^Link/{s/.*<\(.*\)>; rel="last"/\1/;p;q0};$q1' \
|| echo $PREV_URL)
LFS_VERSION_PATCH=$(curl -u "$GEKY_BOT_RELEASES" "$PREV_URL" \
| jq 'map(.ref | match("\\bv.*\\..*\\.(.*)$";"g")
.captures[].string | tonumber) | max + 1' \
|| echo 0)
# We have our new version
LFS_VERSION="v$LFS_VERSION_MAJOR.$LFS_VERSION_MINOR.$LFS_VERSION_PATCH"
echo "VERSION $LFS_VERSION"
# Check that we're the most recent commit
CURRENT_COMMIT=$(curl -f -u "$GEKY_BOT_RELEASES" \
https://api.github.com/repos/$TRAVIS_REPO_SLUG/commits/master \
| jq -re '.sha')
[ "$TRAVIS_COMMIT" == "$CURRENT_COMMIT" ] || exit 0
# Create major branch (vN)
git branch v$LFS_VERSION_MAJOR HEAD
git push https://[email protected]/$TRAVIS_REPO_SLUG.git \
v$LFS_VERSION_MAJOR
# Create patch version tag (vN.N.N)
curl -f -u "$GEKY_BOT_RELEASES" -X POST \
https://api.github.com/repos/$TRAVIS_REPO_SLUG/git/refs \
-d "{
\"ref\": \"refs/tags/$LFS_VERSION\",
\"sha\": \"$TRAVIS_COMMIT\"
}"
SCRIPT
# Job control
stages:
- name: test
- name: deploy
if: branch = master AND type = push