Skip to content

Commit

Permalink
add CodeQuality.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
maiadegraaf committed Jun 27, 2024
1 parent ed1e414 commit fdccb3c
Show file tree
Hide file tree
Showing 4 changed files with 450 additions and 3 deletions.
95 changes: 95 additions & 0 deletions .github/workflows/CodeQuality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: CodeQuality
on:
workflow_dispatch:
repository_dispatch:
push:
branches:
- '**'
- '!main'
- '!feature'
paths-ignore:
- '**.md'
- '.github/patches/duckdb-wasm/**'
- '.github/workflows/**'
- '!.github/workflows/lcov_exclude'
- '!.github/workflows/CodeQuality.yml'

pull_request:
types: [opened, reopened, ready_for_review]
paths-ignore:
- '**.md'
- '.github/patches/duckdb-wasm/**'
- '.github/workflows/**'
- '!.github/workflows/lcov_exclude'
- '!.github/workflows/CodeQuality.yml'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref || '' }}-${{ github.base_ref || '' }}-${{ github.ref != 'refs/heads/main' || github.sha }}
cancel-in-progress: true

env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}

jobs:
format-check:
name: Format Check
runs-on: ubuntu-20.04

env:
CC: gcc-10
CXX: g++-10
GEN: ninja

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install
shell: bash
run: sudo apt-get update -y -qq && sudo apt-get install -y -qq ninja-build clang-format-11 && sudo pip3 install cmake-format black

- name: Format Check
shell: bash
run: |
clang-format --version
clang-format --dump-config
black --version
make format-check-silent
tidy-check:
name: Tidy Check
runs-on: ubuntu-22.04
needs: format-check

env:
CC: gcc-10
CXX: g++-10
GEN: ninja
TIDY_THREADS: 4

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install
shell: bash
run: sudo apt-get update -y -qq && sudo apt-get install -y -qq ninja-build clang-tidy && sudo pip3 install pybind11[global]

- name: Setup Ccache
uses: hendrikmuhs/ccache-action@main
with:
key: ${{ github.job }}
save: ${{ github.ref == 'refs/heads/main' || github.repository != 'duckdb/duckdb' }}
- name: Download clang-tidy-cache
shell: bash
run: |
set -e
curl -Lo /tmp/clang-tidy-cache https://github.com/ejfitzgerald/clang-tidy-cache/releases/download/v0.4.0/clang-tidy-cache-linux-amd64
md5sum /tmp/clang-tidy-cache | grep 880b290d7bbe7c1fb2a4f591f9a86cc1
chmod +x /tmp/clang-tidy-cache
- name: Tidy Check
shell: bash
run: make tidy-check TIDY_BINARY=/tmp/clang-tidy-cache
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ set_target_properties(duckdb_odbc PROPERTIES DEFINE_SYMBOL "DUCKDB_ODBC_API")
target_link_libraries(duckdb_odbc ${LINK_LIB_LIST} )
target_link_libraries(duckdb_odbc Threads::Threads ${DUCKDB_SYSTEM_LIBS})

if (CLANG_TIDY)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDUCKDB_CLANG_TIDY")
endif()

if(NOT CLANG_TIDY)
add_subdirectory(test)
endif()
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
.PHONY: release debug test clean format tidy tidy



GENERATOR=
ifeq ($(GEN),ninja)
GENERATOR=-G "Ninja"
Expand Down Expand Up @@ -30,10 +28,13 @@ format-fix:
rm -rf src/amalgamation/*
python3 scripts/format.py --all --fix --noconfirm

format-check-silent:
python3 scripts/format.py --all --check --silent

tidy-check:
mkdir -p ./build/tidy && \
cd build/tidy && \
cmake -DCLANG_TIDY=1 -DDISABLE_UNITY=1 -DBUILD_EXTENSIONS=parquet -DBUILD_PYTHON_PKG=TRUE -DBUILD_SHELL=0 ../.. && \
cmake -DCLANG_TIDY=1 ../.. && \
python3 ../../scripts/run-clang-tidy.py -quiet ${TIDY_THREAD_PARAMETER} ${TIDY_BINARY_PARAMETER}

tidy-fix:
Expand Down
Loading

0 comments on commit fdccb3c

Please sign in to comment.