From 850d4741242a29461520d02e474a293ecc72fc22 Mon Sep 17 00:00:00 2001 From: CodeGonshik Date: Mon, 12 Oct 2026 21:35:17 +0300 Subject: [PATCH 1/2] feat: ci integration --- .github/workflows/build.yml | 265 ++++++++++++++++++++++++++++++++++++ 1 file changed, 265 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..d6b3db9 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,265 @@ +name: CMake Multi-Platform Build + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + workflow_dispatch: + +jobs: + + resolve: + runs-on: ubuntu-latest + outputs: + logger_ref: ${{ steps.r.outputs.logger_ref }} + steps: + - name: Resolve master SHAs + id: r + shell: bash + run: | + LOGGER_SHA=$(git ls-remote https://github.com/brazier-tech/brazier-logger.git master | awk '{print $1}') + echo "logger_ref=$LOGGER_SHA" >> $GITHUB_OUTPUT + echo "resolved logger: $LOGGER_SHA" + + linux: + needs: resolve + runs-on: ubuntu-latest + + env: + VCPKG_OVERLAY_PORTS: ${{ github.workspace }}/registry/ports + BRAZIER_LOGGER_REF: ${{ needs.resolve.outputs.logger_ref }} + + strategy: + fail-fast: false + matrix: + compiler: [gcc, clang] + build_type: [Release, Debug] + shared_libs: [ON, OFF] + include: + - compiler: gcc + c_compiler: gcc + cpp_compiler: g++ + - compiler: clang + c_compiler: clang + cpp_compiler: clang++ + + steps: + - name: Checkout brazier-orm + uses: actions/checkout@v4 + + - name: Checkout brazier-registry + uses: actions/checkout@v4 + with: + repository: brazier-tech/brazier-registry + path: registry + ref: for-local-using + + - name: Start PostgreSQL + run: | + docker run -d --name postgres \ + -e POSTGRES_USER=postgres \ + -e POSTGRES_PASSWORD=postgres \ + -e POSTGRES_DB=postgres \ + -p 5432:5432 postgres:15 + for i in {1..30}; do + docker exec postgres pg_isready -U postgres && break || sleep 1 + done + + - name: Setup vcpkg + uses: lukka/run-vcpkg@v11 + with: + vcpkgDirectory: '${{ github.workspace }}/vcpkg' + vcpkgJsonGlob: 'brazierORM/vcpkg.json' + + - name: Set VCPKG_ROOT + shell: bash + run: echo "VCPKG_ROOT=${{ github.workspace }}/vcpkg" >> $GITHUB_ENV + + - name: Configure CMake + run: > + cmake -B build + -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} + -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} + -DBUILD_SHARED_LIBS=${{ matrix.shared_libs }} + -DBUILD_TESTS=ON + -DBUILD_DEMO=OFF + -DVCPKG_OVERLAY_PORTS=${{ github.workspace }}/registry/ports + -DCMAKE_TOOLCHAIN_FILE=${{ env.VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake + -S brazierORM + + - name: Build + run: cmake --build build --config ${{ matrix.build_type }} + + - name: Run tests + working-directory: build + run: ./brazier-orm_tests + shell: bash + + windows: + needs: resolve + runs-on: windows-latest + + env: + VCPKG_OVERLAY_PORTS: ${{ github.workspace }}/registry/ports + BRAZIER_LOGGER_REF: ${{ needs.resolve.outputs.logger_ref }} + + strategy: + fail-fast: false + matrix: + compiler: [cl] + build_type: [Release, Debug] + shared_libs: [ON, OFF] + include: + - compiler: cl + c_compiler: cl + cpp_compiler: cl + + steps: + - name: Checkout brazier-orm + uses: actions/checkout@v4 + + - name: Checkout brazier-registry + uses: actions/checkout@v4 + with: + repository: brazier-tech/brazier-registry + path: registry + ref: for-local-using + + - name: Install PostgreSQL + shell: pwsh + run: | + choco install postgresql15 --params '/Password:postgres' --no-progress -y + $svc = Get-Service -Name "postgresql*" + if ($svc) { Start-Service $svc.Name } + # update pg_hba.conf to trust local connections + $data = "C:\Program Files\PostgreSQL\15\data" + $hba = Join-Path $data "pg_hba.conf" + if (Test-Path $hba) { + (Get-Content $hba) -replace 'scram-sha-256','trust' -replace 'md5','trust' | + Set-Content $hba + Restart-Service $svc.Name + } + # set postgres user password + $env:PGPASSWORD = "postgres" + & "C:\Program Files\PostgreSQL\15\bin\psql.exe" -U postgres -c "ALTER USER postgres PASSWORD 'postgres';" + + - name: Setup vcpkg + uses: lukka/run-vcpkg@v11 + with: + vcpkgDirectory: '${{ github.workspace }}/vcpkg' + vcpkgJsonGlob: 'brazierORM/vcpkg.json' + + - name: Set VCPKG_ROOT + shell: bash + run: echo "VCPKG_ROOT=${{ github.workspace }}/vcpkg" >> $GITHUB_ENV + + - name: Configure CMake + run: > + cmake -B build + -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} + -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} + -DBUILD_SHARED_LIBS=${{ matrix.shared_libs }} + -DBUILD_TESTS=ON + -DBUILD_DEMO=OFF + -DVCPKG_OVERLAY_PORTS=${{ github.workspace }}/registry/ports + -DCMAKE_TOOLCHAIN_FILE=${{ env.VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake + -S brazierORM + + - name: Build + run: cmake --build build --config ${{ matrix.build_type }} + + - name: Copy DLLs to test directory + shell: pwsh + run: | + $dest = "build\${{ matrix.build_type }}" + New-Item -ItemType Directory -Force -Path $dest | Out-Null + if ("${{ matrix.build_type }}" -eq "Release") { + Copy-Item "build\vcpkg_installed\x64-windows\bin\*.dll" -Destination $dest -ErrorAction SilentlyContinue + } else { + Copy-Item "build\vcpkg_installed\x64-windows\debug\bin\*.dll" -Destination $dest -ErrorAction SilentlyContinue + } + + - name: Run tests + working-directory: build + run: ./${{ matrix.build_type }}/brazier-orm_tests.exe + shell: bash + + macos: + needs: resolve + runs-on: macos-13 + + env: + VCPKG_OVERLAY_PORTS: ${{ github.workspace }}/registry/ports + BRAZIER_LOGGER_REF: ${{ needs.resolve.outputs.logger_ref }} + + strategy: + fail-fast: false + matrix: + compiler: [clang] + build_type: [Release, Debug] + shared_libs: [ON, OFF] + include: + - compiler: clang + c_compiler: clang + cpp_compiler: clang++ + + steps: + - name: Checkout brazier-orm + uses: actions/checkout@v4 + + - name: Checkout brazier-registry + uses: actions/checkout@v4 + with: + repository: brazier-tech/brazier-registry + path: registry + ref: for-local-using + + - name: Install system dependencies + run: | + brew install autoconf postgresql@15 + brew services start postgresql@15 + sleep 5 + # ensure 'postgres' superuser exists (homebrew creates current user by default) + createuser -s postgres 2>/dev/null || true + psql -U postgres -d postgres -c "ALTER USER postgres PASSWORD 'postgres';" || true + # set to trust for local connections + PG_HBA=$(brew --prefix)/var/postgresql@15/pg_hba.conf + if [ -f "$PG_HBA" ]; then + sed -i.bak 's/scram-sha-256/trust/g; s/md5/trust/g' "$PG_HBA" + brew services restart postgresql@15 + sleep 3 + fi + + - name: Setup vcpkg + uses: lukka/run-vcpkg@v11 + with: + vcpkgDirectory: '${{ github.workspace }}/vcpkg' + vcpkgJsonGlob: 'brazierORM/vcpkg.json' + + - name: Set VCPKG_ROOT + shell: bash + run: echo "VCPKG_ROOT=${{ github.workspace }}/vcpkg" >> $GITHUB_ENV + + - name: Configure CMake + run: > + cmake -B build + -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} + -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} + -DBUILD_SHARED_LIBS=${{ matrix.shared_libs }} + -DBUILD_TESTS=ON + -DBUILD_DEMO=OFF + -DVCPKG_OVERLAY_PORTS=${{ github.workspace }}/registry/ports + -DCMAKE_TOOLCHAIN_FILE=${{ env.VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake + -S brazierORM + + - name: Build + run: cmake --build build --config ${{ matrix.build_type }} + + - name: Run tests + working-directory: build + run: ./brazier-orm_tests + shell: bash \ No newline at end of file From 4610a8b6b92f5115d0070062ed241b61301ff616 Mon Sep 17 00:00:00 2001 From: CodeGonshik Date: Mon, 12 Oct 2026 22:45:13 +0300 Subject: [PATCH 2/2] fix: ci/cd integration --- .github/workflows/build.yml | 117 +++++++++++++++++++++++++++++------- vcpkg.json | 2 +- 2 files changed, 95 insertions(+), 24 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d6b3db9..c993765 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,6 +29,7 @@ jobs: env: VCPKG_OVERLAY_PORTS: ${{ github.workspace }}/registry/ports BRAZIER_LOGGER_REF: ${{ needs.resolve.outputs.logger_ref }} + VCPKG_KEEP_ENV_VARS: "BRAZIER_LOGGER_REF" strategy: fail-fast: false @@ -46,15 +47,22 @@ jobs: steps: - name: Checkout brazier-orm - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Checkout brazier-registry - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: repository: brazier-tech/brazier-registry path: registry ref: for-local-using + - name: Debug env + shell: bash + run: | + echo "BRAZIER_LOGGER_REF = $BRAZIER_LOGGER_REF" + echo "VCPKG_OVERLAY_PORTS = $VCPKG_OVERLAY_PORTS" + echo "VCPKG_KEEP_ENV_VARS = $VCPKG_KEEP_ENV_VARS" + - name: Start PostgreSQL run: | docker run -d --name postgres \ @@ -70,12 +78,28 @@ jobs: uses: lukka/run-vcpkg@v11 with: vcpkgDirectory: '${{ github.workspace }}/vcpkg' - vcpkgJsonGlob: 'brazierORM/vcpkg.json' + vcpkgJsonGlob: 'vcpkg.json' - name: Set VCPKG_ROOT shell: bash run: echo "VCPKG_ROOT=${{ github.workspace }}/vcpkg" >> $GITHUB_ENV + - name: Create tests config + working-directory: brazierORM + run: | + mkdir -p tests/config + cat > tests/config/config.hpp <<'EOF' + #pragma once + #include + + static const std::string db_host = "localhost"; + static const std::string db_port = "5432"; + static const std::string db_user = "postgres"; + static const std::string db_password = "postgres"; + static const std::string db_name = "postgres"; + EOF + shell: bash + - name: Configure CMake run: > cmake -B build @@ -85,6 +109,8 @@ jobs: -DBUILD_SHARED_LIBS=${{ matrix.shared_libs }} -DBUILD_TESTS=ON -DBUILD_DEMO=OFF + -DVCPKG_MANIFEST_DIR=${{ github.workspace }} + -DVCPKG_INSTALLED_DIR=${{ github.workspace }}/vcpkg_installed -DVCPKG_OVERLAY_PORTS=${{ github.workspace }}/registry/ports -DCMAKE_TOOLCHAIN_FILE=${{ env.VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake -S brazierORM @@ -104,6 +130,7 @@ jobs: env: VCPKG_OVERLAY_PORTS: ${{ github.workspace }}/registry/ports BRAZIER_LOGGER_REF: ${{ needs.resolve.outputs.logger_ref }} + VCPKG_KEEP_ENV_VARS: "BRAZIER_LOGGER_REF" strategy: fail-fast: false @@ -118,30 +145,32 @@ jobs: steps: - name: Checkout brazier-orm - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Checkout brazier-registry - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: repository: brazier-tech/brazier-registry path: registry ref: for-local-using + - name: Debug env + shell: bash + run: | + echo "BRAZIER_LOGGER_REF = $BRAZIER_LOGGER_REF" + echo "VCPKG_OVERLAY_PORTS = $VCPKG_OVERLAY_PORTS" + echo "VCPKG_KEEP_ENV_VARS = $VCPKG_KEEP_ENV_VARS" + - name: Install PostgreSQL shell: pwsh run: | choco install postgresql15 --params '/Password:postgres' --no-progress -y - $svc = Get-Service -Name "postgresql*" - if ($svc) { Start-Service $svc.Name } - # update pg_hba.conf to trust local connections + $svc = Get-Service -Name "postgresql*" | Select-Object -First 1 + Start-Service $svc.Name $data = "C:\Program Files\PostgreSQL\15\data" $hba = Join-Path $data "pg_hba.conf" - if (Test-Path $hba) { - (Get-Content $hba) -replace 'scram-sha-256','trust' -replace 'md5','trust' | - Set-Content $hba - Restart-Service $svc.Name - } - # set postgres user password + (Get-Content $hba) -replace 'scram-sha-256','trust' -replace 'md5','trust' | Set-Content $hba + Restart-Service $svc.Name $env:PGPASSWORD = "postgres" & "C:\Program Files\PostgreSQL\15\bin\psql.exe" -U postgres -c "ALTER USER postgres PASSWORD 'postgres';" @@ -149,12 +178,28 @@ jobs: uses: lukka/run-vcpkg@v11 with: vcpkgDirectory: '${{ github.workspace }}/vcpkg' - vcpkgJsonGlob: 'brazierORM/vcpkg.json' + vcpkgJsonGlob: 'vcpkg.json' - name: Set VCPKG_ROOT shell: bash run: echo "VCPKG_ROOT=${{ github.workspace }}/vcpkg" >> $GITHUB_ENV + - name: Create tests config + working-directory: brazierORM + run: | + New-Item -ItemType Directory -Force -Path "tests\config" | Out-Null + @' + #pragma once + #include + + static const std::string db_host = "localhost"; + static const std::string db_port = "5432"; + static const std::string db_user = "postgres"; + static const std::string db_password = "postgres"; + static const std::string db_name = "postgres"; + '@ | Out-File -Encoding utf8 tests\config\config.hpp + shell: pwsh + - name: Configure CMake run: > cmake -B build @@ -164,6 +209,8 @@ jobs: -DBUILD_SHARED_LIBS=${{ matrix.shared_libs }} -DBUILD_TESTS=ON -DBUILD_DEMO=OFF + -DVCPKG_MANIFEST_DIR=${{ github.workspace }} + -DVCPKG_INSTALLED_DIR=${{ github.workspace }}/vcpkg_installed -DVCPKG_OVERLAY_PORTS=${{ github.workspace }}/registry/ports -DCMAKE_TOOLCHAIN_FILE=${{ env.VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake -S brazierORM @@ -177,9 +224,9 @@ jobs: $dest = "build\${{ matrix.build_type }}" New-Item -ItemType Directory -Force -Path $dest | Out-Null if ("${{ matrix.build_type }}" -eq "Release") { - Copy-Item "build\vcpkg_installed\x64-windows\bin\*.dll" -Destination $dest -ErrorAction SilentlyContinue + Copy-Item "vcpkg_installed\x64-windows\bin\*.dll" -Destination $dest -ErrorAction SilentlyContinue } else { - Copy-Item "build\vcpkg_installed\x64-windows\debug\bin\*.dll" -Destination $dest -ErrorAction SilentlyContinue + Copy-Item "vcpkg_installed\x64-windows\debug\bin\*.dll" -Destination $dest -ErrorAction SilentlyContinue } - name: Run tests @@ -189,11 +236,12 @@ jobs: macos: needs: resolve - runs-on: macos-13 + runs-on: macos-latest env: VCPKG_OVERLAY_PORTS: ${{ github.workspace }}/registry/ports BRAZIER_LOGGER_REF: ${{ needs.resolve.outputs.logger_ref }} + VCPKG_KEEP_ENV_VARS: "BRAZIER_LOGGER_REF" strategy: fail-fast: false @@ -208,24 +256,29 @@ jobs: steps: - name: Checkout brazier-orm - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Checkout brazier-registry - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: repository: brazier-tech/brazier-registry path: registry ref: for-local-using + - name: Debug env + shell: bash + run: | + echo "BRAZIER_LOGGER_REF = $BRAZIER_LOGGER_REF" + echo "VCPKG_OVERLAY_PORTS = $VCPKG_OVERLAY_PORTS" + echo "VCPKG_KEEP_ENV_VARS = $VCPKG_KEEP_ENV_VARS" + - name: Install system dependencies run: | brew install autoconf postgresql@15 brew services start postgresql@15 sleep 5 - # ensure 'postgres' superuser exists (homebrew creates current user by default) createuser -s postgres 2>/dev/null || true psql -U postgres -d postgres -c "ALTER USER postgres PASSWORD 'postgres';" || true - # set to trust for local connections PG_HBA=$(brew --prefix)/var/postgresql@15/pg_hba.conf if [ -f "$PG_HBA" ]; then sed -i.bak 's/scram-sha-256/trust/g; s/md5/trust/g' "$PG_HBA" @@ -237,12 +290,28 @@ jobs: uses: lukka/run-vcpkg@v11 with: vcpkgDirectory: '${{ github.workspace }}/vcpkg' - vcpkgJsonGlob: 'brazierORM/vcpkg.json' + vcpkgJsonGlob: 'vcpkg.json' - name: Set VCPKG_ROOT shell: bash run: echo "VCPKG_ROOT=${{ github.workspace }}/vcpkg" >> $GITHUB_ENV + - name: Create tests config + working-directory: brazierORM + run: | + mkdir -p tests/config + cat > tests/config/config.hpp <<'EOF' + #pragma once + #include + + static const std::string db_host = "localhost"; + static const std::string db_port = "5432"; + static const std::string db_user = "postgres"; + static const std::string db_password = "postgres"; + static const std::string db_name = "postgres"; + EOF + shell: bash + - name: Configure CMake run: > cmake -B build @@ -252,6 +321,8 @@ jobs: -DBUILD_SHARED_LIBS=${{ matrix.shared_libs }} -DBUILD_TESTS=ON -DBUILD_DEMO=OFF + -DVCPKG_MANIFEST_DIR=${{ github.workspace }} + -DVCPKG_INSTALLED_DIR=${{ github.workspace }}/vcpkg_installed -DVCPKG_OVERLAY_PORTS=${{ github.workspace }}/registry/ports -DCMAKE_TOOLCHAIN_FILE=${{ env.VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake -S brazierORM diff --git a/vcpkg.json b/vcpkg.json index f4153cb..c032dbc 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -1,5 +1,5 @@ { - "name": "brazier-orm", + "name": "brazier-orm-dev", "version": "0.1.0", "license": "LGPL-3.0-or-later", "description": "ORM from Brazier Framework",