Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
336 changes: 336 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,336 @@
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 }}
VCPKG_KEEP_ENV_VARS: "BRAZIER_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@v5

- name: Checkout brazier-registry
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 \
-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: '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 <string>

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
-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_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

- 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 }}
VCPKG_KEEP_ENV_VARS: "BRAZIER_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@v5

- name: Checkout brazier-registry
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*" | Select-Object -First 1
Start-Service $svc.Name
$data = "C:\Program Files\PostgreSQL\15\data"
$hba = Join-Path $data "pg_hba.conf"
(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';"

- name: Setup vcpkg
uses: lukka/run-vcpkg@v11
with:
vcpkgDirectory: '${{ github.workspace }}/vcpkg'
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 <string>

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
-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_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

- 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 "vcpkg_installed\x64-windows\bin\*.dll" -Destination $dest -ErrorAction SilentlyContinue
} else {
Copy-Item "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-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
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@v5

- name: Checkout brazier-registry
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
createuser -s postgres 2>/dev/null || true
psql -U postgres -d postgres -c "ALTER USER postgres PASSWORD 'postgres';" || true
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: '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 <string>

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
-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_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

- name: Build
run: cmake --build build --config ${{ matrix.build_type }}

- name: Run tests
working-directory: build
run: ./brazier-orm_tests
shell: bash
2 changes: 1 addition & 1 deletion vcpkg.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down