-
Notifications
You must be signed in to change notification settings - Fork 1
/
.travis.yml
86 lines (72 loc) · 4.1 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
language: node_js
node_js:
- '16'
services:
- docker
cache:
directories:
- node_modules
env:
- TEST_ENV=eon
- TEST_ENV=gobi
- TEST_ENV=pregobi
before_install:
- git submodule add --force https://github.com/ethereum/execution-apis.git
- git submodule update --init
- docker build -t rpc-tests .
install:
- npm install
script:
# Test Commands
- >
if [ "$TEST_ENV" = "local" ]; then
TEST_OUTPUT=$(docker run -e SEND_FROM_PK=$SEND_FROM_PK -e SEND_FROM_PK2=$SEND_FROM_PK2 -e SEND_FROM_PK2=$SEND_FROM_PK2 -e RPC_USERNAME=$RPC_USERNAME -e RPC_PASSWORD=$RPC_PASSWORD -v $(pwd):/usr/src/app -v $(pwd)/reports:/usr/src/app/reports rpc-tests npm run test-local 2>&1);
fi
- >
if [ "$TEST_ENV" = "pregobi" ]; then
TEST_OUTPUT=$(docker run -e SEND_FROM_PK=$SEND_FROM_PK -e SEND_FROM_PK2=$SEND_FROM_PK2 -e SEND_FROM_PK2=$SEND_FROM_PK2 -e RPC_USERNAME=$RPC_USERNAME -e RPC_PASSWORD=$RPC_PASSWORD -e RPC_URL=$RPC_URL_PRE_GOBI -v $(pwd):/usr/src/app -v $(pwd)/reports:/usr/src/app/reports rpc-tests npm run test-pregobi 2>&1);
fi
- >
if [ "$TEST_ENV" = "gobi" ]; then
TEST_OUTPUT=$(docker run -e SEND_FROM_PK=$SEND_FROM_PK -e SEND_FROM_PK2=$SEND_FROM_PK2 -e SEND_FROM_PK2=$SEND_FROM_PK2 -e RPC_USERNAME=$RPC_USERNAME -e RPC_PASSWORD=$RPC_PASSWORD -v $(pwd):/usr/src/app -v $(pwd)/reports:/usr/src/app/reports rpc-tests npm run test-gobi 2>&1);
fi
- >
if [ "$TEST_ENV" = "eon" ]; then
TEST_OUTPUT=$(docker run -e SEND_FROM_PK2=$SEND_FROM_PK2 -e SEND_FROM_PK2=$SEND_FROM_PK2 -e RPC_USERNAME=$EON_RPC_USERNAME -e RPC_PASSWORD=$EON_RPC_PASSWORD -v $(pwd):/usr/src/app -v $(pwd)/reports:/usr/src/app/reports rpc-tests npm run test-eon 2>&1);
fi
- echo "$TEST_OUTPUT";
# Extract Test Suites data
- failed_suites=$(echo "$TEST_OUTPUT" | awk -F' ' '/Test Suites:/ { for(i=1; i<=NF; i++) if($i ~ /failed/) print $(i-1)}')
- passed_suites=$(echo "$TEST_OUTPUT" | awk -F' ' '/Test Suites:/ { for(i=1; i<=NF; i++) if($i ~ /passed/) print $(i-1)}')
- total_suites=$(echo "$TEST_OUTPUT" | awk -F' ' '/Test Suites:/ { for(i=1; i<=NF; i++) if($i ~ /total/) print $(i-1)}')
# Extract Tests data
- failed_tests=$(echo "$TEST_OUTPUT" | awk -F' ' '/Tests:/ { for(i=1; i<=NF; i++) if($i ~ /failed/) print $(i-1)}')
- passed_tests=$(echo "$TEST_OUTPUT" | awk -F' ' '/Tests:/ { for(i=1; i<=NF; i++) if($i ~ /passed/) print $(i-1)}')
- total_tests=$(echo "$TEST_OUTPUT" | awk -F' ' '/Tests:/ { for(i=1; i<=NF; i++) if($i ~ /total/) print $(i-1)}')
# Extract Time data
- total_time=$(echo "$TEST_OUTPUT" | awk -F'Time:' '{print $2}' | tr -d '[:space:]')
# Default to 0 if values are empty
- "[ -z \"$failed_suites\" ] && failed_suites=0 || true"
- "[ -z \"$passed_suites\" ] && passed_suites=0 || true"
- "[ -z \"$failed_tests\" ] && failed_tests=0 || true"
- "[ -z \"$passed_tests\" ] && passed_tests=0 || true"
- "[ -z \"$total_tests\" ] && total_tests=0 || true"
- "[ -z \"$total_time\" ] && total_time=0 || true"
# Determine test outcome and symbols to send to slack
- >
if [ "$failed_tests" = "0" ]; then
test_outcome=":large_green_circle: ALL TESTS PASSED :large_green_circle: "
passed_tests_symbol=":large_green_circle: "
elif [ "$passed_tests" = "0" ]; then
test_outcome=":red_circle: ALL TESTS FAILED :red_circle: "
failed_tests_symbol=":red_circle: "
else
test_outcome=":red_circle: TESTS FAILED :red_circle: "
passed_tests_symbol=":large_green_circle: "
failed_tests_symbol=":red_circle: "
fi
# Send data to Slack
- >
curl -X POST -H 'Content-type: application/json'
--data "{\"failed_suites\": \"$failed_suites\", \"passed_suites\": \"$passed_suites\", \"total_suites\": \"$total_suites\", \"failed_tests\": \"$failed_tests\", \"passed_tests\": \"$passed_tests\", \"total_tests\": \"$total_tests\", \"total_time\": \"$total_time\", \"build_url\": \"$TRAVIS_BUILD_WEB_URL\", \"branch\": \"$TRAVIS_BRANCH\", \"test_outcome\": \"$test_outcome\", \"passed_tests_symbol\": \"$passed_tests_symbol\", \"failed_tests_symbol\": \"$failed_tests_symbol\", \"environment\": \"$TEST_ENV\"}"
$SLACK_WEBHOOK_URL