Skip to content

Change BelongsTo API to have safe access to the elements when the entry is optional. #2137

Change BelongsTo API to have safe access to the elements when the entry is optional.

Change BelongsTo API to have safe access to the elements when the entry is optional. #2137

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_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
which 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
- 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 -p ./build -clang-tidy-binary clang-tidy-21 -config-file .clang-tidy -header-filter='^(?!(.*/)?stdexec-src/).*$'
# }}}
# {{{ 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: "Test"
if: ${{ endsWith(matrix.preset, 'windows-cl-debug') }}
run: ./out/build/${{ matrix.preset }}/target/Debug/LightweightTest.exe --trace-sql --trace-odbc
env:
ODBC_CONNECTION_STRING: "Driver={ODBC Driver 17 for SQL Server};Server=(LocalDB)\\MSSQLLocalDB;Database=TestDB;Trusted_Connection=Yes;"
# }}}
# {{{ 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
- 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 uuid-dev libyaml-cpp-dev
- name: "Setup ms sql server"
id: setup
run: |
bash ./.github/prepare-test-run.sh "MS SQL Server 2022" "./src/examples/test_chinook/Chinook_Sqlite.sql"
- name: "Run ddl2cpp on Chinook db"
run: |
DDL2CPP=/usr/local/bin/ddl2cpp ODBC_CONNECTION_STRING="${{ steps.setup.outputs.ODBC_CONNECTION_STRING }}" ./src/tools/test_chinook.sh
- name: "install 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
- name: "Configure cmake"
run: cmake --preset linux-gcc-release -B build -D CMAKE_CXX_COMPILER=g++-14
- name: "Configure cmake"
run: cmake --build build --target chinook
- name: "Run chinook example"
run: ./build/src/examples/test_chinook/chinook
dbms_test_matrix:
strategy:
fail-fast: false
matrix:
database:
[
"SQLite3",
"MS SQL Server 2019",
"MS SQL Server 2022",
"PostgreSQL",
# TODO: "Oracle"
# TODO: "MySQL" or "MariaDB"
]
name: "Tests (${{ matrix.database }})"
runs-on: ubuntu-24.04
needs: [ubuntu_build_cc_matrix]
env:
DBMS: "${{ matrix.database }}"
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 dependencies"
run: sudo apt install -y unixodbc odbcinst libuuid1 valgrind
- name: "Setup ${{ matrix.database }}"
id: setup
run: bash ./.github/prepare-test-run.sh "${{ matrix.database }}"
- name: "Enable ODBC tracing"
if: ${{ matrix.database == 'Oracle' }}
run: |
echo "[ODBC]" | sudo tee -a /etc/odbcinst.ini
echo "Trace=Yes" | sudo tee -a /etc/odbcinst.ini
echo "TraceFile=/dev/stdout" | sudo tee -a /etc/odbcinst.ini
- name: "~/.odbc.ini: set ServerName"
if: ${{ matrix.database == 'Oracle' }}
run: |
sed -i "s/ServerName =.*/ServerName = localhost/" ~/.odbc.ini
- name: "CI Debug prints"
if: ${{ matrix.database == 'Oracle' }}
run: |
echo "ODBC_CONNECTION_STRING=${{ steps.setup.outputs.ODBC_CONNECTION_STRING }}"
ldd /home/runner/oracle/instantclient_21_3/libsqora.so.21.1
- name: "Inspect dependencies"
run: ldd /usr/local/bin/LightweightTest
- name: "Run SQL tests"
env:
ODBC_CONNECTION_STRING: "${{ steps.setup.outputs.ODBC_CONNECTION_STRING }}"
run: |
set -ex
if [[ "${{ matrix.database }}" = "SQLite3" ]]; then
CMD_PREFIX="valgrind --leak-check=full --leak-resolution=high --num-callers=64 --error-exitcode=1"
elif [[ "${{ matrix.database }}" = "Oracle" ]]; then
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/oracle/instantclient_21_3
CMD_PREFIX="strace -f"
fi
$CMD_PREFIX LightweightTest
# }}}