forked from awesomeWM/awesome
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
260 lines (238 loc) · 10.1 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
sudo: required
dist: trusty
language: c
# Build only master and stable branches. Other branches go through PRs.
branches:
only:
- master
- 3.5
env:
matrix:
- LUA=5.2 LUANAME=lua5.2 DO_COVERAGE=coveralls
# Lua 5.3 isn't available in Ubuntu Trusty, so some magic below installs it.
- LUA=5.3 LUANAME=lua5.3 LUALIBRARY=/usr/lib/liblua.so DO_COVERAGE=codecov
# luajit: installed from source.
- LUA=5.1 LUANAME=luajit-2.0 LUALIBRARY=/usr/lib/libluajit-5.1.so LUAROCKS_ARGS=--lua-suffix=jit-2.0.5 TEST_PREV_COMMITS=1
# Note: luarocks does not work with Lua 5.0.
- LUA=5.1 LUANAME=lua5.1 BUILD_IN_DIR=/tmp/awesome-build
# Lua 5.2 with older lgi and screen size not divisible by 2.
# SOURCE_DATE_EPOCH: used for stable dates during build.
- LUA=5.2 LUANAME=lua5.2 LGIVER=0.8.0 TESTS_SCREEN_SIZE=1921x1079 BUILD_APIDOC=true DO_CHECKQA=1 EMPTY_THEME_WHILE_LOADING=1 SOURCE_DATE_EPOCH=1893456000
global:
# Secure GH_APIDOC_TOKEN to push to awesomeWM/apidoc.
- secure: "R/HYDclnws1I1+v9Yjt+RKa4CsFhbBT9tiwE3EfPhEj2KCYX4sFRMxuZvLf5sq0XWdrQaPhQ54fgAZGr3f054JKRXcTB0g9J6nhSHz9kIjPh446gafUhEeDQcZRwM/MeCWiwFIkiZm6smYoDFE9JTWu6quNV+lQ4kcVDOp2ibEc="
before_install:
- if [ "$BUILD_APIDOC" = true ] && [ -n "$DO_COVERAGE" ]; then echo "BUILD_APIDOC and DO_COVERAGE are not meant to be used together." >&2; exit 1; fi
- if [ -z $LUAINCLUDE ]; then LUAINCLUDE=/usr/include/${LUANAME}; fi
- if [ -z $LUALIBRARY ]; then LUALIBRARY=/usr/lib/x86_64-linux-gnu/lib${LUANAME}.so; fi
- cmake --version
install:
# Travis boilerplate: the apt-get cache might be out of date.
- travis_retry sudo apt-get update -qq
# Do not install recommended packages with apt-get.
- echo 'APT::Install-Recommends "false";' | sudo tee /etc/apt/apt.conf.d/no-recommends
# Install build dependencies.
# See also `apt-cache showsrc awesome | grep -E '^(Version|Build-Depends)'`.
- sudo apt-get install -y libcairo2-dev gir1.2-gtk-3.0 xmlto asciidoc libpango1.0-dev libxcb-xtest0-dev libxcb-icccm4-dev libxcb-randr0-dev libxcb-keysyms1-dev libxcb-xinerama0-dev libdbus-1-dev libxdg-basedir-dev libstartup-notification0-dev imagemagick libxcb1-dev libxcb-shape0-dev libxcb-util0-dev libx11-xcb-dev libxcb-cursor-dev libxcb-xkb-dev libxkbcommon-dev libxkbcommon-x11-dev
# Deps for tests.
- sudo apt-get install -y dbus-x11 xterm xdotool xterm xvfb zsh
# Need xorg-macros
- sudo apt-get install -y xutils-dev
- |
set -e
(git clone --depth 1 --recursive https://github.com/Airblader/xcb-util-xrm.git /tmp/xcb-util-xrm
cd /tmp/xcb-util-xrm
./autogen.sh --prefix=/usr
make && sudo make install)
# Install Lua (per env).
# Note that Lua 5.3 is installed manually, because it is not available in Ubuntu Trusty.
- |
set -e
if [[ "$LUA" == "5.3" ]]; then
(echo '#!/bin/sh' ; echo 'set -x' ; echo 'gcc -shared -Wl,--no-undefined -o "$@" -ldl -lm') > /tmp/myar
chmod a+x /tmp/myar
(cd /tmp
wget http://www.lua.org/ftp/lua-5.3.4.tar.gz -O lua.tar.gz
tar -xvzf lua.tar.gz
cd lua-5.3.*/src \
&& make SYSCFLAGS="-DLUA_USE_LINUX -ULUA_COMPAT_5_2 -DLUA_USE_APICHECK" SYSLIBS="-Wl,-E -ldl -lreadline" LUA_A=liblua.so MYCFLAGS="-fPIC" RANLIB=: AR="/tmp/myar" liblua.so \
&& cd .. \
&& sudo make INSTALL_TOP=/usr/ INSTALL_INC=${LUAINCLUDE} TO_LIB=liblua.so linux install)
elif [[ "$LUANAME" == "luajit-2.0" ]]; then
(wget http://luajit.org/download/LuaJIT-2.0.5.tar.gz -O- | tar xzf - -C /tmp
cd /tmp/LuaJIT-*
sudo make install PREFIX=/usr)
# "Create" /usr/bin/lua if needed (Yup, this is a bad hack)
if [ ! -e "/usr/bin/lua" ]; then sudo ln -s /usr/bin/luajit /usr/bin/lua; fi
else
sudo apt-get install -y lib${LUANAME}-dev ${LUANAME} ${INSTALL_PKGS}
fi
# Install luarocks (for the selected Lua version).
- |
travis_retry wget https://github.com/luarocks/luarocks/archive/v2.4.2.tar.gz
tar xf v2.4.2.tar.gz -C /tmp
(cd /tmp/luarocks-* \
&& ./configure --lua-version=$LUA --with-lua-include=${LUAINCLUDE} ${LUAROCKS_ARGS} \
&& make build \
&& sudo make install)
# lgi.
- sudo apt-get install -y gir1.2-pango-1.0 libgirepository1.0-dev
- travis_retry sudo luarocks install lgi $LGIVER
# Install busted for "make check-unit".
- travis_retry sudo luarocks install busted
# Install luacheck for "make check-qa".
- if [ "$DO_CHECKQA" = 1 ]; then travis_retry sudo luarocks install luacheck; fi
# Install depgraph for "make check-qa".
- if [ "$DO_CHECKQA" = 1 ]; then travis_retry sudo luarocks install depgraph; fi
# Install ldoc for building docs and check-ldoc-warnings.
- |
if [ "$BUILD_APIDOC" = "true" ] || [ "$DO_CHECKQA" = 1 ]; then
travis_retry sudo luarocks install ldoc
travis_retry sudo luarocks install lua-discount
fi
# Install dependencies for code coverage testing.
- if [ -n "$DO_COVERAGE" ]; then sudo luarocks install cluacov; fi
- if [ "$DO_COVERAGE" = "coveralls" ]; then sudo luarocks install luacov-coveralls; fi
# Determine custom version.
- export AWESOME_VERSION="${TRAVIS_BRANCH}-g$(git rev-parse --short HEAD)"
- |
if [ "$TRAVIS_PULL_REQUEST" != false ] && [ "$TEST_PREV_COMMITS" = 1 ]; then
AWESOME_VERSION="${AWESOME_VERSION}-PR${TRAVIS_PULL_REQUEST}"
elif [ "$TRAVIS_PULL_REQUEST" != false ]; then
AWESOME_VERSION="v9999-PR${TRAVIS_PULL_REQUEST}";
fi
# function for codecov support
- if [ "$DO_COVERAGE" = "codecov" ]; then travis_retry wget -O /tmp/codecov-bash https://codecov.io/bash; fi
- |
do_codecov() {
echo "== do_codecov in $PWD: $*: build/luacov.stats.out: =="
if [ "$DO_COVERAGE" = "codecov" ]; then
test -f build/luacov.stats.out || { echo 'build/luacov.stats.out does not exist.'; return 1; }
luacov || return 1
travis_retry bash /tmp/codecov-bash -X gcov -X coveragepy -c -F "$1,${LUANAME//./}" || return 1
rm build/luacov.stats.out
fi
return 0
}
- |
do_codecov_gcov() {
echo "== do_codecov_gcov in $PWD: $*: =="
if [ "$DO_COVERAGE" = "codecov" ]; then
travis_retry bash /tmp/codecov-bash -X coveragepy -c -F "$1" || return 1
fi
return 0
}
# Functions for custom Travis folds.
- |
travis_fold_start() {
travis_fold start "$1"
travis_fold_current="$1"
}
travis_fold_end() {
travis_fold end "$travis_fold_current"
}
travis_run_in_fold() {
travis_fold_start "$1"
shift
"$@" || return 1
travis_fold_end
return 0
}
script:
- export CMAKE_ARGS="-DLUA_LIBRARY=${LUALIBRARY} -DLUA_INCLUDE_DIR=${LUAINCLUDE} -D OVERRIDE_VERSION=$AWESOME_VERSION -DSTRICT_TESTS=true -D DO_COVERAGE=$DO_COVERAGE"
- |
if [ "$EMPTY_THEME_WHILE_LOADING" = 1 ]; then
# Break beautiful so that trying to access the theme before beautiful.init() causes an error
sed -i -e 's/theme = {}/theme = setmetatable({}, { __index = function() error("May not access theme before beautiful.init()") end })/' lib/beautiful/init.lua \
&& grep -q 'May not access' lib/beautiful/init.lua
fi
- |
set -e
if [ -n "$BUILD_IN_DIR" ]; then
# Explicitly remove the Makefile to not build from the src dir accidentally.
rm Makefile
SOURCE_DIRECTORY="$PWD"
mkdir "$BUILD_IN_DIR"
cd "$BUILD_IN_DIR"
travis_run_in_fold "build_in_dir" cmake $CMAKE_ARGS "$SOURCE_DIRECTORY"
fi
- travis_run_in_fold "make" make
- |
if [ "$TRAVIS_TEST_RESULT" = 0 ]; then
travis_run_in_fold "make.install" sudo env PATH=$PATH make install
awesome --version
fi
# Run checks.
- |
if [ "$TRAVIS_TEST_RESULT" = 0 ]; then
set -ex
if [ -n "$DO_COVERAGE" ]; then
travis_fold_start "DO_COVERAGE"
# Run tests/examples explicitly.
(mkdir -p tests/examples/build \
&& cd tests/examples/build \
&& cmake $CMAKE_ARGS ..)
do_codecov samples
make check-unit-coverage || exit 1
do_codecov unittests
make check-integration || exit 1
make check-themes || exit 1
do_codecov functionaltests
do_codecov_gcov c_code
travis_fold_end
else
travis_run_in_fold "make.check-unit" make check-unit
travis_run_in_fold "make.check-integration" make check-integration
travis_run_in_fold "make.check-themes" make check-themes
fi
set +x
fi
# Run check-qa.
- |
if [ "$DO_CHECKQA" = 1 ]; then
travis_run_in_fold "make.check-qa" make check-qa
fi
- |
set -e
if [ "$TEST_PREV_COMMITS" = 1 ] && ! [ "$TRAVIS_PULL_REQUEST" = false ]; then
# Check each commit separately (to make git-bisect less annoying).
# Fix Travis' commit range (https://github.com/travis-ci/travis-ci/issues/4596).
commit_range="${TRAVIS_COMMIT_RANGE/.../..}"
echo "Testing previous commits ($commit_range)"
rev_list="$(git rev-list --bisect-all $commit_range)"
echo "rev-list: $rev_list"
commits="$(echo "$rev_list" | grep -v 'dist=0' | cut -d\ -f 1)"
n="$(echo "$commits" | wc -l)"
echo "Testing $n commits: $commits"
i=0
failed=
for commit in $commits; do
i=$((i+1))
travis_fold_start "test_commit_${commit}_.$i.$n"
echo "Testing commit $commit"
git checkout "$commit"
git --no-pager show --stat
if ! make all check CMAKE_ARGS+="-D DO_COVERAGE=0"; then
failed="$failed $commit"
fi
travis_fold_end
done
git checkout -qf FETCH_HEAD
if [ -n "$failed" ]; then
echo "Checks failed for these commits:"
for c in $commits; do
git log -1 --pretty="%h %s (%an, %ad)" "$c"
done
false
fi
fi
after_success:
# Push updated API docs for relevant branches, e.g. non-PRs builds on master.
- if [ "$BUILD_APIDOC" = "true" ]; then build-utils/travis-apidoc.sh; fi
# Push code coverage information
- |
set -e
if [ "$DO_COVERAGE" = "coveralls" ]; then
test -f build/luacov.stats.out || { echo 'build/luacov.stats.out does not exist.'; return 1; }
luacov-coveralls --verbose --merge
fi