forked from jr-robotics/robo-gym-robot-servers
-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
200 lines (179 loc) · 5.35 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
stages:
- build
- manual-deploy
- test
- deploy
variables:
PYTHON_VER: "3.6"
ROS_DISTRO: "noetic"
ROBO_GYM_IMAGE: "$CI_REGISTRY/robo-gym/robo-gym/develop:latest"
ROBOT_SERVERS_IMAGE: "$CI_REGISTRY_IMAGE:$ROS_DISTRO-$CI_COMMIT_SHA"
before_script:
- 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_docker_image: &build_docker_image_def
image: docker:18.09
services:
- docker:18.09-dind
tags:
- docker-executor
stage: build
script:
# fetch the latest image (not failing if image is not found)
- docker pull $CI_REGISTRY_IMAGE:$ROS_DISTRO-latest || true
- >
docker build
-f $ROS_DISTRO.Dockerfile
--cache-from $CI_REGISTRY_IMAGE:$ROS_DISTRO-latest
--build-arg GIT_COMMIT=$CI_COMMIT_SHA
--build-arg CI_JOB_TOKEN=$CI_JOB_TOKEN
--build-arg CACHEBUST=$CI_COMMIT_SHA
-t $CI_REGISTRY_IMAGE:$ROS_DISTRO-$CI_COMMIT_SHA
.
- docker push $CI_REGISTRY_IMAGE:$ROS_DISTRO-$CI_COMMIT_SHA
- docker tag $CI_REGISTRY_IMAGE:$ROS_DISTRO-$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:$ROS_DISTRO-latest
- docker push $CI_REGISTRY_IMAGE:$ROS_DISTRO-latest
except:
- /^docs.*$/
build_melodic_docker_image:
<<: *build_docker_image_def
variables:
ROS_DISTRO: "melodic"
build_noetic_docker_image:
<<: *build_docker_image_def
variables:
ROS_DISTRO: "noetic"
.test_environments: &test_environments_def
image: docker:18.09
before_script:
- echo -n $CI_JOB_TOKEN | docker login -u gitlab-ci-token --password-stdin $CI_REGISTRY
- apk add docker-compose
services:
- docker:18.09-dind
tags:
- docker-executor
stage: test
script:
- echo "Python Version:$PYTHON_VER robo-gym image:$ROBO_GYM_IMAGE robot-servers image:$ROBOT_SERVERS_IMAGE"
- 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.yml up -d
- docker exec robo-gym pytest -m "not nightly"
- docker-compose -f docker-compose.yml down
except:
- /^docs.*$/
test_environments_melodic:
<<: *test_environments_def
variables:
ROS_DISTRO: melodic
when: manual
needs: ["build_melodic_docker_image"]
test_environments_noetic:
<<: *test_environments_def
variables:
ROS_DISTRO: noetic
needs: ["build_noetic_docker_image"]
test_environments_with_robo-gym-master:
<<: *test_environments_def
variables:
ROBO_GYM_IMAGE: "$CI_REGISTRY/robo-gym/robo-gym/master:latest"
only:
- master
.full_test_environments: &full_test_environments_def
image: docker:18.09
before_script:
- echo -n $CI_JOB_TOKEN | docker login -u gitlab-ci-token --password-stdin $CI_REGISTRY
- apk add docker-compose
services:
- docker:18.09-dind
tags:
- docker-executor
stage: test
script:
- echo "Python Version:$PYTHON_VER robo-gym image:$ROBO_GYM_IMAGE robot-servers image:$ROBOT_SERVERS_IMAGE"
- 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.yml up -d
- docker exec robo-gym pytest -x
- docker-compose -f docker-compose.yml down
except:
- /^docs.*$/
full_test_environments_melodic:
<<: *full_test_environments_def
variables:
ROS_DISTRO: melodic
when: manual
needs: ["build_melodic_docker_image"]
full_test_environments_noetic:
<<: *full_test_environments_def
variables:
ROS_DISTRO: noetic
when: manual
needs: ["build_noetic_docker_image"]
.deploy_docker_image: &deploy_docker_image_def
image: docker:18.09
services:
- docker:18.09-dind
tags:
- docker-executor
stage: deploy
variables:
GIT_STRATEGY: none
IMAGE_NAME: $CI_COMMIT_BRANCH
script:
- docker pull $CI_REGISTRY_IMAGE:$ROS_DISTRO-$CI_COMMIT_SHA
- docker tag $CI_REGISTRY_IMAGE:$ROS_DISTRO-$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:$ROS_DISTRO-$IMAGE_NAME-latest
- docker push $CI_REGISTRY_IMAGE:$ROS_DISTRO-$IMAGE_NAME-latest
except:
- /^docs.*$/
deploy_docker_image:
<<: *deploy_docker_image_def
only:
- master
- develop
manual_deploy_test_docker_image:
<<: *deploy_docker_image_def
stage: manual-deploy
variables:
IMAGE_NAME: "manual_deploy"
when: manual
manual_deploy_docker_image:
<<: *deploy_docker_image_def
stage: manual-deploy
only:
- master
- develop
when: manual
deploy_docker_image_to_dockerhub:
image: docker:18.09
services:
- docker:18.09-dind
tags:
- docker-executor
stage: deploy
variables:
GIT_STRATEGY: none
script:
- docker pull $CI_REGISTRY_IMAGE:$ROS_DISTRO-$CI_COMMIT_SHA
- docker tag $CI_REGISTRY_IMAGE:$ROS_DISTRO-$CI_COMMIT_SHA joanneumrobotics/robo-gym-robot-server-side:$CI_COMMIT_SHA
- docker tag $CI_REGISTRY_IMAGE:$ROS_DISTRO-$CI_COMMIT_SHA joanneumrobotics/robo-gym-robot-server-side:latest
- echo "$DOCKER_HUB_TOKEN" | docker login --username $DOCKER_HUB_USER --password-stdin
- docker push joanneumrobotics/robo-gym-robot-server-side:$CI_COMMIT_SHA
- docker push joanneumrobotics/robo-gym-robot-server-side:latest
only:
- master
when: manual
except:
- /^docs.*$/