3 # MIT Alexander Couzens <lynxis@fe80.eu>
8 SDK_PATH
=https
://downloads.lede-project.org
/snapshots
/targets
/ar71xx
/generic
/
9 SDK
=openwrt-sdk-ar71xx-generic_gcc-5.5
.0_musl.Linux-x86_64
12 echo_red
() { printf "\033[1;31m$*\033[m\n"; }
13 echo_green
() { printf "\033[1;32m$*\033[m\n"; }
14 echo_blue
() { printf "\033[1;34m$*\033[m\n"; }
19 while :;do sleep 590;echo "still running (please don't kill me Travis)";done &
20 ("$@" 2>&1) |
tee logoutput
22 kill $
! && wait $
! 2>/dev
/null
24 echo_red
"=> '$*' failed (return code $R)"
27 if grep -qE "$PATTERN" logoutput
; then
28 echo_red
"=> '$*' failed (log matched '$PATTERN')"
32 echo_green
"=> '$*' successful"
36 # download will run on the `before_script` step
37 # The travis cache will be used (all files under $HOME/sdk/). Meaning
38 # We don't have to download the file again
43 echo_blue
"=== download SDK"
44 wget
"$SDK_PATH/sha256sums" -O sha256sums
45 wget
"$SDK_PATH/sha256sums.gpg" -O sha256sums.asc
47 # LEDE Build System (LEDE GnuPG key for unattended build jobs)
48 gpg
--import $PACKAGES_DIR/.travis
/626471F1.asc
49 echo '54CC74307A2C6DC9CE618269CD84BCED626471F1:6:' | gpg
--import-ownertrust
50 # LEDE Release Builder (17.01 "Reboot" Signing Key)
51 gpg
--import $PACKAGES_DIR/.travis
/D52BBB6B.asc
52 echo 'B09BE781AE8A0CD4702FDCD3833C6010D52BBB6B:6:' | gpg
--import-ownertrust
54 gpg
--verify sha256sums.asc
55 grep "$SDK" sha256sums
> sha256sums.small
57 # if missing, outdated or invalid, download again
58 if ! sha256sum
-c .
/sha256sums.small
; then
59 wget
"$SDK_PATH/$SDK.tar.xz" -O "$SDK.tar.xz"
62 # check again and fail here if the file is still bad
63 sha256sum
-c .
/sha256sums.small
64 echo_blue
"=== SDK is up-to-date"
67 # test_package will run on the `script` step.
68 # test_package call make download check for very new/modified package
70 local commit_range
=$TRAVIS_COMMIT_RANGE
71 if [ -z "$TRAVIS_PULL_REQUEST_SHA" ]; then
72 echo_blue
"Using only the latest commit, since we're not in a Pull Request"
76 # search for new or modified packages. PKGS will hold a list of package like 'admin/muninlite admin/monit ...'
77 PKGS
=$
(git
diff --diff-filter=d
--name-only "$commit_range" |
grep 'Makefile$' |
grep -v '/files/' |
awk -F'/Makefile' '{ print $1 }')
79 if [ -z "$PKGS" ] ; then
80 echo_blue
"No new or modified packages found!"
84 echo_blue
"=== Found new/modified packages:"
89 echo_blue
"=== Setting up SDK"
92 tar Jxf
"$SDK_HOME/$SDK.tar.xz" --strip=1
94 # use github mirrors to spare lede servers
95 cat > feeds.conf
<<EOF
96 src-git base https://github.com/lede-project/source.git
97 src-link packages $PACKAGES_DIR
98 src-git luci https://github.com/openwrt/luci.git
102 sed -i '1s/^/config BUILD_LOG\n\tbool\n\tdefault y\n\n/' Config-build.
in
104 .
/scripts
/feeds update
-a > /dev
/null
105 .
/scripts
/feeds
install -a > /dev
/null
106 make defconfig
> /dev
/null
107 echo_blue
"=== Setting up SDK done"
110 # E.g: pkg_dir => admin/muninlite
111 # pkg_name => muninlite
112 for pkg_dir
in $PKGS ; do
113 pkg_name
=$
(echo "$pkg_dir" |
awk -F/ '{ print $NF }')
114 echo_blue
"=== $pkg_name: Starting quick tests"
116 exec_status
'WARNING|ERROR' make "package/$pkg_name/download" V
=s || RET
=1
117 exec_status
'WARNING|ERROR' make "package/$pkg_name/check" V
=s || RET
=1
119 echo_blue
"=== $pkg_name: quick tests done"
122 [ $RET -ne 0 ] && return $RET
124 for pkg_dir
in $PKGS ; do
125 pkg_name
=$
(echo "$pkg_dir" |
awk -F/ '{ print $NF }')
126 echo_blue
"=== $pkg_name: Starting compile test"
128 # we can't enable verbose built else we often hit Travis limits
129 # on log size and the job get killed
130 exec_status
'^ERROR' make "package/$pkg_name/compile" -j3 || RET
=1
132 echo_blue
"=== $pkg_name: compile test done"
134 echo_blue
"=== $pkg_name: begin compile logs"
135 for f
in $
(find logs
/package
/feeds
/packages
/$pkg_name/ -type f
); do
136 echo_blue
"Printing last 200 lines of $f"
139 echo_blue
"=== $pkg_name: end compile logs"
141 echo_blue
"=== $pkg_name: begin packages sizes"
143 echo_blue
"=== $pkg_name: end packages sizes"
151 if [ -z "$TRAVIS_PULL_REQUEST_SHA" ]; then
152 echo_blue
"Skipping commits tests (not in a Pull Request)"
155 for commit
in $
(git rev-list
${TRAVIS_COMMIT_RANGE/.../..}); do
156 echo_blue
"=== Checking commit '$commit'"
157 if git show
--format='%P' -s $commit |
grep -qF ' '; then
158 echo_red
"Pull request should not include merge commits"
162 author
="$(git show -s --format=%aN $commit)"
163 if echo $author |
grep -q '\S\+\s\+\S\+'; then
164 echo_green
"Author name ($author) seems ok"
166 echo_red
"Author name ($author) need to be your real name 'firstname lastname'"
170 subject
="$(git show -s --format=%s $commit)"
171 if echo "$subject" |
grep -q -e '^[0-9A-Za-z,/_-]\+: ' -e '^Revert '; then
172 echo_green
"Commit subject line seems ok ($subject)"
174 echo_red
"Commit subject line MUST start with '<package name>: ' ($subject)"
178 body
="$(git show -s --format=%b $commit)"
179 sob
="$(git show -s --format='Signed-off-by: %aN <%aE>' $commit)"
180 if echo "$body" |
grep -qF "$sob"; then
181 echo_green
"Signed-off-by match author"
183 echo_red
"Signed-off-by is missing or doesn't match author (should be '$sob')"
192 test_commits
&& test_packages2 ||
return 1
195 echo_blue
"=== Travis ENV"
197 echo_blue
"=== Travis ENV"
199 if [ -n "$TRAVIS_PULL_REQUEST_SHA" ]; then
201 # if clone depth is too small, git rev-list / diff return incorrect or empty results
202 C
="$(git rev-list ${TRAVIS_COMMIT_RANGE/.../..} | tail -n1)" 2>/dev
/null
203 [ -n "$C" -a "$C" != "a22de9b74cf9579d1ce7e6cf1845b4afa4277b00" ] && break
204 echo_blue
"Fetching 50 commits more"
205 git fetch origin
--deepen=50
209 if [ $# -ne 1 ] ; then
211 Usage: $0 (download_sdk|test_packages)
213 download_sdk - download the SDK to $HOME/sdk.tar.xz
214 test_packages - do a make check on the package