-
Notifications
You must be signed in to change notification settings - Fork 70
/
Copy path.travis.sh
190 lines (163 loc) · 6.95 KB
/
.travis.sh
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
#!/bin/bash
set -e
function travis_time_start {
set +x
TRAVIS_START_TIME=$(date +%s%N)
TRAVIS_TIME_ID=$(cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 8 | head -n 1)
TRAVIS_FOLD_NAME=$1
echo -e "\e[0Ktraivs_fold:start:$TRAVIS_FOLD_NAME"
echo -e "\e[0Ktraivs_time:start:$TRAVIS_TIME_ID"
set -x
}
function travis_time_end {
set +x
_COLOR=${1:-32}
TRAVIS_END_TIME=$(date +%s%N)
TIME_ELAPSED_SECONDS=$(( ($TRAVIS_END_TIME - $TRAVIS_START_TIME)/1000000000 ))
echo -e "traivs_time:end:$TRAVIS_TIME_ID:start=$TRAVIS_START_TIME,finish=$TRAVIS_END_TIME,duration=$(($TRAVIS_END_TIME - $TRAVIS_START_TIME))\n\e[0K"
echo -e "traivs_fold:end:$TRAVIS_FOLD_NAME"
echo -e "\e[0K\e[${_COLOR}mFunction $TRAVIS_FOLD_NAME takes $(( $TIME_ELAPSED_SECONDS / 60 )) min $(( $TIME_ELAPSED_SECONDS % 60 )) sec\e[0m"
set -x
}
function setup {
travis_time_start setup.before_install
#before_install:
# Install ROS
sudo sh -c "echo \"deb http://packages.ros.org/ros-shadow-fixed/ubuntu `lsb_release -cs` main\" > /etc/apt/sources.list.d/ros-latest.list"
wget http://packages.ros.org/ros.key -O - | sudo apt-key add -
# Setup EoL repository
if [[ "$ROS_DISTRO" == "hydro" || "$ROS_DISTRO" == "jade" || "$ROS_DISTRO" == "lunar" ]]; then
sudo -E sh -c 'echo "deb http://snapshots.ros.org/$ROS_DISTRO/final/ubuntu `lsb_release -sc` main" >> /etc/apt/sources.list.d/ros-latest.list'
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key 0xCBF125EA
fi
sudo apt-get update -qq
### HotFix: Hold python-vcs-tools for hydro (https://github.com/vcstools/vcstools/issues/157)
if [[ "$ROS_DISTRO" == "hydro" ]]; then
sudo apt-get install -y --force-yes -q python-vcstools=0.1.40-1
sudo apt-mark hold python-vcstools
fi
###
# Install ROS
if [[ "$ROS_DISTRO" == "noetic" ]]; then
sudo apt-get install -y -q python3-catkin-pkg python3-catkin-tools python3-rosdep python3-wstool python3-rosinstall-generator python3-osrf-pycommon
else
sudo apt-get install -y -q python-catkin-pkg python-catkin-tools python-rosdep python-wstool python-rosinstall-generator
fi
sudo apt-get install -y -q ros-$ROS_DISTRO-catkin
source /opt/ros/$ROS_DISTRO/setup.bash
# Setup for rosdep
sudo rosdep init
# use snapshot of rosdep list
# https://github.com/ros/rosdistro/pull/31570#issuecomment-1000497517
if [[ "$ROS_DISTRO" =~ "hydro"|"indigo"|"jade"|"kinetic"|"lunar" ]]; then
sudo rm /etc/ros/rosdep/sources.list.d/20-default.list
sudo wget https://gist.githubusercontent.com/cottsay/b27a46e53b8f7453bf9ff637d32ea283/raw/476b3714bb90cfbc6b8b9d068162fc6408fa7f76/30-xenial.list -O /etc/ros/rosdep/sources.list.d/30-xenial.list
fi
rosdep update --include-eol-distros
travis_time_end
travis_time_start setup.install
#install:
mkdir -p ~/catkin_ws/src
# Add the package under test to the workspace.
cd ~/catkin_ws/src
ln -s $CI_SOURCE_PATH . # Link the repo we are testing to the new workspace
# Install all dependencies, using wstool and rosdep.
# wstool looks for a ROSINSTALL_FILE defined in before_install.
travis_time_end
travis_time_start setup.before_script
#before_script:
# source dependencies: install using wstool.
cd ~/catkin_ws/src
wstool init
#if [[ -f $ROSINSTALL_FILE ]] ; then wstool merge $ROSINSTALL_FILE ; fi
if [ "$OPENCV_VERSION" == 3 ]; then rosinstall_generator image_pipeline --upstream >> .rosinstall.opencv3; fi # need to recompile image_proc
if [ "$OPENCV_VERSION" == 3 ]; then rosinstall_generator compressed_image_transport --upstream >> .rosinstall.opencv3; fi # need to recompile compressed_image_transport
if [ "$OPENCV_VERSION" == 3 ]; then rosinstall_generator vision_opencv --upstream >> .rosinstall.opencv3; fi # need to recompile visoin_opencv
if [ "$OPENCV_VERSION" == 3 ]; then wstool merge .rosinstall.opencv3; fi # need to recompile visoin_opencv
wstool up
wstool info
if [ "$OPENCV_VERSION" == 3 ]; then sed -i 's@libopencv-dev@opencv3@' */*/package.xml ; fi
# package depdencies: install using rosdep.
cd ~/catkin_ws
rosdep install -q -y --from-paths src --ignore-src --rosdistro $ROS_DISTRO
travis_time_end
}
function build {
travis_time_start build.script
source /opt/ros/$ROS_DISTRO/setup.bash
cd ~/catkin_ws
catkin build -p1 -j1 --no-status
travis_time_end
}
function run_test {
travis_time_start run_test.script
source /opt/ros/$ROS_DISTRO/setup.bash
cd ~/catkin_ws
catkin run_tests -p1 -j1 --no-status -i opencv_apps --no-deps
catkin_test_results --verbose build || catkin_test_results --all build
travis_time_end
}
function build_install {
travis_time_start build_install.script
source /opt/ros/$ROS_DISTRO/setup.bash
cd ~/catkin_ws
catkin clean -b --yes || catkin clean -b -a
catkin config --install
catkin build -p1 -j1 --no-status
travis_time_end
}
travis_time_start apt.before_install
apt-get -y -qq update || if [ $? -eq 100 ]; then sed -i 's/archive.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list; apt-get -y -qq update; fi
apt-get install -y -q wget sudo lsb-release gnupg # for docker
# set DEBIAN_FRONTEND=noninteractive
echo 'debconf debconf/frontend select Noninteractive' | sudo debconf-set-selections
travis_time_end
if [ "$TEST" == "catkin_lint" ]; then
travis_time_start catkin_lint.script
apt-get install -y -q python-pip
pip install catkin_lint rosdep
rosdep init
rosdep update
travis_time_end
ROS_DISTRO=melodic catkin_lint --resolve-env --strict $CI_SOURCE_PATH
elif [ "$TEST" == "clang-format" ]; then
travis_time_start clang_format.script
apt-get install -y -q clang-format git
find $CI_SOURCE_PATH -name '*.h' -or -name '*.hpp' -or -name '*.cpp' | xargs clang-format -i -style=file
travis_time_end
git -C $CI_SOURCE_PATH --no-pager diff
git -C $CI_SOURCE_PATH diff-index --quiet HEAD -- .
elif [ "$TEST" == "clang-tidy" ]; then
setup
travis_time_start clang_tidy.script
apt-get install -y -q clang-tidy clang-tools
cd ~/catkin_ws
catkin config --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
travis_time_end
build
travis_time_start clang_tidy.script
for file in $(find ~/catkin_ws/build -name compile_commands.json) ; do
run-clang-tidy -fix -p $(dirname $file)
done
travis_time_end
sudo chown -R $(whoami) $CI_SOURCE_PATH
git -C $CI_SOURCE_PATH --no-pager diff
git -C $CI_SOURCE_PATH diff-index --quiet HEAD -- .
elif [ "$TEST" == "debian-unstable" ]; then
sed -i 's/Types: deb/Types: deb deb-src/' /etc/apt/sources.list.d/debian.sources
apt update
apt-get -y build-dep ros-opencv-apps
travis_time_start build_debian_unstable.script
cd $CI_SOURCE_PATH
mkdir build
cd build
cmake ..
make VERBOSE=1
travis_time_end
else
# Compile and test.
setup
build
run_test
build_install
fi