-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathentrypoint.sh
executable file
·187 lines (159 loc) · 5.09 KB
/
entrypoint.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
#!/bin/sh -l
set -x
set -e
OLD_APT_DEPENDENCIES=$1
CODECOV_TOKEN=$2
CMAKE_ARGS=$3
export DEBIAN_FRONTEND="noninteractive"
cd "$GITHUB_WORKSPACE"
echo ::group::Install tools: apt
apt update 2>&1
apt -y install \
build-essential \
cmake \
cppcheck \
curl \
g++-8 \
git \
gnupg \
lsb-release \
python3-pip \
wget
SYSTEM_VERSION=`lsb_release -cs`
SOURCE_DEPENDENCIES="`pwd`/.github/ci/dependencies.yaml"
SOURCE_DEPENDENCIES_VERSIONED="`pwd`/.github/ci-$SYSTEM_VERSION/dependencies.yaml"
SCRIPT_BEFORE_CMAKE="`pwd`/.github/ci/before_cmake.sh"
SCRIPT_BEFORE_CMAKE_VERSIONED="`pwd`/.github/ci-$SYSTEM_VERSION/before_cmake.sh"
SCRIPT_BETWEEN_CMAKE_MAKE="`pwd`/.github/ci/between_cmake_make.sh"
SCRIPT_BETWEEN_CMAKE_MAKE_VERSIONED="`pwd`/.github/ci-$SYSTEM_VERSION/between_cmake_make.sh"
SCRIPT_AFTER_MAKE="`pwd`/.github/ci/after_make.sh"
SCRIPT_AFTER_MAKE_VERSIONED="`pwd`/.github/ci-$SYSTEM_VERSION/after_make.sh"
SCRIPT_AFTER_MAKE_TEST="`pwd`/.github/ci/after_make_test.sh"
SCRIPT_AFTER_MAKE_TEST_VERSIONED="`pwd`/.github/ci-$SYSTEM_VERSION/after_make_test.sh"
# Infer package name from GITHUB_REPOSITORY
PACKAGE=$(echo "$GITHUB_REPOSITORY" | sed 's:.*/::' | sed 's:ign-:ignition-:')
wget https://raw.githubusercontent.com/ignition-tooling/release-tools/master/jenkins-scripts/tools/detect_cmake_major_version.py
PACKAGE_MAJOR_VERSION=$(python3 detect_cmake_major_version.py "$GITHUB_WORKSPACE"/CMakeLists.txt)
git clone --depth 1 https://github.com/osrf/gzdev /tmp/gzdev
pip3 install -r /tmp/gzdev/requirements.txt
/tmp/gzdev/gzdev.py \
repository enable --project="${PACKAGE}${PACKAGE_MAJOR_VERSION}"
apt-get update 2>&1
echo ::endgroup::
echo ::group::Install tools: pip
pip3 install -U pip vcstool colcon-common-extensions
echo ::endgroup::
echo ::group::Install tools: source
git clone https://github.com/linux-test-project/lcov.git -b v1.14 2>&1
cd lcov
make install
cd ..
echo ::endgroup::
echo ::group::GCC 8
update-alternatives \
--install /usr/bin/gcc gcc /usr/bin/gcc-8 800 \
--slave /usr/bin/g++ g++ /usr/bin/g++-8 \
--slave /usr/bin/gcov gcov /usr/bin/gcov-8
echo ::endgroup::
if [ -f "$SOURCE_DEPENDENCIES" ] || [ -f "$SOURCE_DEPENDENCIES_VERSIONED" ] ; then
echo ::group::Fetch source dependencies
mkdir -p deps/src
if [ -f "$SOURCE_DEPENDENCIES" ] ; then
vcs import deps/src < $SOURCE_DEPENDENCIES
fi
if [ -f "$SOURCE_DEPENDENCIES_VERSIONED" ] ; then
vcs import deps/src < $SOURCE_DEPENDENCIES_VERSIONED
fi
echo ::endgroup::
fi
echo ::group::Install dependencies from binaries
apt -y install \
$OLD_APT_DEPENDENCIES \
$(sort -u $(find . -iname 'packages-'$SYSTEM_VERSION'.apt' -o -iname 'packages.apt') | tr '\n' ' ')
echo ::endgroup::
if [ -f "$SOURCE_DEPENDENCIES" ] || [ -f "$SOURCE_DEPENDENCIES_VERSIONED" ] ; then
echo ::group::Compile dependencies from source
cd deps
colcon build --symlink-install --merge-install --cmake-args -DBUILD_TESTING=false
. install/setup.sh
cd ..
echo ::endgroup::
fi
echo ::group::Build folder
mkdir build
cd build
echo ::endgroup::
if [ -f "$SCRIPT_BEFORE_CMAKE" ] || [ -f "$SCRIPT_BEFORE_CMAKE_VERSIONED" ] ; then
echo ::group::Script before cmake
if [ -f "$SCRIPT_BEFORE_CMAKE" ] ; then
. $SCRIPT_BEFORE_CMAKE
fi
if [ -f "$SCRIPT_BEFORE_CMAKE_VERSIONED" ] ; then
. $SCRIPT_BEFORE_CMAKE_VERSIONED
fi
echo ::endgroup::
fi
echo ::group::cmake
if [ ! -z "$CODECOV_TOKEN" ] ; then
cmake .. $CMAKE_ARGS -DCMAKE_BUILD_TYPE=coverage
else
cmake .. $CMAKE_ARGS
fi
echo ::endgroup::
echo ::group::Code check
# only run `make codecheck` if the Makefile has a `codecheck` target
# (default to tools/code_check.sh otherwise)
if grep -iq codecheck Makefile; then
make codecheck 2>&1
else
cd ..
sh tools/code_check.sh 2>&1
cd build
fi
echo ::endgroup::
if [ -f "$SCRIPT_BETWEEN_CMAKE_MAKE" ] || [ -f "$SCRIPT_BETWEEN_CMAKE_MAKE_VERSIONED" ] ; then
echo ::group::Script between cmake and make
if [ -f "$SCRIPT_BETWEEN_CMAKE_MAKE" ] ; then
. $SCRIPT_BETWEEN_CMAKE_MAKE
fi
if [ -f "$SCRIPT_BETWEEN_CMAKE_MAKE_VERSIONED" ] ; then
. $SCRIPT_BETWEEN_CMAKE_MAKE_VERSIONED
fi
echo ::endgroup::
fi
echo ::group::make
make
echo ::endgroup::
if [ -f "$SCRIPT_AFTER_MAKE" ] || [ -f "$SCRIPT_AFTER_MAKE_VERSIONED" ] ; then
echo ::group::Script after make
if [ -f "$SCRIPT_AFTER_MAKE" ] ; then
. $SCRIPT_AFTER_MAKE
fi
if [ -f "$SCRIPT_AFTER_MAKE_VERSIONED" ] ; then
. $SCRIPT_AFTER_MAKE_VERSIONED
fi
echo ::endgroup::
fi
echo ::group::make test
export CTEST_OUTPUT_ON_FAILURE=1
cd "$GITHUB_WORKSPACE"/build
make test
echo ::endgroup::
if [ -f "$SCRIPT_AFTER_MAKE_TEST" ] || [ -f "$SCRIPT_AFTER_MAKE_TEST_VERSIONED" ] ; then
echo ::group::Script after make test
if [ -f "$SCRIPT_AFTER_MAKE_TEST" ] ; then
. $SCRIPT_AFTER_MAKE_TEST
fi
if [ -f "$SCRIPT_AFTER_MAKE_TEST_VERSIONED" ] ; then
. $SCRIPT_AFTER_MAKE_TEST_VERSIONED
fi
echo ::endgroup::
fi
if [ ! -z "$CODECOV_TOKEN" ] ; then
echo ::group::codecov
make coverage VERBOSE=1
curl -v -f https://codecov.io/bash > codecov.sh
# disable gcov output with `-X gcovout -X gcov`
bash codecov.sh -t $CODECOV_TOKEN -X gcovout -X gcov
echo ::endgroup::
fi