Skip to content

Commit 486b7be

Browse files
authored
Make clang-tidy a separate check that runs on ARM (#10080)
I want it to run on all the code, tests included, and in Debug mode. Currently it's running on some very fast Release build and does not cover everything. The check seems to be too slow to run it as part of a regresscheck workflow, so just make it a separate job.
1 parent 656740b commit 486b7be

15 files changed

Lines changed: 118 additions & 38 deletions

File tree

.github/gh_matrix_builder.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,15 +221,11 @@ def macos_config(overrides):
221221
)
222222
)
223223

224-
# Test latest postgres release without telemetry. Also run clang-tidy on it
225-
# because it's the fastest one.
224+
# Test latest postgres release without telemetry.
226225
m["include"].append(
227226
build_without_telemetry(
228227
{
229228
"pg": PG18_LATEST,
230-
"cc": "clang",
231-
"cxx": "clang++",
232-
"tsdb_build_args": "-DLINTER=ON -DWARNINGS_AS_ERRORS=ON",
233229
}
234230
)
235231
)

.github/workflows/code_style.yaml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,87 @@ jobs:
112112
echo '::add-matcher::.github/problem-matchers/grep.json'
113113
! grep '[f]ixme' -niR ./* .github/workflows/*
114114
115+
clang_tidy:
116+
name: clang-tidy
117+
runs-on: timescaledb-runner-arm64
118+
env:
119+
LLVM_VER: 17
120+
steps:
121+
- name: Install Linux Dependencies
122+
timeout-minutes: 15
123+
run: |
124+
gpg --batch --keyserver hkp://keyserver.ubuntu.com --recv-keys 15CF4D18AF4F7421
125+
gpg --batch --export --export-options export-minimal --armor 15CF4D18AF4F7421 | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc > /dev/null
126+
127+
. /etc/os-release
128+
echo "deb https://apt.llvm.org/${VERSION_CODENAME}/ llvm-toolchain-${VERSION_CODENAME}-${LLVM_VER} main" | sudo tee /etc/apt/sources.list.d/llvm.list >/dev/null
129+
sudo apt-get update
130+
131+
sudo apt-get install clang-${LLVM_VER} lld-${LLVM_VER} clang-tidy-${LLVM_VER}
132+
133+
sudo update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-${LLVM_VER} 100
134+
sudo update-alternatives --set clang-tidy /usr/bin/clang-tidy-${LLVM_VER}
135+
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-${LLVM_VER} 100
136+
sudo update-alternatives --set clang /usr/bin/clang-${LLVM_VER}
137+
138+
- name: Checkout source
139+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
140+
141+
- name: Read configuration
142+
id: config
143+
run: python -B .github/gh_config_reader.py
144+
145+
# We are going to rebuild Postgres weekly, so that it doesn't suddenly break
146+
# ages after the original problem.
147+
- name: Get date for build caching
148+
id: get-date
149+
run: echo "date=$(date +"%V")" >> $GITHUB_OUTPUT
150+
151+
- name: Get key for caching
152+
id: cache-key
153+
run: echo "key=postgresql-tidy-${{ steps.get-date.outputs.date }}-${{ hashFiles('.github/**') }}" >> $GITHUB_OUTPUT
154+
155+
- name: Restore PostgreSQL Cache
156+
id: restore-postgresql
157+
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
158+
with:
159+
path: install
160+
key: ${{ steps.cache-key.outputs.key }}
161+
162+
- name: Build PostgreSQL
163+
if: steps.restore-postgresql.outputs.cache-hit != 'true'
164+
run: |
165+
wget -q --tries=6 --waitretry=15 -O postgresql.tar.bz2 \
166+
https://ftp.postgresql.org/pub/source/v${{ steps.config.outputs.PG16_LATEST }}/postgresql-${{ steps.config.outputs.PG16_LATEST }}.tar.bz2
167+
mkdir -p pg build-pg install
168+
tar --extract --file postgresql.tar.bz2 --directory pg --strip-components 1
169+
cd build-pg
170+
CC=clang-${LLVM_VER} ../pg/configure --prefix=$(readlink -e "$(pwd)/../install") --with-openssl \
171+
--without-readline --without-zlib --without-libxml --without-llvm \
172+
--enable-cassert --enable-debug
173+
make -j$(getconf _NPROCESSORS_ONLN) install
174+
175+
- name: Save PostgreSQL Cache
176+
if: steps.restore-postgresql.outputs.cache-matched-key == ''
177+
uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
178+
with:
179+
path: install
180+
key: ${{ steps.cache-key.outputs.key }}
181+
182+
- name: Upload config.log
183+
if: always()
184+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
185+
with:
186+
name: config.log for PostgreSQL
187+
path: build-pg/config.log
188+
189+
- name: Run clang-tidy
190+
run: |
191+
cmake -S . -B build-ts-tidy -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=clang-${LLVM_VER} \
192+
-DPG_PATH=install -DLINTER=ON -DWARNINGS_AS_ERRORS=ON
193+
make -C build-ts-tidy -j8 -k
194+
195+
115196
python_checks:
116197
name: Check Python code in tree
117198
runs-on: timescaledb-runner-arm64

.github/workflows/linux-build-and-test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ jobs:
179179
- name: Build TimescaleDB
180180
run: |
181181
# Show the actual architecture this CI runner has
182-
"$CC" -march=native -E -v - </dev/null 2>&1 | grep cc1
182+
gcc -march=native -E -v - </dev/null 2>&1 | grep cc1
183183
184184
./bootstrap -DCMAKE_BUILD_TYPE="${{ matrix.build_type }}" \
185185
-DPG_SOURCE_DIR=$HOME/$PG_SRC_DIR -DPG_PATH=$HOME/$PG_INSTALL_DIR \

CMakeLists.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ cmake_minimum_required(VERSION 3.15)
22

33
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
44

5+
include(CMakeDependentOption)
56
include(CheckCCompilerFlag)
67
include(CheckSymbolExists)
7-
include(GitCommands)
88
include(GenerateScripts)
9-
include(CMakeDependentOption)
9+
include(GitCommands)
1010

1111
option(APACHE_ONLY "only compile apache code" off)
1212
# This requires all tests to run. This defaults to OFF but can be enabled to
@@ -542,16 +542,18 @@ if(LINTER)
542542
CONCAT
543543
CMAKE_C_CLANG_TIDY
544544
"${CLANG_TIDY}"
545-
";--checks=clang-diagnostic-*,clang-analyzer-*"
545+
";--checks=clang-analyzer-*"
546546
",-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling"
547547
",-clang-analyzer-deadcode.DeadStores"
548+
",clang-diagnostic-*"
548549
",bugprone-*"
549550
",-bugprone-branch-clone"
550551
",-bugprone-easily-swappable-parameters"
551552
",-bugprone-implicit-widening-of-multiplication-result"
552553
",-bugprone-narrowing-conversions"
553554
",-bugprone-reserved-identifier"
554555
",-bugprone-suspicious-include"
556+
",misc-header-include-cycle"
555557
",readability-*"
556558
",-readability-avoid-const-params-in-decls"
557559
",-readability-braces-around-statements"
@@ -564,7 +566,6 @@ if(LINTER)
564566
",-readability-math-missing-parentheses"
565567
",-readability-non-const-parameter"
566568
",-readability-redundant-casting"
567-
",misc-header-include-cycle"
568569
"${CLANG_TIDY_EXTRA_OPTS}")
569570
if(WARNINGS_AS_ERRORS)
570571
set(CMAKE_C_CLANG_TIDY "${CMAKE_C_CLANG_TIDY};--warnings-as-errors=*")

src/guc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ DebugRequireOption ts_guc_debug_require_vector_qual = DRO_Allow;
212212
DebugRequireOption ts_guc_debug_require_vector_agg = DRO_Allow;
213213
#endif
214214

215-
DebugRequireOption ts_guc_debug_require_batch_sorted_merge = false;
215+
DebugRequireOption ts_guc_debug_require_batch_sorted_merge = DRO_Allow;
216216

217217
bool ts_guc_debug_compression_path_info = false;
218218
bool ts_guc_enable_rowlevel_compression_locking = false;

test/expected/c_unit_tests.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ SELECT test.compression_settings();
5555

5656

5757
SELECT test.chunk_stats();
58-
NOTICE: Eviction test completed: 9216 evictions, 1024 slots, average lifespan 1023.53, lifespan stddev 167.91, min lifespan 138, max lifespan 1975
58+
NOTICE: Eviction test completed: 9216 evictions, 1024 slots, average lifespan 1024, lifespan stddev 165, min lifespan 138, max lifespan 1975
5959
chunk_stats
6060
-------------
6161

test/src/test_jsonb_utils.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
*/
66

