This repository has been archived by the owner on Nov 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 348
/
.travis.yml
108 lines (91 loc) · 3.28 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
language: python
python: '2.7'
env:
global:
- exit_code=0
- number_per_job=2
- message=()
- ANSIBLE_VERSION=latest
- ANSIBLE_CONFIG=/home/travis/.ansible/ansible.cfg
#- ANSIBLE_VERSION=2.4.2.0
matrix:
- id=1
- id=2
- id=3
- id=4
- id=5
- id=6
before_install:
- sudo apt-get update -qq
- run_test(){
file=$1;
test_name=${file##./};
test_name=${test_name%%.yml};
delete_resource_group=${2:-true};
resource_group=${3:-sampletest$(date +%s)};
echo Run playbook $file;
travis_wait 50 ansible-playbook $file --extra-vars "{\"azure_subscription_id\":$AZURE_SUBSCRIPTION_ID,\"azure_tenant\":$AZURE_TENANT,\"azure_client_id\":$AZURE_CLIENT_ID,\"resource_group_name\":$resource_group}";
if [ $? -ne 0 ]; then
echo test $file failed;
message+=($file);
export exit_code=1;
fi;
if [ "$delete_resource_group" == true ]; then
travis_wait 50 ansible-playbook ./__helpers/__delete_test_resource_group.yml --extra-vars "{\"azure_subscription_id\":$AZURE_SUBSCRIPTION_ID,\"azure_tenant\":$AZURE_TENANT,\"azure_client_id\":$AZURE_CLIENT_ID,\"resource_group_name\":$resource_group}";
fi;
}
- scan_test() {
end=$((id * number_per_job));
start=$((end - number_per_job));
branch=$TRAVIS_BRANCH;
echo branch is $branch;
git pull;
diffstr=$(git diff $branch remotes/origin/master --name-only -- '*.yml' --no-pager);
changedfiles=($diffstr);
excludedList="vm_create_existingvnet_deployjavaapp.yml .travis.yml aks_create_scale.yml webapp.yml rest/sql-managed-instance.yml vm_create_image.yml";
echo start = $start, end = $end, list_lenth = ${#changedfiles[@]};
for (( i = $start; i < $end; i++ )); do
echo file is ${#changedfiles[$i]};
if [ "$i" -lt "${#changedfiles[@]}" ]; then
excluded=false;
for item in ${excludedList[*]}; do
if [ "${changedfiles[$i]}" == "$item" ]; then
excluded=true;
break;
fi
done;
if [ "$excluded" == false ]; then
run_test ${changedfiles[$i]};
fi
fi
done;
}
install:
- sudo apt-get install -y git
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
- sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
- sudo apt-get update
- apt-cache policy docker-ce
- sudo apt-get install -y docker-ce
- sudo usermod -aG docker ${USER}
- sudo apt-get install -y default-jdk
- sudo apt-get install -y maven sshpass
- if [ "$ANSIBLE_VERSION" = "latest" ]; then pip install ansible[azure]; else pip
install ansible[azure]==$ANSIBLE_VERSION; fi
- ansible --version
- ansible-galaxy install azure.azure_preview_modules
- pip install -I -r ~/.ansible/roles/azure.azure_preview_modules/files/requirements-azure.txt
- pip install docker
- pip freeze
- cp -f ./vmss/ansible.cfg /home/travis/.ansible
- git clone https://github.com/Azure-Samples/ansible-playbooks.git
- cd ansible-playbooks
- git checkout $TRAVIS_BRANCH
script:
- scan_test
- exit $exit_code
notifications:
email: