2019-04-25 12:29:28 +00:00
|
|
|
#!/usr/bin/env bash
|
2022-05-13 10:50:16 +00:00
|
|
|
set -x -e
|
2019-04-25 12:29:28 +00:00
|
|
|
|
2022-03-16 18:52:19 +00:00
|
|
|
exec &> >(ts)
|
2019-04-25 12:29:28 +00:00
|
|
|
|
2022-07-29 22:47:12 +00:00
|
|
|
ccache_status () {
|
2022-02-08 18:12:04 +00:00
|
|
|
ccache --show-config ||:
|
|
|
|
ccache --show-stats ||:
|
2023-02-09 15:43:24 +00:00
|
|
|
SCCACHE_NO_DAEMON=1 sccache --show-stats ||:
|
2022-02-08 18:12:04 +00:00
|
|
|
}
|
|
|
|
|
2022-05-13 10:50:16 +00:00
|
|
|
[ -O /build ] || git config --global --add safe.directory /build
|
2022-04-13 19:33:34 +00:00
|
|
|
|
2023-06-05 00:58:42 +00:00
|
|
|
if [ "$EXTRACT_TOOLCHAIN_DARWIN" = "1" ]; then
|
2023-06-04 15:06:21 +00:00
|
|
|
mkdir -p /build/cmake/toolchain/darwin-x86_64
|
|
|
|
tar xJf /MacOSX11.0.sdk.tar.xz -C /build/cmake/toolchain/darwin-x86_64 --strip-components=1
|
|
|
|
ln -sf darwin-x86_64 /build/cmake/toolchain/darwin-aarch64
|
2023-06-26 15:28:59 +00:00
|
|
|
|
|
|
|
if [ "$EXPORT_SOURCES_WITH_SUBMODULES" = "1" ]; then
|
2023-06-27 10:32:32 +00:00
|
|
|
cd /build
|
|
|
|
tar --exclude-vcs-ignores --exclude-vcs --exclude build --exclude build_docker --exclude debian --exclude .git --exclude .github --exclude .cache --exclude docs --exclude tests/integration -c . | pigz -9 > /output/source_sub.tar.gz
|
2023-06-26 15:28:59 +00:00
|
|
|
fi
|
2023-06-04 15:06:21 +00:00
|
|
|
fi
|
2019-10-29 17:33:31 +00:00
|
|
|
|
2023-11-17 07:46:45 +00:00
|
|
|
|
2021-04-01 12:12:30 +00:00
|
|
|
# Uncomment to debug ccache. Don't put ccache log in /output right away, or it
|
|
|
|
# will be confusingly packed into the "performance" package.
|
2021-04-07 20:38:48 +00:00
|
|
|
# export CCACHE_LOGFILE=/build/ccache.log
|
|
|
|
# export CCACHE_DEBUG=1
|
2021-03-31 15:38:36 +00:00
|
|
|
|
2022-04-13 19:33:34 +00:00
|
|
|
|
2022-05-13 10:50:16 +00:00
|
|
|
mkdir -p /build/build_docker
|
|
|
|
cd /build/build_docker
|
2019-04-25 23:21:59 +00:00
|
|
|
rm -f CMakeCache.txt
|
2022-04-13 15:45:15 +00:00
|
|
|
|
2023-11-17 07:46:45 +00:00
|
|
|
|
2022-04-21 11:43:24 +00:00
|
|
|
if [ -n "$MAKE_DEB" ]; then
|
|
|
|
rm -rf /build/packages/root
|
2022-07-16 07:50:22 +00:00
|
|
|
# NOTE: this is for backward compatibility with previous releases,
|
|
|
|
# that does not diagnostics tool (only script).
|
|
|
|
if [ -d /build/programs/diagnostics ]; then
|
|
|
|
if [ -z "$SANITIZER" ]; then
|
|
|
|
# We need to check if clickhouse-diagnostics is fine and build it
|
|
|
|
(
|
|
|
|
cd /build/programs/diagnostics
|
|
|
|
make test-no-docker
|
|
|
|
GOARCH="${DEB_ARCH}" CGO_ENABLED=0 make VERSION="$VERSION_STRING" build
|
|
|
|
mv clickhouse-diagnostics ..
|
|
|
|
)
|
|
|
|
else
|
|
|
|
echo -e "#!/bin/sh\necho 'Not implemented for this type of package'" > /build/programs/clickhouse-diagnostics
|
|
|
|
chmod +x /build/programs/clickhouse-diagnostics
|
|
|
|
fi
|
2022-06-30 16:52:59 +00:00
|
|
|
fi
|
2022-04-21 11:43:24 +00:00
|
|
|
fi
|
2022-04-13 19:33:34 +00:00
|
|
|
|
2022-06-30 16:52:59 +00:00
|
|
|
|
2022-07-29 22:47:12 +00:00
|
|
|
ccache_status
|
2022-04-21 15:18:43 +00:00
|
|
|
# clear cache stats
|
|
|
|
ccache --zero-stats ||:
|
|
|
|
|
2023-09-27 15:10:02 +00:00
|
|
|
function check_prebuild_exists() {
|
|
|
|
local path="$1"
|
|
|
|
[ -d "$path" ] && [ "$(ls -A "$path")" ]
|
|
|
|
}
|
|
|
|
|
2023-09-26 13:59:57 +00:00
|
|
|
# Check whether the directory with pre-build scripts exists and not empty.
|
2023-09-27 15:10:02 +00:00
|
|
|
if check_prebuild_exists /build/packages/pre-build
|
|
|
|
then
|
2023-09-26 13:59:57 +00:00
|
|
|
# Execute all commands
|
|
|
|
for file in /build/packages/pre-build/*.sh ;
|
|
|
|
do
|
2023-09-28 09:47:23 +00:00
|
|
|
# The script may want to modify environment variables. Why not to allow it to do so?
|
|
|
|
# shellcheck disable=SC1090
|
2023-09-27 22:48:17 +00:00
|
|
|
source "$file"
|
2023-09-26 13:59:57 +00:00
|
|
|
done
|
2023-09-27 15:10:02 +00:00
|
|
|
else
|
|
|
|
echo "There are no subcommands to execute :)"
|
2023-09-26 13:59:57 +00:00
|
|
|
fi
|
|
|
|
|
2023-09-27 18:50:19 +00:00
|
|
|
# Read cmake arguments into array (possibly empty)
|
|
|
|
# The name of local variable has to be different from the name of environment variable
|
|
|
|
# not to override it. And make it usable for other processes.
|
|
|
|
read -ra CMAKE_FLAGS_ARRAY <<< "${CMAKE_FLAGS:-}"
|
|
|
|
env
|
|
|
|
|
2022-04-13 15:45:15 +00:00
|
|
|
if [ "$BUILD_MUSL_KEEPER" == "1" ]
|
|
|
|
then
|
2022-04-21 12:15:24 +00:00
|
|
|
# build keeper with musl separately
|
2022-12-07 12:14:24 +00:00
|
|
|
# and without rust bindings
|
2023-09-27 18:50:19 +00:00
|
|
|
cmake --debug-trycompile -DENABLE_RUST=OFF -DBUILD_STANDALONE_KEEPER=1 -DENABLE_CLICKHOUSE_KEEPER=1 -DCMAKE_VERBOSE_MAKEFILE=1 -DUSE_MUSL=1 -LA -DCMAKE_TOOLCHAIN_FILE=/build/cmake/linux/toolchain-x86_64-musl.cmake "-DCMAKE_BUILD_TYPE=$BUILD_TYPE" "-DSANITIZE=$SANITIZER" -DENABLE_CHECK_HEAVY_BUILDS=1 "${CMAKE_FLAGS_ARRAY[@]}" ..
|
2022-04-13 15:45:15 +00:00
|
|
|
# shellcheck disable=SC2086 # No quotes because I want it to expand to nothing if empty.
|
|
|
|
ninja $NINJA_FLAGS clickhouse-keeper
|
2022-04-14 13:43:36 +00:00
|
|
|
|
2022-04-14 10:23:09 +00:00
|
|
|
ls -la ./programs/
|
2023-03-11 20:20:20 +00:00
|
|
|
ldd ./programs/clickhouse-keeper ||:
|
2022-04-14 13:43:36 +00:00
|
|
|
|
|
|
|
if [ -n "$MAKE_DEB" ]; then
|
|
|
|
# No quotes because I want it to expand to nothing if empty.
|
|
|
|
# shellcheck disable=SC2086
|
2022-04-21 14:11:43 +00:00
|
|
|
DESTDIR=/build/packages/root ninja $NINJA_FLAGS programs/keeper/install
|
2022-04-14 13:43:36 +00:00
|
|
|
fi
|
2022-04-21 12:15:24 +00:00
|
|
|
rm -f CMakeCache.txt
|
2022-04-13 15:45:15 +00:00
|
|
|
|
2023-09-26 13:59:57 +00:00
|
|
|
# Modify CMake flags, so we won't overwrite standalone keeper with symlinks
|
2023-09-27 18:50:19 +00:00
|
|
|
CMAKE_FLAGS_ARRAY+=(-DBUILD_STANDALONE_KEEPER=0 -DCREATE_KEEPER_SYMLINK=0)
|
2022-04-14 13:43:36 +00:00
|
|
|
fi
|
2021-03-30 11:31:39 +00:00
|
|
|
|
2023-09-26 13:59:57 +00:00
|
|
|
# Build everything
|
2023-09-27 18:50:19 +00:00
|
|
|
cmake --debug-trycompile -DCMAKE_VERBOSE_MAKEFILE=1 -LA "-DCMAKE_BUILD_TYPE=$BUILD_TYPE" "-DSANITIZE=$SANITIZER" -DENABLE_CHECK_HEAVY_BUILDS=1 "${CMAKE_FLAGS_ARRAY[@]}" ..
|
2023-09-26 13:59:57 +00:00
|
|
|
|
2022-02-08 18:12:04 +00:00
|
|
|
# No quotes because I want it to expand to nothing if empty.
|
2022-03-14 13:51:50 +00:00
|
|
|
# shellcheck disable=SC2086 # No quotes because I want it to expand to nothing if empty.
|
2023-07-30 08:27:33 +00:00
|
|
|
ninja $NINJA_FLAGS $BUILD_TARGET
|
2021-03-31 15:43:31 +00:00
|
|
|
|
2022-04-14 10:23:09 +00:00
|
|
|
ls -la ./programs
|
|
|
|
|
2022-07-29 22:47:12 +00:00
|
|
|
ccache_status
|
2022-02-08 18:12:04 +00:00
|
|
|
|
|
|
|
if [ -n "$MAKE_DEB" ]; then
|
|
|
|
# No quotes because I want it to expand to nothing if empty.
|
|
|
|
# shellcheck disable=SC2086
|
2023-02-14 09:28:53 +00:00
|
|
|
DESTDIR=/build/packages/root ninja $NINJA_FLAGS programs/install
|
2022-06-30 16:52:59 +00:00
|
|
|
cp /build/programs/clickhouse-diagnostics /build/packages/root/usr/bin
|
|
|
|
cp /build/programs/clickhouse-diagnostics /output
|
2022-02-08 18:12:04 +00:00
|
|
|
bash -x /build/packages/build
|
|
|
|
fi
|
2021-03-31 15:43:31 +00:00
|
|
|
|
2023-09-05 12:59:32 +00:00
|
|
|
mv ./programs/clickhouse* /output || mv ./programs/*_fuzzer /output
|
|
|
|
[ -x ./programs/self-extracting/clickhouse ] && mv ./programs/self-extracting/clickhouse /output
|
2023-11-11 08:24:26 +00:00
|
|
|
[ -x ./programs/self-extracting/clickhouse-stripped ] && mv ./programs/self-extracting/clickhouse-stripped /output
|
2023-09-05 12:59:32 +00:00
|
|
|
mv ./src/unit_tests_dbms /output ||: # may not exist for some binary builds
|
2023-09-11 19:06:00 +00:00
|
|
|
mv ./programs/*.dict ./programs/*.options ./programs/*_seed_corpus.zip /output ||: # libFuzzer oss-fuzz compatible infrastructure
|
2019-09-20 20:15:42 +00:00
|
|
|
|
2022-05-13 11:36:08 +00:00
|
|
|
prepare_combined_output () {
|
|
|
|
local OUTPUT
|
|
|
|
OUTPUT="$1"
|
|
|
|
|
|
|
|
mkdir -p "$OUTPUT"/config
|
|
|
|
cp /build/programs/server/config.xml "$OUTPUT"/config
|
|
|
|
cp /build/programs/server/users.xml "$OUTPUT"/config
|
|
|
|
cp -r --dereference /build/programs/server/config.d "$OUTPUT"/config
|
|
|
|
}
|
|
|
|
|
2019-12-25 16:08:44 +00:00
|
|
|
# Different files for performance test.
|
2022-05-13 11:36:08 +00:00
|
|
|
if [ "$WITH_PERFORMANCE" == 1 ]
|
2019-12-25 16:08:44 +00:00
|
|
|
then
|
2022-05-13 11:36:08 +00:00
|
|
|
PERF_OUTPUT=/workdir/performance/output
|
|
|
|
mkdir -p "$PERF_OUTPUT"
|
|
|
|
cp -r ../tests/performance "$PERF_OUTPUT"
|
|
|
|
cp -r ../tests/config/top_level_domains "$PERF_OUTPUT"
|
|
|
|
cp -r ../docker/test/performance-comparison/config "$PERF_OUTPUT" ||:
|
|
|
|
for SRC in /output/clickhouse*; do
|
|
|
|
# Copy all clickhouse* files except packages and bridges
|
|
|
|
[[ "$SRC" != *.* ]] && [[ "$SRC" != *-bridge ]] && \
|
|
|
|
cp -d "$SRC" "$PERF_OUTPUT"
|
|
|
|
done
|
|
|
|
if [ -x "$PERF_OUTPUT"/clickhouse-keeper ]; then
|
|
|
|
# Replace standalone keeper by symlink
|
|
|
|
ln -sf clickhouse "$PERF_OUTPUT"/clickhouse-keeper
|
|
|
|
fi
|
2020-03-11 14:29:34 +00:00
|
|
|
|
2022-05-13 11:36:08 +00:00
|
|
|
cp -r ../docker/test/performance-comparison "$PERF_OUTPUT"/scripts ||:
|
|
|
|
prepare_combined_output "$PERF_OUTPUT"
|
2020-07-14 15:11:49 +00:00
|
|
|
|
|
|
|
# We have to know the revision that corresponds to this binary build.
|
|
|
|
# It is not the nominal SHA from pull/*/head, but the pull/*/merge, which is
|
|
|
|
# head merged to master by github, at some point after the PR is updated.
|
|
|
|
# There are some quirks to consider:
|
|
|
|
# - apparently the real SHA is not recorded in system.build_options;
|
|
|
|
# - it can change at any time as github pleases, so we can't just record
|
|
|
|
# the SHA and use it later, it might become inaccessible;
|
|
|
|
# - CI has an immutable snapshot of repository that it uses for all checks
|
|
|
|
# for a given nominal SHA, but it is not accessible outside Yandex.
|
|
|
|
# This is why we add this repository snapshot from CI to the performance test
|
|
|
|
# package.
|
2022-05-13 11:36:08 +00:00
|
|
|
mkdir "$PERF_OUTPUT"/ch
|
2023-10-17 19:08:55 +00:00
|
|
|
# Copy .git only, but skip modules, using tar
|
|
|
|
tar c -C /build/ --exclude='.git/modules/**' .git | tar x -C "$PERF_OUTPUT"/ch
|
|
|
|
# Create branch pr and origin/master to have them for the following performance comparison
|
|
|
|
git -C "$PERF_OUTPUT"/ch branch pr
|
2023-11-13 17:07:25 +00:00
|
|
|
git -C "$PERF_OUTPUT"/ch fetch --no-tags --no-recurse-submodules --depth 50 origin master:origin/master
|
2023-10-17 19:08:55 +00:00
|
|
|
# Clean remote, to not have it stale
|
|
|
|
git -C "$PERF_OUTPUT"/ch remote | xargs -n1 git -C "$PERF_OUTPUT"/ch remote remove
|
|
|
|
# And clean all tags
|
2023-11-13 18:38:11 +00:00
|
|
|
echo "Deleting $(git -C "$PERF_OUTPUT"/ch tag | wc -l) tags"
|
|
|
|
git -C "$PERF_OUTPUT"/ch tag | xargs git -C "$PERF_OUTPUT"/ch tag -d >/dev/null
|
2022-05-13 11:36:08 +00:00
|
|
|
git -C "$PERF_OUTPUT"/ch reset --soft pr
|
|
|
|
git -C "$PERF_OUTPUT"/ch log -5
|
|
|
|
(
|
|
|
|
cd "$PERF_OUTPUT"/..
|
2023-01-01 20:17:43 +00:00
|
|
|
tar -cv --zstd -f /output/performance.tar.zst output
|
2022-05-13 11:36:08 +00:00
|
|
|
)
|
2019-12-25 16:08:44 +00:00
|
|
|
fi
|
|
|
|
|
2023-01-02 01:06:11 +00:00
|
|
|
# May be set for performance test.
|
2019-12-23 18:24:33 +00:00
|
|
|
if [ "" != "$COMBINED_OUTPUT" ]
|
2019-09-20 20:15:42 +00:00
|
|
|
then
|
2022-05-13 11:36:08 +00:00
|
|
|
prepare_combined_output /output
|
2023-01-01 20:17:43 +00:00
|
|
|
tar -cv --zstd -f "$COMBINED_OUTPUT.tar.zst" /output
|
2019-09-20 20:15:42 +00:00
|
|
|
rm -r /output/*
|
2023-01-01 20:17:43 +00:00
|
|
|
mv "$COMBINED_OUTPUT.tar.zst" /output
|
2019-09-20 20:15:42 +00:00
|
|
|
fi
|
2021-03-31 15:43:31 +00:00
|
|
|
|
2022-07-29 22:47:12 +00:00
|
|
|
ccache_status
|
|
|
|
ccache --evict-older-than 1d
|
2021-08-24 00:09:19 +00:00
|
|
|
|
2021-03-31 23:51:47 +00:00
|
|
|
if [ "${CCACHE_DEBUG:-}" == "1" ]
|
2021-03-31 21:54:45 +00:00
|
|
|
then
|
2021-04-01 12:46:55 +00:00
|
|
|
find . -name '*.ccache-*' -print0 \
|
2021-04-01 18:02:35 +00:00
|
|
|
| tar -c -I pixz -f /output/ccache-debug.txz --null -T -
|
2021-03-31 21:54:45 +00:00
|
|
|
fi
|
2021-03-31 15:43:31 +00:00
|
|
|
|
2021-04-01 12:12:30 +00:00
|
|
|
if [ -n "$CCACHE_LOGFILE" ]
|
2021-03-31 21:54:45 +00:00
|
|
|
then
|
|
|
|
# Compress the log as well, or else the CI will try to compress all log
|
|
|
|
# files in place, and will fail because this directory is not writable.
|
2021-04-01 17:00:08 +00:00
|
|
|
tar -cv -I pixz -f /output/ccache.log.txz "$CCACHE_LOGFILE"
|
2021-03-31 21:54:45 +00:00
|
|
|
fi
|
2022-04-22 11:37:08 +00:00
|
|
|
|
|
|
|
ls -l /output
|