-
Notifications
You must be signed in to change notification settings - Fork 49
/
.travis.yml
335 lines (316 loc) · 11.8 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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
language: python
branches:
except:
- latest
- latest-tmp
matrix:
fast_finish: true
include:
- os: linux
python: 2.7
- os: osx
language: generic
env: PYTHON=2.7.14
- os: osx
osx_image: xcode6.4
language: generic
env:
- PYTHON=2.7.14
- BIN_SUFFIX=legacy
env:
global:
- PIPENV=9.0.3
- secure: "CnchGXzH12uHNHwVeSdfyi/UBoHONNogxVaM+fIzcZXadiK3mm6mnjoBSXiFabNAgmMr20BHZ5OSB8qZLX5L0jMxrH3zfvlTUFivibL+IHAqPC/Jt1EpABDxbE+BMLVcpJBOVztDpACNDomnVX1X+mLhG2lbcD0x/XlZJugpB68="
before_install:
# Need to disable the boto configuration before starting a sudo-enabled
# build in Travis, or the tests will fail (as one of the modules loads
# boto)
- export BOTO_CONFIG=/dev/null
# If we did not define the python version in the environment, set it as
# being the one provided by Travis
- if [ -z "${PYTHON}" ]; then
PYTHON="${TRAVIS_PYTHON_VERSION}";
fi
# If we are on OSX, we need to devine a number of aliases for GNU commands,
# as well as print the OSX software information
- if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then
sw_vers;
export HOMEBREW_NO_AUTO_UPDATE=1;
which gsort >/dev/null 2>&1 || brew install coreutils;
brew install gnu-sed --with-default-names;
export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH";
fi
# If we are on pypy, determine which is the latest version by using the
# bitbucket's API on pypy's repository
- if [[ "${PYTHON}" =~ ^pypy ]]; then
if [ "${PYTHON}" == "pypy" ]; then
PYTHON=pypy2;
fi;
PYTHON=$(
curl "https://api.bitbucket.org/2.0/repositories/pypy/pypy/refs/tags" 2>/dev/null |
grep -oE "release-${PYTHON}[a-zA-Z0-9._-]*" |
grep -- '-v' |
sed -e 's/^release-//g' -e 's/\-v/\-/g' |
sort -t'-' -k1,1Vr -k2,2Vr -u |
head -n1
);
if [ -z "${PYTHON}" ]; then
echo "ERROR - No PYPY version found.";
exit 1;
fi;
echo "PyPy version - $PYTHON";
fi
# If we are on OSX, or if we want to use pypy, we need to install the
# version of python we want. We are going to use pyenv for that, that will
# take care of downloading and compiling python as needed.
- if [[ "${TRAVIS_OS_NAME}" == "osx" ]] || [[ "${PYTHON}" =~ ^pypy ]]; then
set -x;
rm -rf ~/.pyenv;
if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then
export PYTHON_CONFIGURE_OPTS="--enable-framework";
else
export PYTHON_CONFIGURE_OPTS="--enable-shared";
fi;
git clone --depth 1 https://github.com/pyenv/pyenv ~/.pyenv;
PYENV_ROOT="$HOME/.pyenv";
PATH="$PYENV_ROOT/bin:$PATH";
eval "$(pyenv init -)";
pyenv install ${PYTHON} || exit 1;
pyenv global ${PYTHON} || exit 1;
pyenv rehash;
export PATH=$(python -c "import site, os; print(os.path.join(site.USER_BASE, 'bin'))"):$PATH;
python -m pip install --user pipenv==${PIPENV};
echo $PATH;
set +x;
else
pip install pipenv==${PIPENV};
fi
# Print Python version
- python --version; which python
- pipenv --version
# Install all dependencies
- echo $PATH; pipenv install --dev
# If the build should lead to a deployment, check that the tag is valid,
# else, check what the current version will be
- if [ -n "${TRAVIS_TAG}" ]; then
pipenv run ./version.py check-tag --tag=${TRAVIS_TAG} &&
environment=$(pipenv run ./version.py environment --version=${TRAVIS_TAG}) &&
eval "$environment";
else
environment=$(pipenv run ./version.py environment) &&
eval "$environment";
fi &&
printenv | grep '^TRAKT_VERSION' | sort
# Set the binary name
- TRAKT_HELPER_BIN=$(echo "TraktForVLC_${TRAKT_VERSION}_${TRAVIS_OS_NAME}" | sed -r 's/[^a-zA-Z0-9_.-]+/./g');
if [ -n "${BIN_SUFFIX}" ]; then
TRAKT_HELPER_BIN="${TRAKT_HELPER_BIN}_${BIN_SUFFIX}";
fi
# Install VLC
- if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then
brew cask install vlc;
else
sudo apt-get install -y vlc;
fi
# Print VLC version
- vlc --version
install:
# Set the version in the Python and LUA scripts
- pipenv run ./version.py set --version=${TRAKT_VERSION}
# Compile the Lua scripts
- vlc -I luaintf --lua-intf luac
--lua-config 'luac={input="trakt.lua",output="trakt.luac"}'
# Then prepare the binary file
- pipenv run pyinstaller
--onedir --onefile
--name=${TRAKT_HELPER_BIN}
--hidden-import=concurrent.futures
--add-data=trakt.luac:.
--console trakt_helper.py
# Test the binary by first checking if the --version command returns properly
- dist/${TRAKT_HELPER_BIN} --version
# Then print the help message
- dist/${TRAKT_HELPER_BIN} --help
script:
# Prepare the variables to know where to check for the installation
- if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then
CONFIG="${HOME}/Library/Application Support/org.videolan.vlc";
LUA_USER="${CONFIG}/lua";
LUA_SYSTEM="/Applications/VLC.app/Contents/MacOS/share/lua";
else
CONFIG="${HOME}/.config/vlc";
LUA_USER="${HOME}/.local/share/vlc/lua";
LUA_SYSTEM="$(python -c "import glob; print(
glob.glob('/usr/lib/*/vlc/lua') +
glob.glob('/usr/lib/vlc/lua'))[0]")";
fi
############################################################################
# TEST INSTALLATION LOCALLY
############################################################################
# Install with default parameters
- dist/${TRAKT_HELPER_BIN} --debug install --yes --no-init-trakt-auth
# Check that the helper has been installed
- ls -ls "${LUA_USER}/trakt_helper"
# And that the Lua interface is also installed
- ls -ls "${LUA_USER}/intf/trakt.luac"
# Run vlc to check that TraktForVLC is ready
- vlc >/tmp/vlc.out 2>&1 & sleep 5; kill $!
- sleep 5; cat /tmp/vlc.out
# Check that it found the helper
- |
helper=$(cat /tmp/vlc.out | perl -ne '
if ($_ =~ m/\[trakt\] lua interface: helper:/g) {
$_ =~ s/^.*\[trakt\] lua interface: helper: //g;
print;
}')
test "$helper" == "${LUA_USER}/trakt_helper"
if [ $? -ne 0 ]; then
echo "Helper is '${helper}' instead of '${LUA_USER}/trakt_helper'"
cat /tmp/vlc.out
false
else
echo "Helper '${helper}' was found"
fi
# And that it was requesting for Trakt.tv access
- |
test "$(cat /tmp/vlc.out |
perl -ne 'print "OK" if $_ =~ m/^\s*TraktForVLC is not setup/'
)" == "OK"
if [ $? -ne 0 ]; then
echo "TraktForVLC is NOT requesting for Trakt.tv access :("
false
else
echo "TraktForVLC is requesting for Trakt.tv access :)"
fi
# And that it did not fail before we stopped
- |
test "$(cat /tmp/vlc.out |
perl -ne 'print "NOK" if $_ =~ m/^\s*TraktForVLC setup failed/'
)" != "NOK"
if [ $? -ne 0 ]; then
echo "TraktForVLC failed (setup fail) before we stopped VLC :("
false
else
echo "TraktForVLC did not fail (setup fail) before we stopped VLC :)"
fi
# Test the update tool
- |
vlc --lua-config "trakt={check_update={file=\"$(pwd)/dist/${TRAKT_HELPER_BIN}\",wait=30,output=\"/tmp/update_output.log\"}}";
ls "/tmp/update_output.log";
cat "/tmp/update_output.log"
# Then uninstall
- "\"${LUA_USER}/trakt_helper\" --debug uninstall --yes"
# And check that the files are not there
- test \! -f "${LUA_USER}/trakt_helper"
- test \! -f "${LUA_USER}/intf/trakt.luac"
############################################################################
# IN BETWEEN CLEANING
############################################################################
- rm /tmp/vlc.out
############################################################################
# TEST INSTALLATION SYSTEM-WIDE
############################################################################
# Install with default parameters
- sudo dist/${TRAKT_HELPER_BIN} --debug install --yes --system --no-init-trakt-auth
# Check that the helper has been installed
- ls -ls "${LUA_SYSTEM}/trakt_helper"
# And that the Lua interface is also installed
- ls -ls "${LUA_SYSTEM}/intf/trakt.luac"
# Run vlc to check that TraktForVLC is ready
- vlc >/tmp/vlc.out 2>&1 & sleep 5; kill $!
- sleep 5; cat /tmp/vlc.out
# Check that it found the helper
- |
helper=$(cat /tmp/vlc.out | perl -ne '
if ($_ =~ m/\[trakt\] lua interface: helper:/g) {
$_ =~ s/^.*\[trakt\] lua interface: helper: //g;
print;
}')
test "$helper" == "${LUA_SYSTEM}/trakt_helper"
if [ $? -ne 0 ]; then
echo "Helper is '${helper}' instead of '${LUA_SYSTEM}/trakt_helper'"
false
else
echo "Helper '${helper}' was found"
fi
# And that it was requesting for Trakt.tv access
- |
test "$(cat /tmp/vlc.out |
perl -ne 'print "OK" if $_ =~ m/^\s*TraktForVLC is not setup/'
)" == "OK"
if [ $? -ne 0 ]; then
echo "TraktForVLC was NOT requesting for Trakt.tv access :("
false
else
echo "TraktForVLC was requesting for Trakt.tv access :)"
fi
# And that it did not fail before we stopped
- |
test "$(cat /tmp/vlc.out |
perl -ne 'print "NOK" if $_ =~ m/^\s*TraktForVLC setup failed/'
)" != "NOK"
if [ $? -ne 0 ]; then
echo "TraktForVLC failed (setup fail) before we stopped VLC :("
false
else
echo "TraktForVLC did not fail (setup fail) before we stopped VLC :)"
fi
# Then uninstall
- "sudo \"${LUA_SYSTEM}/trakt_helper\" --debug uninstall --yes --system"
# And check that the files are not there
- test \! -f "${LUA_SYSTEM}/trakt_helper"
- test \! -f "${LUA_SYSTEM}/intf/trakt.luac"
before_deploy:
- |
if [ -n "${TRAVIS_TAG}" ]; then
RELEASE_DRAFT=false;
if [ -z "${TRAKT_VERSION_PRE_TYPE}" ]; then
RELEASE_PRE=false;
else
RELEASE_PRE=true;
fi;
else
TRAKT_VERSION_NAME="${TRAVIS_BRANCH}-branch";
RELEASE_DRAFT=true;
RELEASE_PRE=false;
TRAKT_VERSION_DESCRIPTION="Draft of release for branch ${TRAVIS_BRANCH}. ${TRAKT_VERSION_DESCRIPTION}";
fi
- |
echo "RELEASE NAME: ${TRAKT_VERSION_NAME}"
echo "RELEASE DESCRIPTION: ${TRAKT_VERSION_DESCRIPTION}"
echo "IS PRE RELEASE ? ${RELEASE_PRE}"
echo "IS RELEASE DRAFT ? ${RELEASE_DRAFT}"
deploy:
# Need to duplicate the release as travis do not manage properly the
# conversion of 'true' and 'false' strings to booleans
- provider: releases
name: ${TRAKT_VERSION_NAME}
body: ${TRAKT_VERSION_DESCRIPTION}
api_key: ${GITHUB_TOKEN}
file: dist/${TRAKT_HELPER_BIN}
draft: false
prerelease: true
skip_cleanup: true
on:
condition: '-n "${TRAKT_VERSION_PRE_TYPE}"'
tags: true
- provider: releases
name: ${TRAKT_VERSION_NAME}
body: ${TRAKT_VERSION_DESCRIPTION}
api_key: ${GITHUB_TOKEN}
file: dist/${TRAKT_HELPER_BIN}
draft: false
prerelease: false
skip_cleanup: true
on:
condition: '-z "${TRAKT_VERSION_PRE_TYPE}"'
tags: true
after_success:
- if [ -z "${TRAVIS_TAG}" ] && [ "${TRAVIS_BRANCH}" == "master" ] && [ "${TRAVIS_PULL_REQUEST}" == "false" ]; then
CLEAR_PATTERN="TraktForVLC_*_${TRAVIS_OS_NAME}";
if [ -n "$BIN_SUFFIX" ]; then
CLEAR_PATTERN="${CLEAR_PATTERN}_${BIN_SUFFIX}";
fi;
pipenv install scikit-ci-addons &&
pipenv run ci_addons publish_github_release --prerelease-packages "dist/${TRAKT_HELPER_BIN}" --prerelease-packages-clear-pattern "${CLEAR_PATTERN}" --prerelease-packages-keep-pattern "${TRAKT_HELPER_BIN}" --prerelease-sha "${TRAVIS_BRANCH}" --re-upload "${TRAVIS_REPO_SLUG}";
fi