forked from jr-robotics/robo-gym
-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
246 lines (223 loc) · 6.15 KB
/
.gitlab-ci.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
stages:
- build
- test
- deploy
variables:
PYTHON_VER: "3.6"
ROS_DISTRO: "melodic"
ROBO_GYM_IMAGE: $CI_REGISTRY_IMAGE:$PYTHON_VER-$CI_COMMIT_SHA
ROBOT_SERVERS_IMAGE: "$CI_REGISTRY/robo-gym/robot-servers:$ROS_DISTRO-develop-latest"
before_script:
# docker login asks for the password to be passed through stdin for security
# we use $CI_JOB_TOKEN here which is a special token provided by GitLab
- echo -n $CI_JOB_TOKEN | docker login -u gitlab-ci-token --password-stdin $CI_REGISTRY
# The pipeline needs at minimum one job to run
dummy:
stage: build
variables:
GIT_STRATEGY: none
script:
- ":"
only:
- /^docs.*$/
.build_robo-gym_image: &build_robo-gym_image_def
image: docker:18.09
services:
- docker:18.09-dind
tags:
- docker-executor
stage: build
retry:
max: 2
script:
# fetch the latest image (not failing if image is not found)
- docker pull $CI_REGISTRY_IMAGE:$PYTHON_VER-latest || true
- >
docker build
--pull
--cache-from $CI_REGISTRY_IMAGE:$PYTHON_VER-latest
--tag $ROBO_GYM_IMAGE
--build-arg PYTHON_VER=$PYTHON_VER
--build-arg CACHEBUST=$CI_COMMIT_SHA
.
- docker push $ROBO_GYM_IMAGE
- docker tag $ROBO_GYM_IMAGE $CI_REGISTRY_IMAGE:$PYTHON_VER-latest
- docker push $CI_REGISTRY_IMAGE:$PYTHON_VER-latest
except:
- /^docs.*$/
build_robo-gym_image_py36:
<<: *build_robo-gym_image_def
build_robo-gym_image_py37:
<<: *build_robo-gym_image_def
variables:
PYTHON_VER: "3.7"
only:
- schedules
build_robo-gym_image_py38:
<<: *build_robo-gym_image_def
variables:
PYTHON_VER: "3.8"
only:
- schedules
build_robo-gym_image_py39:
<<: *build_robo-gym_image_def
variables:
PYTHON_VER: "3.9"
only:
- schedules
.short_test_environments: &short_test_environments_def
image: docker:18.09
before_script:
- apk add docker-compose
services:
- docker:18.09-dind
tags:
- docker-executor
stage: test
script:
- echo "Python Version:$PYTHON_VER Robot Servers image:$ROBOT_SERVERS_IMAGE"
- echo -n $CI_JOB_TOKEN | docker login -u gitlab-ci-token --password-stdin $CI_REGISTRY
- docker pull $ROBO_GYM_IMAGE
- docker tag $ROBO_GYM_IMAGE robo-gym
- docker pull $ROBOT_SERVERS_IMAGE
- docker tag $ROBOT_SERVERS_IMAGE robot-servers
- docker-compose -f docker-compose-test-melodic.yml up -d
- docker exec robo-gym pytest -m "not nightly"
- docker-compose -f docker-compose-test-melodic.yml down
except:
- /^docs.*$/
short_test_environments_py36:
<<: *short_test_environments_def
except:
- schedules
- /^docs.*$/
needs: ["build_robo-gym_image_py36"]
short_test_environments_py37:
<<: *short_test_environments_def
variables:
PYTHON_VER: "3.7"
only:
- schedules
needs: ["build_robo-gym_image_py37"]
short_test_environments_py38:
<<: *short_test_environments_def
variables:
PYTHON_VER: "3.7"
only:
- schedules
needs: ["build_robo-gym_image_py38"]
short_test_environments_py39:
<<: *short_test_environments_def
variables:
PYTHON_VER: "3.7"
only:
- schedules
needs: ["build_robo-gym_image_py39"]
short_test_environments_with_rs_manual_deploy:
<<: *short_test_environments_def
variables:
ROBOT_SERVERS_IMAGE: "$CI_REGISTRY/robo-gym/robot-servers:$ROS_DISTRO-manual_deploy-latest"
when: manual
.full_test_environments: &full_test_environments_def
image: docker:18.09
before_script:
- apk add docker-compose
services:
- docker:18.09-dind
tags:
- docker-executor
stage: test
script:
- echo "Python Version:$PYTHON_VER Robot Servers image:$ROBOT_SERVERS_IMAGE"
- echo -n $CI_JOB_TOKEN | docker login -u gitlab-ci-token --password-stdin $CI_REGISTRY
- docker pull $ROBO_GYM_IMAGE
- docker tag $ROBO_GYM_IMAGE robo-gym
- docker pull $ROBOT_SERVERS_IMAGE
- docker tag $ROBOT_SERVERS_IMAGE robot-servers
- docker-compose -f docker-compose-test-melodic.yml up -d
- docker exec robo-gym pytest -x
- docker-compose -f docker-compose-test-melodic.yml down
except:
- /^docs.*$/
manual_full_test_environments_py36:
<<: *full_test_environments_def
when: manual
needs: ["build_robo-gym_image_py36"]
full_test_environments_py36:
<<: *full_test_environments_def
only:
- schedules
needs: ["build_robo-gym_image_py36"]
full_test_environments_py37:
<<: *full_test_environments_def
variables:
PYTHON_VER: "3.7"
only:
- schedules
when: manual
needs: ["build_robo-gym_image_py37"]
full_test_environments_py38:
<<: *full_test_environments_def
variables:
PYTHON_VER: "3.8"
only:
- schedules
when: manual
needs: ["build_robo-gym_image_py38"]
full_test_environments_py39:
<<: *full_test_environments_def
variables:
PYTHON_VER: "3.9"
only:
- schedules
when: manual
needs: ["build_robo-gym_image_py39"]
full_test_environments_py36_with_rs_master:
<<: *full_test_environments_def
variables:
PYTHON_VER: "3.6"
ROBOT_SERVERS_IMAGE: "$CI_REGISTRY/robo-gym/robot-servers:$ROS_DISTRO-master-latest"
only:
- master
full_test_environments_py36_with_rs_manual_deploy:
<<: *full_test_environments_def
variables:
PYTHON_VER: "3.6"
ROBOT_SERVERS_IMAGE: "$CI_REGISTRY/robo-gym/robot-servers:$ROS_DISTRO-manual_deploy-latest"
when: manual
deploy_docker_image:
image: docker:18.09
services:
- docker:18.09-dind
tags:
- docker-executor
stage: deploy
variables:
GIT_STRATEGY: none
script:
- echo -n $CI_JOB_TOKEN | docker login -u gitlab-ci-token --password-stdin $CI_REGISTRY
- docker pull $ROBO_GYM_IMAGE
- docker tag $ROBO_GYM_IMAGE $CI_REGISTRY_IMAGE/$CI_COMMIT_BRANCH:latest
- docker push $CI_REGISTRY_IMAGE/$CI_COMMIT_BRANCH:latest
only:
- master
- develop
except:
- /^docs.*$/
deploy_production:
image: python:3.6-slim-buster
before_script:
- pip3 install twine
- python3 setup.py sdist
stage: deploy
variables:
TWINE_USERNAME: $PYPI_USERNAME
TWINE_PASSWORD: $PYPI_PASSWORD
script:
- twine upload --repository-url https://upload.pypi.org/legacy/ dist/*
only:
- /^v.*$/
except:
refs:
- branches
- triggers