-
Notifications
You must be signed in to change notification settings - Fork 4
/
.gitlab-ci.yml
153 lines (132 loc) · 2.85 KB
/
.gitlab-ci.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
variables:
DEPLOY_OWNER_PRIVKEY: 0xBF3862CD1EE53F542C483E4F55BEE2D0B13014A7D6AD1B0CA457240C2888C1FB
image: node:14-buster
stages:
- build
- test
- analysis
- deploy
default:
tags:
- docker
cache:
key: ${CI_PROJECT_PATH_SLUG}
paths:
- node_modules/
- artifacts/
- cache/
before_script:
- npm install
build:
stage: build
script:
- npm run build
- npm run check
.test_job: &test_job
stage: test
script:
- apt-get update && apt-get install -y netcat
- RUNNER_COUNT=12
- FILES=( $(find -H -L ./test/* -regex "^.*.test.js") )
- len=${#FILES[@]}
- >
for (( i=0; i<${RUNNER_COUNT}; i+=1 )); do
RUNNER_TEST_CNTS[$i]=0
done
- >
for (( i=0; i<${len}; i+=1 )); do
TestCases[$i]=$(grep -o " it" ${FILES[$i]} | wc -l)
done
- >
for ((i = 0; i<${len}; i++))
do
for((j = 0; j<${len}-i-1; j++))
do
if [ ${TestCases[j]} -lt ${TestCases[$((j+1))]} ]
then
# swap
temp=${TestCases[j]}
TestCases[$j]=${TestCases[$((j+1))]}
TestCases[$((j+1))]=$temp
temp=${FILES[j]}
FILES[$j]=${FILES[$((j+1))]}
FILES[$((j+1))]=$temp
fi
done
done
- MIN=${RUNNER_TEST_CNTS[0]}
- MINIDX=0
- >
for (( i=0; i<${len}; i+=1 )); do
for j in ${!RUNNER_TEST_CNTS[@]};
do
if [ ${MIN} -gt ${RUNNER_TEST_CNTS[$j]} ]
then
MIN=${RUNNER_TEST_CNTS[${j}]}
MINIDX=${j}
fi
done
UNITTEST_FILES[$MINIDX]+=' '"${FILES[$i]}"
RUNNER_TEST_CNTS[$MINIDX]=`expr ${TestCases[$i]} + ${RUNNER_TEST_CNTS[$MINIDX]}`
MIN=${RUNNER_TEST_CNTS[$MINIDX]}
done
- npm run test ${UNITTEST_FILES[${JOB_INDEX}]}
test_0:
variables:
JOB_INDEX: 0
<<: *test_job
test_1:
variables:
JOB_INDEX: 1
<<: *test_job
test_2:
variables:
JOB_INDEX: 2
<<: *test_job
test_3:
variables:
JOB_INDEX: 3
<<: *test_job
test_4:
variables:
JOB_INDEX: 4
<<: *test_job
test_5:
variables:
JOB_INDEX: 5
<<: *test_job
test_6:
variables:
JOB_INDEX: 6
<<: *test_job
test_7:
variables:
JOB_INDEX: 7
<<: *test_job
test_8:
variables:
JOB_INDEX: 8
<<: *test_job
test_9:
variables:
JOB_INDEX: 9
<<: *test_job
test_10:
variables:
JOB_INDEX: 10
<<: *test_job
test_11:
variables:
JOB_INDEX: 11
<<: *test_job
analysis_slither:
stage: analysis
script:
- apt-get update && apt-get install -y python3-pip
- pip3 install slither-analyzer && pip3 install solc-select
- npm run analysis
deploy:
stage: deploy
script:
- apt-get update && apt-get install -y netcat
- npm run deploy