diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..855f29f --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,100 @@ +name: CI + +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: + - ubuntu-24.04 + - windows-latest + - macos-latest + config: + - qt_version: "6.4.2" + + steps: + - name: Install dependencies on Ubuntu + if: runner.os == 'Linux' + run: | + sudo apt update -qq + sudo apt install -y doxygen graphviz postgresql-server-dev-16 + + - name: Install dependencies on macOS + if: runner.os == 'macOS' + run: | + brew install postgresql@16 + + - name: Install PostgreSQL 16 with Chocolatey + if: runner.os == 'Windows' + run: | + choco install postgresql --version=16.0 -y + + - name: Install Qt with options and default aqtversion + uses: jurplel/install-qt-action@v4 + with: + aqtversion: null # use whatever the default is + version: ${{ matrix.config.qt_version }} + cache: true + + - name: Install ninja-build tool (must be after Qt due PATH changes) + uses: turtlesec-no/get-ninja@main + + - name: Make sure MSVC is found when Ninja generator is in use + if: ${{ runner.os == 'Windows' }} + uses: ilammy/msvc-dev-cmd@v1 + + - name: Checkout sources + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Configure project (Shared Link) + run: > + cmake -S . -B ./build-shared -G Ninja + -DCMAKE_BUILD_TYPE=Debug + -DCMAKE_PREFIX_PATH="/opt/homebrew/opt/postgresql@16;C:\Program Files\PostgreSQL\16" + -DENABLE_MAINTAINER_CFLAGS=${{ matrix.build_type == 'Debug' }} + -DBUILD_SHARED_LIBS=ON + + - name: Build project + run: cmake --build ./build-shared + + - name: Run tests + id: ctest_shared + run: ctest --test-dir ./build-shared -C Debug --output-on-failure + + - name: Read tests log when it fails + uses: andstor/file-reader-action@v1 + if: ${{ steps.ctest_shared.conclusion == 'failure' }} + with: + path: "./build-shared/Testing/Temporary/LastTest.log" + + # Installing PostgreSQL on Windows takes too much time, so better reuse it here + - name: Configure project (Static Link) + run: > + cmake -S . -B ./build-static -G Ninja + -DCMAKE_BUILD_TYPE=Debug + -DCMAKE_PREFIX_PATH="/opt/homebrew/opt/postgresql@16;C:\Program Files\PostgreSQL\16" + -DBUILD_SHARED_LIBS=OFF + + - name: Build project + run: cmake --build ./build-static + + - name: Run tests + id: ctest_static + run: ctest --test-dir ./build-static -C Debug --output-on-failure + + - name: Read tests log when it fails + uses: andstor/file-reader-action@v1 + if: ${{ steps.ctest_static.conclusion == 'failure' }} + with: + path: "./build-static/Testing/Temporary/LastTest.log" diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml new file mode 100644 index 0000000..926dc1e --- /dev/null +++ b/.github/workflows/documentation.yml @@ -0,0 +1,75 @@ +name: Deploy API docs to GitHub Pages + +on: + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + + push: + branches: + - master + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. +concurrency: + group: "pages" + cancel-in-progress: false + +jobs: + build: + runs-on: ubuntu-24.04 + + steps: + - name: Install Dependencies on Linux + run: | + sudo apt update -qq + sudo apt install -y doxygen graphviz postgresql-server-dev-all + + - name: Install Qt + uses: jurplel/install-qt-action@v4 + with: + aqtversion: null # use whatever the default is + version: 6.6.0 + cache: true + documentation: true + doc-archives: 'qtcore' + + - name: Checkout sources + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Configure project + run: > + cmake -S . -B ./build + -DBUILD_ALL=ON + -DPLUGIN_VIEW_CUTELEE=OFF + -DPLUGIN_VIEW_EMAIL=OFF + -DUSE_JEMALLOC=OFF + -DDOCS_QTDOCSDIR:PATH="${{ runner.workspace }}/Qt/Docs/Qt-6.6.0" + + - name: Create docs + run: cmake --build ./build --target webdocs + + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: build/webdocs/ + + # Deployment job, what was uploaded to artifact + deploy: + needs: build + runs-on: ubuntu-latest + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml new file mode 100644 index 0000000..ea16df4 --- /dev/null +++ b/.github/workflows/nightly.yml @@ -0,0 +1,53 @@ +name: CI Nightly + +on: + workflow_dispatch: + + schedule: + - cron: '0 3 * * *' + +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: + - ubuntu-24.04 + + config: + - name: clang-tidy + cmake_arg: '-DCMAKE_CXX_CLANG_TIDY=clang-tidy' + qt_version: "6.7.3" + + - name: clazy + cmake_arg: '-DCMAKE_CXX_COMPILER=clazy' + qt_version: "6.7.3" + + steps: + - name: Install dependencies on Ubuntu + if: runner.os == 'Linux' + run: | + sudo apt update -qq + sudo apt install -y clazy doxygen graphviz postgresql-server-dev-all + + - name: Install Qt ${{ matrix.config.qt_version }} with options and default aqtversion + uses: jurplel/install-qt-action@v4 + with: + version: ${{ matrix.config.qt_version }} + cache: true + + - name: Install ninja-build tool (must be after Qt due PATH changes) + uses: turtlesec-no/get-ninja@main + + - uses: actions/checkout@v4 + + - name: Configure project + run: > + cmake -S . -B ./build -G Ninja ${{ matrix.config.cmake_arg }} + -DCMAKE_BUILD_TYPE=Debug + --warn-uninitialized -Werror=dev + -DENABLE_MAINTAINER_CFLAGS=ON + + - name: Build Project + run: cmake --build ./build diff --git a/.gitignore b/.gitignore index f65bf55..08ddb7a 100644 --- a/.gitignore +++ b/.gitignore @@ -31,5 +31,5 @@ *.out *.app -build +build*/ *.user diff --git a/CMakeLists.txt b/CMakeLists.txt index 4b27bd7..ead9da5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,7 @@ cmake_minimum_required(VERSION 3.16) project(libasql VERSION 0.92.0 LANGUAGES CXX) include(GNUInstallDirs) +include(GenerateExportHeader) find_package(PostgreSQL REQUIRED) find_package(QT NAMES Qt6 COMPONENTS Core REQUIRED) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 122bcb9..6452d7c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -34,9 +34,11 @@ add_library(ASqlQt${QT_VERSION_MAJOR} ${asql_HEADERS} ${asql_HEADERS_PRIVATE} ) - -configure_file(asqlexports.h.in asqlexports.h @ONLY) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/asqlexports.h +generate_export_header(ASqlQt${QT_VERSION_MAJOR} + BASE_NAME ASQL +) +install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/asql_export.h DESTINATION include/asql-qt${QT_VERSION_MAJOR}/ASql ) @@ -100,6 +102,14 @@ add_library(ASqlQt${QT_VERSION_MAJOR}Migrations ${asql_migrations_HEADERS} ) +generate_export_header(ASqlQt${QT_VERSION_MAJOR}Migrations + BASE_NAME ASQL_MIGRATIONS +) +install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/asql_migrations_export.h + DESTINATION include/asql-qt${QT_VERSION_MAJOR}/ASql +) + add_library(ASql::Migrations ALIAS ASqlQt${QT_VERSION_MAJOR}Migrations) project_target_compile_definitions(ASqlQt${QT_VERSION_MAJOR}Migrations) @@ -154,6 +164,14 @@ add_library(ASqlQt${QT_VERSION_MAJOR}Pg ${asql_pg_HEADERS} ) +generate_export_header(ASqlQt${QT_VERSION_MAJOR}Pg + BASE_NAME ASQL_PG +) +install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/asql_pg_export.h + DESTINATION include/asql-qt${QT_VERSION_MAJOR}/ASql +) + add_library(ASql::Pg ALIAS ASqlQt${QT_VERSION_MAJOR}Pg) project_target_compile_definitions(ASqlQt${QT_VERSION_MAJOR}Pg) diff --git a/src/acache.h b/src/acache.h index 1046602..31a38bf 100644 --- a/src/acache.h +++ b/src/acache.h @@ -5,7 +5,7 @@ #pragma once #include -#include +#include #include #include diff --git a/src/acoroexpected.h b/src/acoroexpected.h index 6e6338c..105d65b 100644 --- a/src/acoroexpected.h +++ b/src/acoroexpected.h @@ -2,7 +2,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/adatabase.h b/src/adatabase.h index 716d08d..2e9acf0 100644 --- a/src/adatabase.h +++ b/src/adatabase.h @@ -4,7 +4,7 @@ */ #pragma once -#include +#include #include #include #include diff --git a/src/adriver.h b/src/adriver.h index 6c2eb6a..6471f19 100644 --- a/src/adriver.h +++ b/src/adriver.h @@ -5,7 +5,7 @@ #pragma once #include -#include +#include #include #include diff --git a/src/adriverfactory.h b/src/adriverfactory.h index c781ec0..118f789 100644 --- a/src/adriverfactory.h +++ b/src/adriverfactory.h @@ -4,7 +4,7 @@ */ #pragma once -#include +#include #include namespace ASql { diff --git a/src/amigrations.h b/src/amigrations.h index f9b97e7..109d07c 100644 --- a/src/amigrations.h +++ b/src/amigrations.h @@ -1,17 +1,18 @@ /* - * SPDX-FileCopyrightText: (C) 2020-2023 Daniel Nicoletti + * SPDX-FileCopyrightText: (C) 2020-2024 Daniel Nicoletti * SPDX-License-Identifier: MIT */ #pragma once #include +#include #include namespace ASql { class AMigrationsPrivate; -class ASQL_EXPORT AMigrations : public QObject +class ASQL_MIGRATIONS_EXPORT AMigrations : public QObject { Q_OBJECT Q_DECLARE_PRIVATE(AMigrations) diff --git a/src/apg.h b/src/apg.h index 32fdd52..8ddd409 100644 --- a/src/apg.h +++ b/src/apg.h @@ -6,7 +6,7 @@ #include "adriverfactory.h" -#include +#include #include diff --git a/src/apool.h b/src/apool.h index 695bbd6..56565e5 100644 --- a/src/apool.h +++ b/src/apool.h @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include diff --git a/src/apreparedquery.h b/src/apreparedquery.h index 338e993..82c9057 100644 --- a/src/apreparedquery.h +++ b/src/apreparedquery.h @@ -4,7 +4,7 @@ */ #pragma once -#include +#include #include diff --git a/src/aresult.h b/src/aresult.h index 12ffe27..d9f04ad 100644 --- a/src/aresult.h +++ b/src/aresult.h @@ -4,7 +4,7 @@ */ #pragma once -#include +#include #include #include diff --git a/src/asqlexports.h.in b/src/asqlexports.h.in deleted file mode 100644 index 7e3d440..0000000 --- a/src/asqlexports.h.in +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SPDX-FileCopyrightText: (C) 2020 Daniel Nicoletti - * SPDX-License-Identifier: MIT - */ - -#ifndef ASQL_EXPORT_H -#define ASQL_EXPORT_H - -#include - -#if defined(ASqlQt@QT_VERSION_MAJOR@_EXPORTS) -#define ASQL_EXPORT Q_DECL_EXPORT -#else -#define ASQL_EXPORT Q_DECL_IMPORT -#endif - -#if defined(ASqlQt@QT_VERSION_MAJOR@Pg_EXPORTS) -#define ASQL_PG_EXPORT Q_DECL_EXPORT -#else -#define ASQL_PG_EXPORT Q_DECL_IMPORT -#endif - -#endif diff --git a/src/atransaction.h b/src/atransaction.h index 65bccb7..197f3cb 100644 --- a/src/atransaction.h +++ b/src/atransaction.h @@ -5,7 +5,7 @@ #pragma once #include -#include +#include namespace ASql {