forked from video-dev/hls.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
travis.sh
executable file
·60 lines (57 loc) · 1.6 KB
/
travis.sh
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
#!/bin/bash
# https://docs.travis-ci.com/user/customizing-the-build/#Implementing-Complex-Build-Steps
set -ev
function testNodeRequire {
# check that hls.js doesn't error if requiring in node
# see https://github.com/video-dev/hls.js/pull/1642
node -e 'require("./" + require("./package.json").main)'
}
npm install
if [ "${TRAVIS_MODE}" = "build" ]; then
npm run lint
npm run build
testNodeRequire
elif [ "${TRAVIS_MODE}" = "unitTests" ]; then
npm run test:unit
elif [ "${TRAVIS_MODE}" = "funcTests" ]; then
npm run build
n=0
maxRetries=1
until [ $n -ge ${maxRetries} ]
do
if [ $n -gt 0 ]; then
echo "Retrying... Attempt: $((n+1))"
delay=$((n*60))
echo "Waiting ${delay} seconds..."
sleep $delay
fi
npm run test:func && break
n=$[$n+1]
done
if [ ${n} = ${maxRetries} ]; then
exit 1
fi
elif [ "${TRAVIS_MODE}" = "releaseCanary" ]; then
# update the version
# make sure everything is fetched https://github.com/travis-ci/travis-ci/issues/3412
git fetch --unshallow
node ./scripts/set-canary-version.js
if [[ $(node ./scripts/check-already-published.js) = "not published" ]]; then
npm run lint
npm run build
testNodeRequire
npm run test:unit
# write the token to config
# see https://docs.npmjs.com/private-modules/ci-server-config
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" >> .npmrc
npm publish --tag canary
echo "Published canary."
curl https://purge.jsdelivr.net/npm/hls.js@canary
echo "Cleared jsdelivr cache."
else
echo "Canary already published."
fi
else
echo "Unknown travis mode: ${TRAVIS_MODE}" 1>&2
exit 1
fi