-
Notifications
You must be signed in to change notification settings - Fork 410
/
do_ci.sh
executable file
·165 lines (156 loc) · 4.74 KB
/
do_ci.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
#!/bin/bash
set -e
[ -z "${SRC_DIR}" ] && export SRC_DIR="`pwd`"
[ -z "${BUILD_DIR}" ] && export BUILD_DIR=$HOME/build
mkdir -p "${BUILD_DIR}"
[ -z "${PLUGIN_DIR}" ] && export PLUGIN_DIR=$HOME/plugin
mkdir -p "${PLUGIN_DIR}"
BAZEL_OPTIONS=""
BAZEL_TEST_OPTIONS="$BAZEL_OPTIONS --test_output=errors"
if [[ "$1" == "cmake.test" ]]; then
cd "${BUILD_DIR}"
rm -rf *
cmake -DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_CXX_FLAGS="-Werror" \
"${SRC_DIR}"
make
make test
exit 0
elif [[ "$1" == "cmake.c++20.test" ]]; then
cd "${BUILD_DIR}"
rm -rf *
cmake -DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_CXX_FLAGS="-Werror" \
-DCMAKE_CXX_STANDARD=20 \
"${SRC_DIR}"
make
make test
exit 0
elif [[ "$1" == "cmake.exporter.otprotocol.test" ]]; then
cd "${BUILD_DIR}"
rm -rf *
cmake -DCMAKE_BUILD_TYPE=Debug \
-DWITH_OTPROTOCOL=ON \
-DCMAKE_CXX_FLAGS="-Werror" \
"${SRC_DIR}"
make
make test
exit 0
elif [[ "$1" == "cmake.exporter.prometheus.test" ]]; then
# export DEBIAN_FRONTEND=noninteractive
# apt-get update
# apt-get install sudo
# apt-get install zlib1g-dev
# apt-get -y install libcurl4-openssl-dev
cd third_party
git clone https://github.com/jupp0r/prometheus-cpp
cd prometheus-cpp
git checkout v0.9.0
git submodule init
git submodule update
mkdir _build && cd _build
cmake .. -DBUILD_SHARED_LIBS=ON
make -j 4
sudo make install
cd "${BUILD_DIR}"
rm -rf *
cmake -DCMAKE_BUILD_TYPE=Debug \
-DWITH_PROMETHEUS=ON \
-DCMAKE_CXX_FLAGS="-Werror" \
"${SRC_DIR}"
make
make test
exit 0
elif [[ "$1" == "cmake.test_example_plugin" ]]; then
# Build the plugin
cd "${BUILD_DIR}"
rm -rf *
cat <<EOF > export.map
{
global:
OpenTelemetryMakeFactoryImpl;
local: *;
};
EOF
LINKER_FLAGS="\
-static-libstdc++ \
-static-libgcc \
-Wl,--version-script=${PWD}/export.map \
"
cmake -DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_CXX_FLAGS="-Werror" \
-DCMAKE_EXE_LINKER_FLAGS="$LINKER_FLAGS" \
-DCMAKE_SHARED_LINKER_FLAGS="$LINKER_FLAGS" \
"${SRC_DIR}"
make example_plugin
cp examples/plugin/plugin/libexample_plugin.so ${PLUGIN_DIR}
# Verify we can load the plugin
cd "${BUILD_DIR}"
rm -rf *
cmake -DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_CXX_FLAGS="-Werror" \
"${SRC_DIR}"
make load_plugin_example
examples/plugin/load/load_plugin_example ${PLUGIN_DIR}/libexample_plugin.so /dev/null
exit 0
elif [[ "$1" == "bazel.test" ]]; then
bazel build $BAZEL_OPTIONS //...
bazel test $BAZEL_TEST_OPTIONS //...
exit 0
elif [[ "$1" == "bazel.legacy.test" ]]; then
# we uses C++ future and async() function to test the Prometheus Exporter functionality,
# that make this test always fail. ignore Prometheus exporter here.
bazel build $BAZEL_OPTIONS -- //... -//exporters/otlp/... -//exporters/prometheus/...
bazel test $BAZEL_TEST_OPTIONS -- //... -//exporters/otlp/... -//exporters/prometheus/...
exit 0
elif [[ "$1" == "bazel.noexcept" ]]; then
# there are some exceptions and error handling code from the Prometheus Client
# that make this test always fail. ignore Prometheus exporter in the noexcept here.
bazel build --copt=-fno-exceptions $BAZEL_OPTIONS -- //... -//exporters/prometheus/...
bazel test --copt=-fno-exceptions $BAZEL_TEST_OPTIONS -- //... -//exporters/prometheus/...
exit 0
elif [[ "$1" == "bazel.asan" ]]; then
bazel test --config=asan $BAZEL_TEST_OPTIONS //...
exit 0
elif [[ "$1" == "bazel.tsan" ]]; then
bazel test --config=tsan $BAZEL_TEST_OPTIONS //...
exit 0
elif [[ "$1" == "bazel.valgrind" ]]; then
bazel build $BAZEL_OPTIONS //...
bazel test --run_under="/usr/bin/valgrind --leak-check=full --error-exitcode=1" $BAZEL_TEST_OPTIONS //...
exit 0
elif [[ "$1" == "benchmark" ]]; then
[ -z "${BENCHMARK_DIR}" ] && export BENCHMARK_DIR=$HOME/benchmark
bazel build $BAZEL_OPTIONS -c opt -- \
$(bazel query 'attr("tags", "benchmark_result", ...)')
echo ""
echo "Benchmark results in $BENCHMARK_DIR:"
(
cd bazel-bin
find . -name \*_result.txt -exec bash -c \
'echo "$@" && mkdir -p "$BENCHMARK_DIR/$(dirname "$@")" && \
cp "$@" "$BENCHMARK_DIR/$@" && chmod +w "$BENCHMARK_DIR/$@"' _ {} \;
)
exit 0
elif [[ "$1" == "format" ]]; then
tools/format.sh
CHANGED="$(git ls-files --modified)"
if [[ ! -z "$CHANGED" ]]; then
echo "The following files have changes:"
echo "$CHANGED"
exit 1
fi
exit 0
elif [[ "$1" == "code.coverage" ]]; then
cd "${BUILD_DIR}"
rm -rf *
cmake -DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_CXX_FLAGS="-Werror --coverage" \
"${SRC_DIR}"
make
make test
lcov --directory $PWD --capture --output-file coverage.info
exit 0
fi
echo "Invalid do_ci.sh target, see ci/README.md for valid targets."
exit 1