forked from Kocal/vue-web-extension
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.travis.yml
118 lines (102 loc) · 3.9 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
dist: trusty
language: node_js
cache:
yarn: true
directories:
- node_modules
- examples/full/node_modules
- examples/full-airbnb/node_modules
- examples/minimal/node_modules
node_js:
- "10"
- "12"
- "node"
env:
- VUE_TEMPLATES="minimal full full-airbnb"
before_install:
- git remote set-branches --add origin master
- git fetch
# Yarn
- npm i -g yarn vue-cli
# Utils
- |
# Setup Symfony bash utils
stty cols 120
nanoseconds() {
local cmd="date"
local format="+%s%N"
local os=$(uname)
if hash gdate > /dev/null 2>&1; then
cmd="gdate"
elif [[ "$os" = Darwin ]]; then
format="+%s000000000"
fi
$cmd -u $format
}
export -f nanoseconds
# tfold is a helper to create folded reports
tfold () {
local title="\\e[1;33m[$VUE_TEMPLATE]\\e[0m $1"
local fold=$(echo $title | sed -r 's/[^-_A-Za-z0-9]+/./g')
shift
local id=$(printf %08x $(( RANDOM * RANDOM )))
local start=$(nanoseconds)
echo -e "travis_fold:start:$fold"
echo -e "travis_time:start:$id"
echo -e "\\e[1;34m$title\\e[0m"
bash -xc "$*" 2>&1
local ok=$?
local end=$(nanoseconds)
echo -e "\\ntravis_time:end:$id:start=$start,finish=$end,duration=$(($end-$start))"
(exit $ok) &&
echo -e "\\e[32mOK\\e[0m $title\\n\\ntravis_fold:end:$fold" ||
echo -e "\\e[41mKO\\e[0m $title\\n"
(exit $ok)
}
export -f tfold
- |
# Setup jsdoc-vuejs bash utils
test_extension () {
set -e
tfold "Working inside \\e[1;33m$PWD\\e[0m folder..." echo $PWD
tfold "Installing extension dependencies..." yarn install --frozen-lockfile
tfold "Building extension..." yarn build
tfold "Testing version behavior..." $TRAVIS_BUILD_DIR/tests/test_version.sh
if [[ "$VUE_TEMPLATE" =~ ^full ]]; then tfold "Linting..." yarn lint --fix; fi
if [[ "$VUE_TEMPLATE" =~ ^full ]]; then tfold "Prettying..." yarn prettier:write; fi
if [[ "$VUE_TEMPLATE" =~ ^full ]]; then tfold "Testing Web extension polyfill..." $TRAVIS_BUILD_DIR/tests/test_web_extension_polyfill.sh; fi
if [[ "$VUE_TEMPLATE" =~ ^full ]]; then tfold "Testing options..." $TRAVIS_BUILD_DIR/tests/test_options.sh; fi
if [[ "$VUE_TEMPLATE" =~ ^full ]]; then tfold "Testing axios..." $TRAVIS_BUILD_DIR/tests/test_axios.sh; fi
if [[ "$VUE_TEMPLATE" =~ ^full ]]; then tfold "Testing vue-router..." $TRAVIS_BUILD_DIR/tests/test_router.sh; fi
if [[ "$VUE_TEMPLATE" =~ ^full ]]; then tfold "Testing vuex..." $TRAVIS_BUILD_DIR/tests/test_store.sh; fi
}
export -f test_extension
create_extension () {
set -e
export VUE_TEMPLATE=$1
cd $TRAVIS_BUILD_DIR/tests
tfold "Creating extension following $VUE_TEMPLATE scenario..." vue init .. extension-$VUE_TEMPLATE &&
cd $TRAVIS_BUILD_DIR/tests/extension-$VUE_TEMPLATE
test_extension
}
export -f create_extension
install:
- yarn install --frozen-lockfile
script:
- |
if [[ "${TRAVIS_PULL_REQUEST_BRANCH}" =~ ^dependabot ]]; then
echo -e "\\e[1;34mDependabot PR detected.\\e[0m"
export VUE_TEMPLATE=$(git --no-pager diff --name-only origin/master | grep "examples" | tail -n 1 | cut -d "/" -f 2)
if [[ "${VUE_TEMPLATES}" = *"$VUE_TEMPLATE"* ]]; then
echo -e "\\e[1;34mRunning tests for \"$VUE_TEMPLATE\" example...\\e[0m"
cd $TRAVIS_BUILD_DIR/examples/$VUE_TEMPLATE
test_extension
else
echo -e "\\e[1;34mRunning tests for global project...\\e[0m"
exit 0 # Actually there is nothing to tests :shrug:
fi
exit $?
else
for VUE_TEMPLATE in $VUE_TEMPLATES; do create_extension $VUE_TEMPLATE; done;
exit $?
fi