@@ -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
0 commit comments