-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy path.gitlab-ci.yml
109 lines (98 loc) · 2.67 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
include:
- 'templates/.gitlab-ci-eth.yml'
- 'templates/.gitlab-ci-optimism.yml'
- 'templates/.gitlab-ci-polygon.yml'
- 'templates/.gitlab-ci-fantom.yml'
- 'templates/.gitlab-ci-metis.yml'
- 'templates/.gitlab-ci-arbitrum.yml'
- 'templates/.gitlab-ci-avalanche.yml'
image: node:16.18.0-buster
default:
tags:
- docker
before_script:
- npm install
stages:
- build
- test
- fuzzing
- analysis
- deploy
.test_template:
stage: test
script:
- apt-get update && apt-get install -y netcat
- 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
- RPC_URL=${RPC_URL} CHAIN_ID=${CHAIN_ID} npm run test ${UNITTEST_FILES[${JOB_INDEX}]}
build:
stage: build
script:
- npm run build
test_fuzzing:
image: ghcr.io/foundry-rs/foundry:nightly-63ed1099a74fded7c3a7182b5a508bd7d16743d3
stage: fuzzing
before_script:
- apk add --update nodejs npm
- npm install
script:
- npm run fuzzing
# Analysis
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
analysis_slither_diff:
stage: analysis
script:
- apt-get update && apt-get install -y python3-pip
- pip3 install slither-analyzer && pip3 install solc-select
- apt-get install git
- npm run slither_diff
deploy:
stage: deploy
script:
- npm run deploy