-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
136 lines (129 loc) · 5.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
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
stages:
- build
- deploy
.build: &build_common
before_script:
- mkdir -p src_tmp/$CI_PROJECT_NAME && mv `find -maxdepth 1 -not -name . -not -name src_tmp` src_tmp/$CI_PROJECT_NAME && mv src_tmp/ src/
- apt-get update
- apt-get install -y python3-pip python3-setuptools python3-colcon-common-extensions
# Update setuptools from PyPI because the version Ubuntu ships with is too old
- pip3 install -U setuptools
# Install lcov from the Ubuntu package. We need 1.13 at least.
- $INSTALL_LCOV
- $INSTALL_LCOV2
- $INSTALL_LCOV3
- $INSTALL_LCOV4
- $INSTALL_LCOV5
- $INSTALL_LCOV6
- rosdep update
- rosdep install -y --from-paths src --ignore-src --rosdistro $ROS_DISTRO
script:
# We first build the entire workspace normally
- source /opt/ros/${ROS_DISTRO}/setup.bash
- colcon build --cmake-args -DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage" -DCMAKE_C_FLAGS="${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage" -DCMAKE_BUILD_TYPE=Debug
# And then build the tests target. catkin (ROS1) packages add their tests to the tests target
# which is not the standard target for CMake projects. We need to trigger the tests target so that
# tests are built and any fixtures are set up.
- colcon build --cmake-target tests --cmake-args -DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage" -DCMAKE_C_FLAGS="${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage" -DCMAKE_BUILD_TYPE=Debug
- lcov --initial --directory build --capture --output-file lcov.base
- colcon test
- colcon test-result
- lcov --directory build --capture --output-file lcov.test
- lcov -a lcov.base -a lcov.test -o lcov.total
- lcov -r lcov.total '*/tests/*' '*/test/*' '*/build/*' '*/devel/*' '*/install/*' '*/log/*' '/usr/*' '/opt/*' '/tmp/*' '*/CMakeCCompilerId.c' '*/CMakeCXXCompilerId.cpp' -o lcov.total.filtered
# BRANCH_NAME: gets branch name from CI_COMMIT_REF_NAME variable substituting / with _ (feature/test_this_lib becomes feature_test_this_lib)
# CI_COMMIT_REF_NAME: (from https://docs.gitlab.com/ee/ci/variables/) The branch or tag name for which project is built
- BRANCH_NAME="$(echo $CI_COMMIT_REF_NAME | sed 's/\//_/g')"
- COVERAGE_FOLDER_NAME="coverage_$BRANCH_NAME"
- genhtml -p "$PWD" --legend --demangle-cpp lcov.total.filtered -o $COVERAGE_FOLDER_NAME
- tar -czvf coverage.tar.gz $COVERAGE_FOLDER_NAME
artifacts:
paths:
- $CI_PROJECT_DIR/coverage.tar.gz
expire_in: 48 hrs
coverage: /\s*lines.*:\s(\d+\.\d+\%\s\(\d+\sof\s\d+.*\))/
only:
- merge_requests
- master
.build_cuda_common: &build_cuda_common
before_script:
- apt-get update
- $INSTALL_TZDATA
- $INSTALL_TZDATA1
- $INSTALL_TZDATA2
- echo "deb http://packages.ros.org/ros/ubuntu $UBUNTU_DISTRO main" > /etc/apt/sources.list.d/ros-latest.list
- apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
- apt-get update
- $INSTALL_ROS
- mkdir -p src_tmp/$CI_PROJECT_NAME && mv `find -maxdepth 1 -not -name . -not -name src_tmp` src_tmp/$CI_PROJECT_NAME && mv src_tmp/ src/
- apt-get install -y python3-pip python3-setuptools python3-colcon-common-extensions
# Update setuptools from PyPI because the version Ubuntu ships with is too old
- pip3 install -U setuptools
- rosdep init
- rosdep update
- rosdep install -y --from-paths src --ignore-src --rosdistro $ROS_DISTRO
script:
# We first build the entire workspace normally
- source /opt/ros/${ROS_DISTRO}/setup.bash
- colcon build --cmake-args -DCMAKE_BUILD_TYPE=Debug
# And then build the tests target. catkin (ROS1) packages add their tests to the tests target
# which is not the standard target for CMake projects. We need to trigger the tests target so that
# tests are built and any fixtures are set up.
- colcon build --cmake-target tests --cmake-args -DCMAKE_BUILD_TYPE=Debug
- colcon test
- colcon test-result
only:
- merge_requests
- master
build_kinetic:
stage: build
image: ros:kinetic-perception
variables:
INSTALL_LCOV: git clone https://github.com/linux-test-project/lcov.git
INSTALL_LCOV2: cd lcov
INSTALL_LCOV3: git checkout v1.13
INSTALL_LCOV4: make install
INSTALL_LCOV5: cd ..
INSTALL_LCOV6: rm -r lcov
<<: *build_common
build_melodic:
stage: build
image: ros:melodic-perception
variables:
INSTALL_LCOV: apt install -y lcov
<<: *build_common
build_kinetic_cuda:
stage: build
image: nvidia/cuda:9.0-runtime-ubuntu16.04
variables:
UBUNTU_DISTRO: xenial
ROS_DISTRO: kinetic
INSTALL_ROS: apt-get install -y ros-kinetic-perception
<<: *build_cuda_common
build_melodic_cuda:
stage: build
image: nvidia/cuda:10.0-runtime-ubuntu18.04
variables:
INSTALL_TZDATA: echo 'Etc/UTC' > /etc/timezone
INSTALL_TZDATA1: ln -s /usr/share/zoneinfo/Etc/UTC /etc/localtime
INSTALL_TZDATA2: apt-get install -q -y tzdata
UBUNTU_DISTRO: bionic
ROS_DISTRO: melodic
INSTALL_ROS: apt-get install -y ros-melodic-perception
<<: *build_cuda_common
pages:
stage: deploy
image: alpine
dependencies:
- build_kinetic
- build_melodic
script:
- BRANCH_NAME="$(echo $CI_COMMIT_REF_NAME | sed 's/\//_/g')"
- COVERAGE_FOLDER_NAME="coverage_$BRANCH_NAME"
- tar -xzvf coverage.tar.gz
- mv $COVERAGE_FOLDER_NAME public
artifacts:
paths:
- public
only:
- master