forked from SHOP4CF/moni2-ros-monitor-tool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
75 lines (67 loc) · 2.4 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
stages:
- test
- deploy
run_ros_tests:
stage: test
image: robotgit.localdom.net:5000/ros2/foxy-ci:latest
variables:
WS_PATH: ${CI_BUILDS_DIR}/ros_ws
WS_SRC_PATH: ${CI_BUILDS_DIR}/ros_ws/src
GIT_CLONE_PATH: ${CI_BUILDS_DIR}/ros_ws/src/${CI_PROJECT_NAME}
SRC_DEPENDENCIES_FILE: ${CI_BUILDS_DIR}/ros_ws/src/${CI_PROJECT_NAME}/src_dependencies.rosinstall
QT_QPA_PLATFORM: offscreen
XDG_RUNTIME_DIR: /tmp
script:
# delete cached workspace contents (as gitlab caches stuff from previous builds)
- mv $GIT_CLONE_PATH /tmp/tmp_repo_contents
- rm -rf $WS_PATH
- mkdir -p $WS_SRC_PATH
- mv /tmp/tmp_repo_contents $GIT_CLONE_PATH
- cd $GIT_CLONE_PATH
# Fetch dependencies
- >
if [ -f "${SRC_DEPENDENCIES_FILE}" ]; then
echo "Found source dependencies, installing..."
wstool init ${WS_SRC_PATH} ${SRC_DEPENDENCIES_FILE} --shallow
else
echo "No file for source-dependencies found at ${SRC_DEPENDENCIES_FILE}, skipping."
fi
# install standard dependencies for all ROS packages
- rosdep install -q --default-yes --ignore-packages-from-source --from-path ${WS_SRC_PATH}
# Build
- cd ${WS_PATH}
- colcon build
# Test
- colcon test --pytest-with-coverage
- colcon test-result --verbose
- coverage=$(xmllint --html --xpath '/html/body/div[@id="header"]/div/h1/span/text()' ${WS_PATH}/build/moni2/coverage.html/index.html)
- echo "coverage $coverage"
after_script:
# copy test reports to the project directory, so that we can upload them as artifacts
- mkdir -p ${CI_PROJECT_DIR}/test_results
- cp ${WS_PATH}/build/*/*.xml ${CI_PROJECT_DIR}/test_results
- cp -rp ${WS_PATH}/build/*/coverage.html ${CI_PROJECT_DIR}
artifacts:
paths:
- coverage.html
# let test results show up in gitlab GUI, see also https://docs.gitlab.com/ee/ci/junit_test_reports.html
reports:
junit: test_results/pytest.xml
cobertura: test_results/coverage.xml
build_image:
stage: deploy
image: docker:19.03.8
rules:
# Only build and push image when a new tag is pushed
- if: '$CI_COMMIT_TAG != null'
variables:
REGISTRY: robotgit.localdom.net:5000/aibox/moni2
TAG: 0.1.0
before_script:
- docker info
script:
- docker build -t $REGISTRY:$TAG -t $REGISTRY:latest .
- docker push $REGISTRY:latest
- docker push $REGISTRY:$TAG
tags:
- docker-dind-builder