77
#include <postgres.h>
8+
9+
#include <fmgr.h>
10+
#include <funcapi.h>
11+
#include <utils/fmgrprotos.h>
12+
813
#include "jsonb_utils.h"
914
#include "test_utils.h"
1015
#include "ts_catalog/compression_settings.h"
1116
#include "utils/jsonb.h"
12-
#include <fmgr.h>
13-
#include <funcapi.h>
14-
15-
// Declare jsonb_in explicitly
16-
extern Datum jsonb_in(PG_FUNCTION_ARGS);
1717

1818
const char *
1919
jsonb_to_cstring(Jsonb *jsonb)

test/src/test_stats.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ test_eviction()
6868
Oid uncompressed_relid = 54321;
6969
int32 slot_indices[NUM_SLOTS] = { 0 };
7070
uint64 slot_seqno[NUM_SLOTS] = { 0 };
71-
uint64 sum_lifespan = 0;
71+
double sum_lifespan = 0;
7272
double sumsq_lifespan = 0;
7373
int32 num_evictions = 0;
7474
uint64 min_lifespan = UINT64_MAX;
@@ -119,8 +119,8 @@ test_eviction()
119119
}
120120

121121
elog(NOTICE,
122-
"Eviction test completed: %d evictions, %d slots, average lifespan %.2f, lifespan stddev "
123-
"%.2f, min lifespan %d, max lifespan %d",
122+
"Eviction test completed: %d evictions, %d slots, average lifespan %.0f, lifespan stddev "
123+
"%.0f, min lifespan %d, max lifespan %d",
124124
num_evictions,
125125
NUM_SLOTS,
126126
(double) sum_lifespan / num_evictions,

test/src/test_with_clause_parser.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ TS_TEST_FN(ts_test_with_clause_parse)
347347

348348
values = palloc0(sizeof(*values) * funcctx->tuple_desc->natts);
349349
nulls = palloc(sizeof(*nulls) * funcctx->tuple_desc->natts);
350-
memset(nulls, true, sizeof(*nulls) * funcctx->tuple_desc->natts);
350+
memset(nulls, 1, sizeof(*nulls) * funcctx->tuple_desc->natts);
351351

352352
values[0] = CStringGetTextDatum(test_args[result->i].arg_names[0]);
353353
nulls[0] = false;

tsl/src/nodes/columnar_scan/batch_queue.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,4 @@ typedef struct BatchQueue
3232
const BatchQueueFunctions *funcs;
3333
} BatchQueue;
3434

35-
#include "batch_queue_fifo.h"
36-
#include "batch_queue_heap.h"
37-
3835
#endif /* TIMESCALEDB_BATCH_QUEUE_H */

0 commit comments

Comments
 (0)