Update shellcheck to the latest release

This commit is contained in:
Mikhail f. Shiryaev 2024-02-29 11:29:14 +01:00
parent f40e25f5c3
commit 82a8308198
No known key found for this signature in database
GPG Key ID: 4B02ED204C7D93F4
7 changed files with 29 additions and 11 deletions

View File

@ -16,7 +16,6 @@ RUN apt-get update && env DEBIAN_FRONTEND=noninteractive apt-get install --yes \
moreutils \
python3-fuzzywuzzy \
python3-pip \
shellcheck \
yamllint \
locales \
&& pip3 install black==23.1.0 boto3 codespell==2.2.1 mypy==1.3.0 PyGithub unidiff pylint==2.6.2 \
@ -30,6 +29,19 @@ ENV LC_ALL en_US.UTF-8
# Architecture of the image when BuildKit/buildx is used
ARG TARGETARCH
ARG SHELLCHECK_VERSION=0.9.0
RUN arch=${TARGETARCH:-amd64} \
&& case $arch in \
amd64) sarch=x86_64 ;; \
arm64) sarch=aarch64 ;; \
esac \
&& curl -L \
"https://github.com/koalaman/shellcheck/releases/download/v${SHELLCHECK_VERSION}/shellcheck-v${SHELLCHECK_VERSION}.linux.${sarch}.tar.xz" \
| tar xJ --strip=1 -C /tmp \
&& mv /tmp/shellcheck /usr/bin \
&& rm -rf /tmp/*
# Get act and actionlint from releases
RUN arch=${TARGETARCH:-amd64} \
&& case $arch in \

View File

@ -9,7 +9,7 @@ $CLICKHOUSE_CLIENT --query="DROP TABLE IF EXISTS json_as_string";
$CLICKHOUSE_CLIENT --query="CREATE TABLE json_as_string (field String) ENGINE = Memory";
echo '
echo -e '
{
"id" : 1,
"date" : "01.01.2020",
@ -44,7 +44,7 @@ echo '
}
}' | $CLICKHOUSE_CLIENT --query="INSERT INTO json_as_string FORMAT JSONAsString";
echo '
echo -e '
[
{
"id" : 1,

View File

@ -7,7 +7,7 @@ CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
$CLICKHOUSE_CLIENT --query="DROP TABLE IF EXISTS line_as_string1";
$CLICKHOUSE_CLIENT --query="CREATE TABLE line_as_string1(field String) ENGINE = Memory";
echo '"id" : 1,
echo -e '"id" : 1,
"date" : "01.01.2020",
"string" : "123{{{\"\\",
"array" : [1, 2, 3],
@ -26,7 +26,9 @@ $CLICKHOUSE_CLIENT --query="create table line_as_string2(
$CLICKHOUSE_CLIENT --query="INSERT INTO line_as_string2(c) values ('ClickHouse')";
echo 'ClickHouse is a `fast` #open-source# (OLAP) database "management" :system:' | $CLICKHOUSE_CLIENT --query="INSERT INTO line_as_string2(c) FORMAT LineAsString";
# Shellcheck thinks `fast` is a shell expansion
# shellcheck disable=SC2016
echo -e 'ClickHouse is a `fast` #open-source# (OLAP) database "management" :system:' | $CLICKHOUSE_CLIENT --query="INSERT INTO line_as_string2(c) FORMAT LineAsString";
$CLICKHOUSE_CLIENT --query="SELECT * FROM line_as_string2 order by c";
$CLICKHOUSE_CLIENT --query="DROP TABLE line_as_string2"

View File

@ -45,11 +45,13 @@ query_id=$$-$RANDOM-$SECONDS
${CLICKHOUSE_CLIENT} --user=test_01541 --max_block_size=1 --format Null --query_id $query_id -q 'SELECT sleepEachRow(1) FROM numbers(600)' &
# trap
sleep_query_pid=$!
# Shellcheck wrongly process "trap" https://www.shellcheck.net/wiki/SC2317
# shellcheck disable=SC2317
function cleanup()
{
echo 'KILL sleep'
# if the timeout will not be enough, it will trigger "No such process" error/message
kill $sleep_query_pid
kill "$sleep_query_pid"
# waiting for a query to finish
while ${CLICKHOUSE_CLIENT} -q "SELECT query_id FROM system.processes WHERE query_id = '$query_id'" | grep -xq "$query_id"; do
sleep 0.1

View File

@ -47,7 +47,7 @@ function main()
{
# retries, since there is no guarantee that every time query will take ~0.4 second.
local retries=20 i=0
while [ "$(test_query_duration_ms | xargs)" != '1 1' ] && [[ $i < $retries ]]; do
while [ "$(test_query_duration_ms | xargs)" != '1 1' ] && (( i < retries )); do
((++i))
done
}

View File

@ -18,10 +18,12 @@ CLICKHOUSE_WATCHDOG_ENABLE=0 $CLICKHOUSE_SERVER_BINARY "${server_opts[@]}" >& cl
server_pid=$!
trap cleanup EXIT
# Shellcheck wrongly process "trap" https://www.shellcheck.net/wiki/SC2317
# shellcheck disable=SC2317
function cleanup()
{
kill -9 $server_pid
kill -9 $client_pid
kill -9 "$server_pid"
kill -9 "$client_pid"
echo "Test failed. Server log:"
cat clickhouse-server.log

View File

@ -3,7 +3,7 @@ ROOT_PATH=$(git rev-parse --show-toplevel)
NPROC=$(($(nproc) + 3))
# Check sh tests with Shellcheck
find "$ROOT_PATH/tests/queries/"{0_stateless,1_stateful} -name '*.sh' -print0 | \
xargs -0 -P "$NPROC" -n 1 shellcheck --check-sourced --external-sources --source-path=SCRIPTDIR \
xargs -0 -P "$NPROC" -n 20 shellcheck --check-sourced --external-sources --source-path=SCRIPTDIR \
--severity info --exclude SC1071,SC2086,SC2016
# Check docker scripts with shellcheck
@ -11,4 +11,4 @@ find "$ROOT_PATH/tests/queries/"{0_stateless,1_stateful} -name '*.sh' -print0 |
find "$ROOT_PATH/docker" -type f -exec file -F' ' --mime-type {} + | \
awk '$2=="text/x-shellscript" {print $1}' | \
grep -v "compare.sh" | \
xargs -P "$NPROC" -n 1 shellcheck --external-sources --source-path=SCRIPTDIR
xargs -P "$NPROC" -n 20 shellcheck --external-sources --source-path=SCRIPTDIR