forked from aliyun/alibabacloud-oss-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ut.sh
125 lines (109 loc) · 2.7 KB
/
ut.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
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
#!/bin/bash
function upload_codecov_report {
# upload_codecov_report <dir> <flag>
cd "$1" || return 126
wget --no-check-certificate https://codecov.io/bash -O codecov.sh
pwd
bash codecov.sh -cF "$2"
return $?
}
function run_php {
cd util/php/ || return 126
composer --version
composer install --dev || return 126
composer test || return 126
cd ../../
upload_codecov_report php php
}
function run_go {
cd util/golang/ || return 126
export GO111MODULE=on
go mod tidy || return 126
go test -race -coverprofile=coverage.txt -covermode=atomic ./service/... || return 126
cd ../../
upload_codecov_report golang go
}
function run_csharp {
# before_install
wget https://download.visualstudio.microsoft.com/download/pr/42f39f2f-3f24-4340-8c57-0a3133620c21/0a353696275b00cbddc9f60069867cfc/dotnet-sdk-2.2.110-linux-x64.tar.gz
mkdir -p ~/dotnet/ && tar zxf dotnet-sdk-2.2.110-linux-x64.tar.gz -C ~/dotnet/
sudo ln -sf ~/dotnet/dotnet /usr/bin/dotnet
dotnet --info
# install
cd util/csharp/tests/ || return 126
dotnet tool install --global altcover.visualizer
dotnet restore || return 126
dotnet build || return 126
cd ../
# run tests
dotnet test tests/ /p:AltCover=true || return 126
cd ../../
# upload code coverage report
upload_codecov_report csharp csharp
}
function run_java {
cd util/java/ || return 126
mvn test -B || return 126
cd ../../
upload_codecov_report java java
}
function run_ts {
cd util/ts/ || return 126
npm install || return 126
npm run test-cov || return 126
cd ../../
upload_codecov_report ts node_js
}
function run_python {
export PYTHONPATH=$PYTHONPATH:`pwd`/util/python
echo $PYTHONPATH
# install
cd util/python || return 126
pip install coverage || return 126
pip install alibabacloud-tea
coverage run --source="./alibabacloud_oss_util" -m pytest tests/test_* || return 126
cd ../../
upload_codecov_report util/python python
}
function run_python2 {
export PYTHONPATH=$PYTHONPATH:`pwd`/util/python2
echo $PYTHONPATH
# install
cd util/python2 || return 126
pip install coverage || return 126
pip install alibabacloud-tea-py2
coverage run --source="./alibabacloud_oss_util" -m pytest tests/ || return 126
cd ../../
upload_codecov_report util/python2 python2
}
lang=$1
if [ "$lang" == "php" ]
then
echo "run php"
run_php
elif [ "$lang" == "go" ]
then
echo "run golang"
run_go
elif [ "$lang" == "csharp" ]
then
echo "run csharp"
run_csharp
elif [ "$lang" == "java" ]
then
echo "run java"
run_java
elif [ "$lang" == "ts" ]
then
echo "run ts"
run_ts
elif [ "$lang" == "python" ]
then
echo "run python"
run_python
elif [ "$lang" == "python2" ]
then
echo "run python2"
run_python2
fi
exit $?