forked from autowarefoundation/autoware
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
136 lines (128 loc) · 5.42 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
stages:
- build
- deploy
variables:
ROS_CI_DESKTOP: "`lsb_release -cs`"
CI_SOURCE_PATH: $CI_PROJECT_DIR
ROSINSTALL_FILE: $CI_SOURCE_PATH/dependencies.rosinstall
CATKIN_OPTIONS: $CI_SOURCE_PATH/catkin.options
GIT_SUBMODULE_STRATEGY: recursive
#CI_DEBUG_TRACE: "true"
.build: &build_common
before_script:
- apt-get update
- apt-get install -y lsb-release
- apt-get install -y gcc g++
- sh -c "echo \"deb http://packages.ros.org/ros/ubuntu $ROS_CI_DESKTOP main\" > /etc/apt/sources.list.d/ros-latest.list"
- apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116
- apt-get update
- apt-get install -y dpkg
- apt-get install -y python-catkin-pkg python-rosdep python-wstool ros-${ROS_DISTRO}-catkin
- apt-get install -y python3-pip python3-setuptools
# Update setuptools from PyPI because the version Ubuntu ships with is too old
- pip3 install -U setuptools
- source /opt/ros/${ROS_DISTRO}/setup.bash
- rosdep init
- rosdep update
- cd ros/src
- wstool init
- test -f "${ROSINSTALL_FILE}" && wstool merge "${ROSINSTALL_FILE}"
- wstool up
- cd ..
- rosdep install -y --from-paths src --ignore-src --rosdistro ${ROS_DISTRO}
build_kinetic:
stage: build
image: ubuntu:xenial
variables:
ROS_DISTRO: kinetic
<<: *build_common
script:
# colcon as a Debian package is only available in Kinetic and up
- apt-get install -y python3-colcon-common-extensions
# Install lcov from source as binary installation errors when appending files
- git clone https://github.com/linux-test-project/lcov.git
- cd lcov
- git checkout v1.13
- make install
- cd ..
- rm -r lcov
# We first build the entire workspace normally
- 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/*' '/usr/*' '/opt/*' '*/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
- mv coverage.tar.gz $CI_PROJECT_DIR/coverage.tar.gz
- ls $CI_PROJECT_DIR
retry: 1
artifacts:
paths:
- $CI_PROJECT_DIR/coverage.tar.gz
expire_in: 48 hrs
coverage: /\s*lines.*:\s(\d+\.\d+\%\s\(\d+\sof\s\d+.*\))/
build_cross:
stage: build
image: docker
services:
- docker:dind
variables:
ROS_DISTRO: kinetic
AUTOWARE_DOCKER_DATE: 20190102
AUTOWARE_HOME: $CI_PROJECT_DIR
AUTOWARE_TARGET_ARCH: aarch64
AUTOWARE_TARGET_PLATFORM: generic-aarch64
AUTOWARE_BUILD_PATH: $CI_PROJECT_DIR/ros/build-${AUTOWARE_TARGET_PLATFORM}
AUTOWARE_INSTALL_PATH: $CI_PROJECT_DIR/ros/install-${AUTOWARE_TARGET_PLATFORM}
AUTOWARE_TOOLCHAIN_FILE_PATH: $CI_PROJECT_DIR/ros/cross_toolchain.cmake
AUTOWARE_SYSROOT: /sysroot/${AUTOWARE_TARGET_PLATFORM}
script:
# - ${AUTOWARE_HOME}/docker/crossbuild/build_cross_image.sh
- 'docker run
-e AUTOWARE_SYSROOT=${AUTOWARE_SYSROOT}
--rm
-v ${AUTOWARE_HOME}:${AUTOWARE_HOME}
-w ${AUTOWARE_HOME}/ros
autoware/build:${AUTOWARE_TARGET_PLATFORM}-kinetic-${AUTOWARE_DOCKER_DATE}
bash
-c "
source ${AUTOWARE_SYSROOT}/opt/ros/kinetic/setup.bash &&
colcon build
--merge-install
--build-base ${AUTOWARE_BUILD_PATH}
--install-base ${AUTOWARE_INSTALL_PATH}
--cmake-args
-DCMAKE_TOOLCHAIN_FILE=${AUTOWARE_TOOLCHAIN_FILE_PATH}
-DCMAKE_SYSTEM_PROCESSOR=${AUTOWARE_TARGET_ARCH}
-DCMAKE_PREFIX_PATH=\"${AUTOWARE_SYSROOT}/opt/ros/kinetic;${AUTOWARE_INSTALL_PATH}\"
-DCMAKE_FIND_ROOT_PATH=${AUTOWARE_INSTALL_PATH}
"
'
retry: 1
pages:
stage: deploy
image: alpine
dependencies:
- build_kinetic
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
- develop