3 # MIT Alexander Couzens <lynxis@fe80.eu>
8 SDK_PATH
=https
://downloads.lede-project.org
/snapshots
/targets
/ar71xx
/generic
/
9 SDK
=lede-sdk-ar71xx-generic_gcc-5.4
.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 ("$@" 2>&1) |
tee logoutput
22 echo_red
"=> '$*' failed (return code $R)"
25 if grep -qE "$PATTERN" logoutput
; then
26 echo_red
"=> '$*' failed (log matched '$PATTERN')"
30 echo_green
"=> '$*' successful"
34 # download will run on the `before_script` step
35 # The travis cache will be used (all files under $HOME/sdk/). Meaning
36 # We don't have to download the file again
41 echo_blue
"=== download SDK"
42 wget
"$SDK_PATH/sha256sums" -O sha256sums
43 wget
"$SDK_PATH/sha256sums.gpg" -O sha256sums.asc
45 # LEDE Build System (LEDE GnuPG key for unattended build jobs)
46 gpg
--recv 0xCD84BCED626471F1
47 # LEDE Release Builder (17.01 "Reboot" Signing Key)
48 gpg
--recv 0x833C6010D52BBB6B
49 gpg
--verify sha256sums.asc
50 grep "$SDK" sha256sums
> sha256sums.small
52 # if missing, outdated or invalid, download again
53 if ! sha256sum
-c .
/sha256sums.small
; then
54 wget
"$SDK_PATH/$SDK.tar.xz" -O "$SDK.tar.xz"
57 # check again and fail here if the file is still bad
58 sha256sum
-c .
/sha256sums.small
59 echo_blue
"=== SDK is up-to-date"
62 # test_package will run on the `script` step.
63 # test_package call make download check for very new/modified package
65 # search for new or modified packages. PKGS will hold a list of package like 'admin/muninlite admin/monit ...'
66 PKGS
=$
(git
diff --diff-filter=d
--name-only "$TRAVIS_COMMIT_RANGE" |
grep 'Makefile$' |
grep -v '/files/' |
awk -F'/Makefile' '{ print $1 }')
68 if [ -z "$PKGS" ] ; then
69 echo_blue
"No new or modified packages found!"
73 echo_blue
"=== Found new/modified packages:"
78 echo_blue
"=== Setting up SDK"
81 tar Jxf
"$SDK_HOME/$SDK.tar.xz" --strip=1
83 # use github mirrors to spare lede servers
84 cat > feeds.conf
<<EOF
85 src-git base https://github.com/lede-project/source.git
86 src-link packages $PACKAGES_DIR
87 src-git luci https://github.com/openwrt/luci.git
91 sed -i '1s/^/config BUILD_LOG\n\tbool\n\tdefault y\n\n/' Config-build.
in
93 .
/scripts
/feeds update
-a
94 .
/scripts
/feeds
install -a
96 echo_blue
"=== Setting up SDK done"
99 # E.g: pkg_dir => admin/muninlite
100 # pkg_name => muninlite
101 for pkg_dir
in $PKGS ; do
102 pkg_name
=$
(echo "$pkg_dir" |
awk -F/ '{ print $NF }')
103 echo_blue
"=== $pkg_name: Starting quick tests"
105 exec_status
'WARNING|ERROR' make "package/$pkg_name/download" V
=s || RET
=1
106 exec_status
'WARNING|ERROR' make "package/$pkg_name/check" V
=s || RET
=1
108 echo_blue
"=== $pkg_name: quick tests done"
111 [ $RET -ne 0 ] && return $RET
113 for pkg_dir
in $PKGS ; do
114 pkg_name
=$
(echo "$pkg_dir" |
awk -F/ '{ print $NF }')
115 echo_blue
"=== $pkg_name: Starting compile test"
117 # we can't enable verbose built else we often hit Travis limits
118 # on log size and the job get killed
119 exec_status
'^ERROR' make "package/$pkg_name/compile" -j3
121 echo_blue
"=== $pkg_name: compile test done"
123 echo_blue
"=== $pkg_name: begin compile logs"
124 cat logs
/package
/feeds
/packages
/$pkg_name/compile.txt
125 echo_blue
"=== $pkg_name: end compile logs"
133 for commit
in $
(git rev-list
${TRAVIS_COMMIT_RANGE/.../..}); do
134 echo_blue
"=== Checking commit '$commit'"
135 if git show
--format='%P' -s $commit |
grep -qF ' '; then
136 echo_red
"Pull request should not include merge commits"
140 author
="$(git show -s --format=%aN $commit)"
141 if echo $author |
grep -q '\S\+\s\+\S\+'; then
142 echo_green
"Author name ($author) seems ok"
144 echo_red
"Author name ($author) need to be your real name 'firstname lastname'"
148 subject
="$(git show -s --format=%s $commit)"
149 if echo "$subject" |
grep -q -e '^[0-9A-Za-z,/-]\+: ' -e '^Revert '; then
150 echo_green
"Commit subject line seems ok ($subject)"
152 echo_red
"Commit subject line MUST start with '<package name>: ' ($subject)"
156 body
="$(git show -s --format=%b $commit)"
157 sob
="$(git show -s --format='Signed-off-by: %aN <%aE>' $commit)"
158 if echo "$body" |
grep -qF "$sob"; then
159 echo_green
"Signed-off-by match author"
161 echo_red
"Signed-off-by is missing or doesn't match author (should be '$sob')"
170 test_commits
&& test_packages2 ||
return 1
173 echo_blue
"=== Travis ENV"
175 echo_blue
"=== Travis ENV"
178 # if clone depth is too small, git rev-list / diff return incorrect or empty results
179 C
="$(git rev-list ${TRAVIS_COMMIT_RANGE/.../..} | tail -n1)" 2>/dev
/null
180 [ -n "$C" -a "$C" != "a22de9b74cf9579d1ce7e6cf1845b4afa4277b00" ] && break
181 echo_blue
"Fetching 50 commits more"
182 git fetch origin
--deepen=50
185 if [ "$TRAVIS_PULL_REQUEST" = false
] ; then
186 echo "Only Pull Requests are supported at the moment." >&2
191 if [ $# -ne 1 ] ; then
193 Usage: $0 (download_sdk|test_packages)
195 download_sdk - download the SDK to $HOME/sdk.tar.xz
196 test_packages - do a make check on the package