forked from ansible/ansible
-
Notifications
You must be signed in to change notification settings - Fork 3
/
.travis.yml
125 lines (117 loc) · 3.38 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
119
120
121
122
123
124
125
language: python
sudo: required
python:
- "2.7"
services:
- docker
env:
global:
- exit_code=0
- number_per_job=2
- message=()
- max_retry_count=2
matrix:
- id=1
- id=2
- id=3
- id=4
- id=5
- id=6
- id=7
- id=8
- id=9
- id=10
- id=11
- id=12
- id=13
- id=14
- id=15
- id=16
- id=17
- id=18
- id=19
- id=20
before_install:
- create_resource_group() {
name=$1;
name2=${name}2;
ansible-playbook ../create_resource_group.yml --extra-vars="name=$name name2=$name2";
}
- delete_resource_group() {
name=$1;
name2=${name}2;
ansible-playbook ../delete_resource_group.yml --extra-vars="name=$name name2=$name2";
}
- "write_credential() { printf \"AZURE_CLIENT_ID: ${AZURE_CLIENT_ID}\nAZURE_SECRET: ${AZURE_SECRET}\nAZURE_SUBSCRIPTION_ID: ${AZURE_SUBSCRIPTION_ID}\nAZURE_TENANT: ${AZURE_TENANT}\nRESOURCE_GROUP: $group_name\nRESOURCE_GROUP_SECONDARY: $group_name_secondary\" >> test/integration/cloud-config-azure.yml; }"
- run_test() {
test_name=$1;
group_name="asb-it-${test_name##azure_rm_}";
group_name_secondary="${group_name}2";
loop=1;
while [ $loop -le $max_retry_count ]; do
echo Run test $test_name $loop time;
create_resource_group $group_name;
rm test/integration/cloud-config-azure.yml 2>/dev/null;
touch test/integration/cloud-config-azure.yml;
write_credential;
travis_wait 50 ansible-test integration $test_name --docker --color=yes;
if [ $? -ne 0 ]; then
echo test $test_name failed at $loop time run;
if [ $loop -eq $max_retry_count ]; then
message+=($test_name);
export exit_code=1;
fi;
loop=$[$loop+1];
else
echo test $test_name passed at $loop time run;
travis_wait 50 delete_resource_group $group_name;
break;
fi;
done;
travis_wait 50 delete_resource_group $group_name;
}
- scan_test() {
end=$((id * number_per_job));
start=$((end - number_per_job));
liststr=test/integration/targets/azure_rm_*;
list=($liststr);
echo start = $start, end = $end, list_lenth = ${#list[@]};
for (( i = $start; i < $end; i++ )); do
if [ "$i" -lt "${#list[@]}" ]; then
file=${list[$i]};
name=${file##test/integration/targets/};
run_test $name;
fi
done
}
install:
- sudo apt-get update
- sudo apt-get install -y libssl-dev libffi-dev python-dev python-pip
- mkdir ~/.azure
- touch ~/.azure/credentials
- printf "[default]\nsubscription_id=${AZURE_SUBSCRIPTION_ID}\nclient_id=${AZURE_CLIENT_ID}\nsecret=${AZURE_SECRET}\ntenant=${AZURE_TENANT}" >> ~/.azure/credentials
- git clone https://github.com/VSChina/ansible.git
- cd ansible
- pip install virtualenv
- virtualenv venv
- . venv/bin/activate
- pip install .
- pip install -r requirements.txt
- pip install -r packaging/requirements/requirements-azure.txt
- . hacking/env-setup
- pip freeze
- ansible --version
script:
- docker --version
- scan_test
- (>&2 echo $message)
- exit $exit_code
notifications:
email:
recipients:
- yuwzho@microsoft.com
- zikalino@microsoft.com
- yungez@microsoft.com
- yaweiw@microsoft.com
on_success: always
on_failure: always