This repository has been archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy path.travis.yml
140 lines (140 loc) · 5.41 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
language: python
python:
- "3.7"
stage:
- unit-test
- docker-build-push
services:
- docker
before_install:
- python -m pip install --upgrade pip
- COMMIT_RANGE="$(echo ${TRAVIS_COMMIT_RANGE} | cut -d '.' -f 1,4 --output-delimiter '..')"
- CHANGED_FILES="$(git diff --name-only ${COMMIT_RANGE} --)"
- export CHANGED_FILES
- SHORT_SHAR=$(git rev-parse --short HEAD)
- TAGS="github-${SHORT_SHAR}"
- echo $TAGS
install:
- pip install -r tests/requirements.txt
jobs:
include:
- stage: unit-test
name: "unittest vsan-prometheus-setup"
env: PYTHONPATH="${PYTHONPATH}:/vsan-prometheus-setup"
script:
- |
if [[ $CHANGED_FILES =~ "vsan-prometheus-setup" ]]
then
echo "Run unittest for vsan-prometheus-setup" && python tests/test_token_setup.py
if [ $? -eq 0 ]
then
echo "vsan-prometheus-setup test success"
else
echo "vsan-prometheus-setup test fails"
exit 1
fi
else
echo "won't trigger vsan-prometheus-setup test"
fi
-
name: "unittest vsan-prometheus-servicediscovery"
env: PYTHONPATH="${PYTHONPATH}:/vsan-prometheus-servicediscovery"
script:
- |
if [[ $CHANGED_FILES =~ "vsan-prometheus-servicediscovery" ]]
then
echo "Run unittest for vsan-prometheus-servicediscovery" && python tests/test_vsan_servicediscovery.py
if [ $? -eq 0 ]
then
echo "test_vsan_servicediscovery test success"
else
echo "test_vsan_servicediscovery test fails"
exit 1
fi
else
echo "won't trigger test_vsan_servicediscovery test"
fi
- stage: docker-build-push
name: "vsan-prometheus-setup image building and publish"
script:
- |
if [[ $CHANGED_FILES =~ "vsan-prometheus-setup" ]]
then
echo "Run vsan-prometheus-setup image building"
docker build -t vmware/vsan-prometheus-setup:$TAGS vsan-prometheus-setup
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
echo "Run vsan-prometheus-setup image publish"
docker push vmware/vsan-prometheus-setup:$TAGS
if [ $? -eq 0 ]
then
echo "vsan-prometheus-setup image building & publishing success"
else
echo "vsan-prometheus-setup image building & publishing fails"
exit 1
fi
else
echo "won't trigger vsan-prometheus-setup image building & publishing"
fi
-
name: "vsan-prometheus-servicediscovery image building and publish"
script:
- |
if [[ $CHANGED_FILES =~ "vsan-prometheus-servicediscovery" ]]
then
echo "Run vsan-prometheus-servicediscovery image building"
docker build -t vmware/vsan-prometheus-servicediscovery:$TAGS vsan-prometheus-servicediscovery
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
echo "Run vsan-prometheus-servicediscovery image publish"
docker push vmware/vsan-prometheus-servicediscovery:$TAGS
if [ $? -eq 0 ]
then
echo "vsan-prometheus-servicediscovery image building & publishing success"
else
echo "vsan-prometheus-servicediscovery image building & publishing fails"
exit 1
fi
else
echo "won't trigger vsan-prometheus-servicediscovery image building & publishing"
fi
-
name: "vsan-prometheus-operator image building and publish"
script:
- |
if [[ $CHANGED_FILES =~ "vsan-prometheus-operator" ]]
then
echo "Run vsan-prometheus-operator image building"
docker build -t vmware/vsan-prometheus-operator:$TAGS vsan-prometheus-operator
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
echo "Run vsan-prometheus-operator image publish"
docker push vmware/vsan-prometheus-operator:$TAGS
if [ $? -eq 0 ]
then
echo "vsan-prometheus-operator image building & publishing success"
else
echo "vsan-prometheus-operator image building & publishing fails"
exit 1
fi
else
echo "won't trigger vsan-prometheus-operator image building & publishing"
fi
-
name: "vsan-prometheus-exporter image building and publish"
script:
- |
if [[ $CHANGED_FILES =~ "vsan-prometheus-exporter" ]]
then
echo "Run vsan-prometheus-exporter image building"
docker build -t vmware/vsan-prometheus-exporter:$TAGS vsan-prometheus-exporter
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
echo "Run vsan-prometheus-exporter image publish"
docker push vmware/vsan-prometheus-exporter:$TAGS
if [ $? -eq 0 ]
then
echo "vsan-prometheus-exporter image building & publishing success"
else
echo "vsan-prometheus-exporter image building & publishing fails"
exit 1
fi
else
echo "won't trigger vsan-prometheus-exporter image building & publishing"
fi