Skip to content

Merge pull request #456 from LASTRADA-Software/copilot/refactor-sqlst… #2378

Merge pull request #456 from LASTRADA-Software/copilot/refactor-sqlst…

Merge pull request #456 from LASTRADA-Software/copilot/refactor-sqlst… #2378

Workflow file for this run

name: Build
permissions:
contents: write
on:
merge_group:
push:
paths-ignore:
- "mkdocs.yml"
- "*.sh"
branches:
- master
pull_request:
paths-ignore:
- "docs/**"
- "LICENSE.txt"
- "mkdocs.yml"
- "*.md"
branches:
- master
concurrency:
group: build-${{ github.ref }}
cancel-in-progress: true
env:
CTEST_OUTPUT_ON_FAILURE: 1
SCCACHE_GHA_ENABLED: "true"
jobs:
# {{{ Common checks
check_PR_TODOs:
name: "Check PR-TODOs"
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
- name: "Checking for open PR-related TODO items"
run: ./scripts/check-pr-todos.sh
check_clang_format:
name: "Check C++ style"
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v2
with:
#persist-credentials: true
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
# token: ${{ secrets.CLANG_FORMAT_PAT }}
- uses: DoozyX/clang-format-lint-action@v0.20
with:
source: "."
exclude: "src/examples/test_chinook/entities"
extensions: "h,hpp,cpp"
clangFormatVersion: 20
style: file
inplace: True
# does not work for now
# - uses: EndBug/add-and-commit@v9
# if: github.event.pull_request.head.repo.full_name == github.repository
# with:
# message: 'Committing clang-format changes'
# default_author: github_actions
check_docs:
name: "Check documentation coverage"
runs-on: ubuntu-24.04
if: github.ref != 'refs/heads/master'
steps:
- uses: actions/checkout@v6
- name: Fetch tags
run: git fetch --prune --unshallow --tags
- name: "update APT database"
run: sudo apt -q update
- name: "install dependencies"
run: sudo apt install -y cmake ninja-build doxygen g++-14 catch2 unixodbc-dev sqlite3 libsqlite3-dev uuid-dev libyaml-cpp-dev libzip-dev
- name: "cmake"
run: cmake --preset linux-gcc-release -D LIGHTWEIGHT_BUILD_DOCUMENTATION=ON -D LIGHTWEIGHT_DOCS_WARN_AS_ERROR=ON
- name: "check documentation"
run: cmake --build --preset linux-gcc-release --target doc
check_clang_tidy:
name: "Check clang-tidy"
runs-on: ubuntu-24.04
if: github.ref != 'refs/heads/master'
steps:
- uses: actions/checkout@v6
- name: Fetch tags
run: git fetch --prune --unshallow --tags
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: "ccache-ubuntu2404-clang-tidy"
max-size: 256M
- name: "update APT database"
run: sudo apt -q update
- name: Install clang
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 21
sudo apt -qy install clang-tidy-21 clang-tools-21
which clang-tidy-21
which run-clang-tidy-21
- name: "install dependencies"
run: sudo apt install -y cmake ninja-build catch2 unixodbc-dev sqlite3 libsqlite3-dev libsqliteodbc uuid-dev libyaml-cpp-dev gcc-14 libtbb-dev libzip-dev
- name: "cmake"
run: |
cmake --preset linux-clang-debug \
-D CMAKE_CXX_COMPILER=clang++-21 \
-D CMAKE_C_COMPILER=clang-21 \
-B build
- name: "run clang-tidy"
run: run-clang-tidy-21 -p ./build -clang-tidy-binary clang-tidy-21 -config-file .clang-tidy -header-filter='^(?!(.*/)?stdexec-src/|(.*/)?libzip-src/).*$' -source-filter='^(?!.*_deps/).*$'
# }}}
# {{{ Windows
windows:
strategy:
fail-fast: false
matrix:
preset: ["windows-cl-debug", "windows-clangcl-debug"]
name: "Windows-${{ matrix.preset }}"
runs-on: windows-2025
steps:
- uses: actions/checkout@v6
- name: Fetch tags
run: git fetch --prune --unshallow --tags
- name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.3
- name: "vcpkg: Install dependencies"
run: |
git clone https://github.com/microsoft/vcpkg.git ${{ runner.workspace }}\vcpkg
${{ runner.workspace }}\vcpkg\bootstrap-vcpkg.bat
- name: "Install SQLite3 for Win32"
run: |
choco install sqliteodbc
choco install sqlite
- name: "Install ninja"
run: |
choco install ninja
- name: "Generate build files"
run: cmake --preset ${{ matrix.preset }}
env:
VCPKG_ROOT: "${{ runner.workspace }}/vcpkg"
- name: "Build"
run: cmake --build --preset ${{ matrix.preset }}
- name: Setup SQL Server
if: ${{ endsWith(matrix.preset, 'windows-cl-debug') }}
shell: powershell
run: |
sqllocaldb info
sqllocaldb start MSSQLLocalDB
sqlcmd -S "(LocalDB)\MSSQLLocalDB" -Q "CREATE DATABASE TestDB;"
sqlcmd -S "(LocalDB)\MSSQLLocalDB" -Q "SELECT name FROM sys.databases WHERE name = 'TestDB';"
- name: Create .test-env.yml
if: ${{ endsWith(matrix.preset, 'windows-cl-debug') }}
shell: powershell
run: |
@"
ODBC_CONNECTION_STRING:
mssql: "Driver={ODBC Driver 17 for SQL Server};Server=(LocalDB)\\MSSQLLocalDB;Database=TestDB;Trusted_Connection=Yes;"
"@ | Out-File -FilePath .test-env.yml -Encoding utf8
- name: "Test"
if: ${{ endsWith(matrix.preset, 'windows-cl-debug') }}
run: ./out/build/${{ matrix.preset }}/target/Debug/LightweightTest.exe --test-env=mssql --trace-sql --trace-odbc
# }}}
# {{{ Ubuntu build CC matrix
ubuntu_build_cc_matrix:
strategy:
fail-fast: false
matrix:
cxx: [23]
build_type: ["RelWithDebInfo"]
compiler: ["GCC 14", "Clang 19"]
name: "Ubuntu Linux 24.04 (${{ matrix.compiler }}, C++${{ matrix.cxx }})"
runs-on: ubuntu-24.04
outputs:
id: "${{ matrix.compiler }} (C++${{ matrix.cxx }}, ${{ matrix.build_type }})"
steps:
- uses: actions/checkout@v6
- name: Fetch tags
run: git fetch --prune --unshallow --tags
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: "ccache-ubuntu2404-${{ matrix.compiler }}-${{ matrix.cxx }}-${{ matrix.build_type }}"
max-size: 256M
- name: "update APT database"
run: sudo apt -q update
- name: "Set up output var: CC_VERSION"
id: extract_matrix
run: |
CC_VERSION=$( echo "${{ matrix.compiler }}" | awk '{ print $2; }')
echo "CC_VERSION=${CC_VERSION}" >> "$GITHUB_OUTPUT"
- name: "install dependencies"
run: sudo apt install -y cmake ninja-build catch2 unixodbc-dev sqlite3 libsqlite3-dev libsqliteodbc uuid-dev libyaml-cpp-dev libtbb-dev libzip-dev
- name: Install GCC
if: ${{ startsWith(matrix.compiler, 'GCC') }}
run: sudo apt install -y g++-${{ steps.extract_matrix.outputs.CC_VERSION }}
- name: Install Clang
if: ${{ startsWith(matrix.compiler, 'Clang') }}
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh ${{ steps.extract_matrix.outputs.CC_VERSION }}
# What about: libc++-dev libc++abi-dev
sudo apt-get install -y \
clang-format-${{ steps.extract_matrix.outputs.CC_VERSION }} \
clang-${{ steps.extract_matrix.outputs.CC_VERSION }}
- name: "cmake"
run: |
CC_NAME=$(echo "${{ matrix.compiler }}" | awk '{ print tolower($1); }')
CC_VER=$( echo "${{ matrix.compiler }}" | awk '{ print $2; }')
test "${{ matrix.compiler }}" = "GCC 8" && EXTRA_CMAKE_FLAGS="$EXTRA_CMAKE_FLAGS -DPEDANTIC_COMPILER_WERROR=ON"
test "${CC_NAME}" = "gcc" && CC_EXE="g++"
if [[ "${CC_NAME}" = "clang" ]]; then
CC_EXE="clang++"
# CMAKE_CXX_FLAGS="-stdlib=libc++"
# CMAKE_EXE_LINKER_FLAGS="-stdlib=libc++ -lc++abi"
# EXTRA_CMAKE_FLAGS="$EXTRA_CMAKE_FLAGS -DENABLE_TIDY=ON"
# EXTRA_CMAKE_FLAGS="$EXTRA_CMAKE_FLAGS -DPEDANTIC_COMPILER_WERROR=OFF"
fi
cmake \
$EXTRA_CMAKE_FLAGS \
-DCMAKE_BUILD_TYPE="${{ matrix.build_type }}" \
-DCMAKE_CXX_STANDARD=${{ matrix.cxx }} \
-DCMAKE_CXX_COMPILER="${CC_EXE}-${CC_VER}" \
-DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS}" \
-DCMAKE_EXE_LINKER_FLAGS="${CMAKE_EXE_LINKER_FLAGS}" \
-DCMAKE_INSTALL_PREFIX="/usr/local" \
-DPEDANTIC_COMPILER_WERROR=OFF \
-DLIGHTWEIGHT_BUILD_SHARED=ON \
--preset linux-gcc-release
- name: "build"
run: cmake --build --preset linux-gcc-release -- -j3
# NB: Don't run the tests here, as we want to run them later for each individual database
# - name: "tests"
# run: ctest --preset linux-gcc-release
# NB: Don't run valgrind test here, as we want to run them later for each individual database
# - name: "Run tests through valgrind (without model tests)"
# run: |
# valgrind \
# --error-exitcode=1 \
# --leak-check=full \
# --leak-resolution=high \
# --num-callers=64 \
# out/build/linux-gcc-release/src/tests/LightweightTest '~[model]'
- name: "package tar.gz"
run: |
cpack --preset linux-gcc-release
cp out/package/linux-gcc-debug/Lightweight-*-Linux.tar.gz ./Lightweight-Linux-CI.tar.gz
- name: "Move tests to root directory"
run: mv out/build/linux-gcc-release/src/tests/LightweightTest .
- name: "Upload unit tests"
if: ${{ matrix.compiler == 'GCC 14' && matrix.cxx == '23' }}
uses: actions/upload-artifact@v4
with:
name: ubuntu2404-tests
path: |
Lightweight-Linux-CI.tar.gz
retention-days: 1
cpp26-reflection:
name: "C++26 reflection implementation"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: all
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
with:
version: latest
- name: Build
shell: bash
run: |
docker buildx build \
--progress=plain \
-f .github/Reflection.Dockerfile \
--load . --no-cache
ddl2cpp:
name: "ddl2cpp"
runs-on: ubuntu-24.04
needs: [ubuntu_build_cc_matrix]
steps:
- uses: actions/checkout@v6
- name: Fetch tags
run: git fetch --prune --unshallow --tags
- name: "Download binaries"
uses: actions/download-artifact@v4
with:
name: ubuntu2404-tests
- name: "Update APT database"
run: sudo apt -q update
- name: "Extract package"
run: |
sudo tar -xvf Lightweight-Linux-CI.tar.gz --strip-components=1 -C /usr/local
- name: "Install dependencies"
run: sudo apt install -y unixodbc-dev unixodbc libsqliteodbc odbcinst uuid-dev sqlite3 libyaml-cpp-dev libzip4 python3-yaml
- name: "Install MS SQL ODBC driver"
run: |
curl https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc
sudo add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/20.04/prod.list)"
sudo apt update
sudo ACCEPT_EULA=y DEBIAN_FRONTEND=noninteractive apt install -y mssql-tools18
- name: "Start MS SQL Server 2022"
run: python3 ./scripts/tests/docker-databases.py --start --wait mssql2022
- name: "Load Chinook data"
run: python3 ./scripts/tests/docker-databases.py --load-sql ./src/examples/test_chinook/Chinook_Sqlite.sql mssql2022
- name: "Run ddl2cpp on Chinook db"
run: |
DDL2CPP=/usr/local/bin/ddl2cpp ./src/tools/test_chinook.sh --test-env=mssql2022
- name: "Install build dependencies"
run: sudo apt install -y cmake ninja-build catch2 unixodbc-dev sqlite3 libsqlite3-dev libsqliteodbc uuid-dev libyaml-cpp-dev g++-14 libstdc++-14-dev libzip-dev
- name: "Configure cmake"
run: cmake --preset linux-gcc-release -B build -D CMAKE_CXX_COMPILER=g++-14 -D LIGHTWEIGHT_BUILD_MODULES=ON
- name: "Build chinook example"
run: cmake --build build --target chinook
- name: "Run chinook example"
run: ./build/src/examples/test_chinook/chinook
env:
ODBC_CONNECTION_STRING: "Driver={ODBC Driver 18 for SQL Server};SERVER=localhost;PORT=1433;UID=SA;PWD=Lightweight!Test42;TrustServerCertificate=yes;DATABASE=LightweightTest"
dbms_test_matrix:
strategy:
fail-fast: false
matrix:
include:
- database: "SQLite3"
test_env: "sqlite3"
docker_db: ""
- database: "MS SQL Server 2017"
test_env: "mssql2017"
docker_db: "mssql2017"
- database: "MS SQL Server 2019"
test_env: "mssql2019"
docker_db: "mssql2019"
- database: "MS SQL Server 2022"
test_env: "mssql2022"
docker_db: "mssql2022"
# Disabled for now, as MS SQL Server 2025 image seems to be broken
# - database: "MS SQL Server 2025"
# test_env: "mssql2025"
# docker_db: "mssql2025"
- database: "PostgreSQL"
test_env: "postgres"
docker_db: "postgres"
name: "Tests (${{ matrix.database }})"
runs-on: ubuntu-24.04
needs: [ubuntu_build_cc_matrix]
steps:
- uses: actions/checkout@v6
- name: "Download unit test binaries"
uses: actions/download-artifact@v4
with:
name: ubuntu2404-tests
- name: "Extract package"
run: |
sudo tar -xvf Lightweight-Linux-CI.tar.gz --strip-components=1 -C /usr/local
- name: "Update APT database"
run: sudo apt -q update
- name: "Install common dependencies"
run: sudo apt install -y unixodbc odbcinst libuuid1 valgrind libyaml-cpp-dev libzip4
- name: "Install SQLite3 ODBC driver"
if: matrix.database == 'SQLite3'
run: sudo apt install -y libsqlite3-dev libsqliteodbc sqlite3
- name: "Install MS SQL ODBC driver"
if: startsWith(matrix.database, 'MS SQL')
run: |
curl https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc
sudo add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/20.04/prod.list)"
sudo apt update
sudo ACCEPT_EULA=y DEBIAN_FRONTEND=noninteractive apt install -y mssql-tools18
- name: "Install PostgreSQL ODBC driver"
if: matrix.database == 'PostgreSQL'
run: sudo apt install -y odbc-postgresql
- name: "Start Docker database"
if: matrix.docker_db != ''
run: python3 ./scripts/tests/docker-databases.py --start --wait ${{ matrix.docker_db }}
- name: "Inspect dependencies"
run: ldd /usr/local/bin/LightweightTest
- name: "Run SQL tests"
run: |
set -ex
if [[ "${{ matrix.database }}" = "SQLite3" ]]; then
CMD_PREFIX="valgrind --leak-check=full --leak-resolution=high --num-callers=64 --error-exitcode=1"
fi
$CMD_PREFIX LightweightTest --test-env=${{ matrix.test_env }}
- name: "Run dbtool tests"
run: |
set -ex
python3 /usr/local/share/Lightweight/tests/test_dbtool.py \
--dbtool /usr/local/bin/dbtool \
--plugins-dir /usr/local/share/Lightweight/tests/plugins \
--test-env ${{ matrix.test_env }}
# }}}
# {{{ Sanitizers
sanitizers:
strategy:
fail-fast: false
matrix:
sanitizer: ["asan-ubsan", "tsan"]
name: "Sanitizers (${{ matrix.sanitizer }})"
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
- name: Fetch tags
run: git fetch --prune --unshallow --tags
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: "ccache-ubuntu2404-clang-${{ matrix.sanitizer }}"
max-size: 256M
- name: "update APT database"
run: sudo apt -q update
- name: Install Clang
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 19
- name: "install dependencies"
run: sudo apt install -y cmake ninja-build catch2 unixodbc-dev sqlite3 libsqlite3-dev libsqliteodbc uuid-dev libyaml-cpp-dev libzip-dev
- name: "cmake"
run: |
cmake --preset linux-clang-${{ matrix.sanitizer }} \
-D CMAKE_CXX_COMPILER=clang++-19 \
-D CMAKE_C_COMPILER=clang-19
- name: "build"
run: cmake --build --preset linux-clang-${{ matrix.sanitizer }} -- -j$(nproc)
- name: "Run tests with ${{ matrix.sanitizer }}"
env:
ASAN_OPTIONS: "detect_leaks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1"
UBSAN_OPTIONS: "print_stacktrace=1:halt_on_error=1:suppressions=${{ github.workspace }}/.github/ubsan.suppressions"
TSAN_OPTIONS: "second_deadlock_stack=1"
run: |
./out/build/linux-clang-${{ matrix.sanitizer }}/src/tests/LightweightTest --test-env=sqlite3
# }}}