Skip to content

PoC: Use Firebird embedded mode for CI on all platforms #76

PoC: Use Firebird embedded mode for CI on all platforms

PoC: Use Firebird embedded mode for CI on all platforms #76

Workflow file for this run

name: Pull Request
on:
pull_request:
branches:
- main
workflow_dispatch:
permissions:
packages: write
jobs:
clang-format-check:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Install clang-format
run: |
sudo apt-get update
sudo apt-get install -y clang-format
- name: Check clang-format
run: |
./check-format.sh
build-linux:
runs-on: ubuntu-latest
env:
USERNAME: asfernandes
VCPKG_EXE: ${{ github.workspace }}/vcpkg/vcpkg
FEED_URL: ${{ github.repository == 'asfernandes/fb-cpp' && 'https://nuget.pkg.github.com/asfernandes/index.json' || '' }}
VCPKG_BINARY_SOURCES: ${{ github.repository == 'asfernandes/fb-cpp' && 'clear;nuget,https://nuget.pkg.github.com/asfernandes/index.json,readwrite' || '' }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Cache vcpkg artifacts
uses: actions/cache@v4
with:
path: |
vcpkg/downloads
vcpkg/buildtrees
vcpkg/packages
build/vcpkg_installed
key: ${{ runner.os }}-vcpkg-v3-${{ hashFiles('vcpkg.json', 'vcpkg-configuration.json') }}
restore-keys: |
${{ runner.os }}-vcpkg-v3-
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install --no-install-recommends -y \
autoconf \
autoconf-archive \
automake \
libtool \
libtool-bin \
doxygen \
graphviz \
ninja-build \
libtommath1 \
libtomcrypt1 \
mono-complete
- name: Cache Firebird environment
id: cache-firebird
uses: actions/cache@v4
with:
path: /tmp/firebird
key: firebird-embedded-linux-x64-5.0.3
- name: Download Firebird (embedded)
if: steps.cache-firebird.outputs.cache-hit != 'true'
run: |
wget -nv -O /tmp/Firebird.tar.gz \
"https://github.com/FirebirdSQL/firebird/releases/download/v5.0.3/Firebird-5.0.3.1683-0-linux-x64.tar.gz"
mkdir -p /tmp/firebird-extract
tar xzf /tmp/Firebird.tar.gz -C /tmp/firebird-extract
tar xzf /tmp/firebird-extract/Firebird-5.0.3.1683-0-linux-x64/buildroot.tar.gz -C /tmp/firebird-extract
mv /tmp/firebird-extract/opt/firebird /tmp/firebird
rm -rf /tmp/firebird-extract /tmp/Firebird.tar.gz
- name: Bootstrap vcpkg
run: |
./vcpkg/bootstrap-vcpkg.sh -disableMetrics
- name: Configure vcpkg binary caching
if: github.repository == 'asfernandes/fb-cpp'
run: |
mono `${{ env.VCPKG_EXE }} fetch nuget | tail -n 1` \
sources add \
-Source "${{ env.FEED_URL }}" \
-StorePasswordInClearText \
-Name GitHubPackages \
-UserName "${{ env.USERNAME }}" \
-Password "${{ secrets.GITHUB_TOKEN }}"
mono `${{ env.VCPKG_EXE }} fetch nuget | tail -n 1` \
setapikey "${{ secrets.GITHUB_TOKEN }}" \
-Source "${{ env.FEED_URL }}"
- name: Configure CMake
run: |
cp CMakeUserPresets.json.embedded-posix.template CMakeUserPresets.json
cmake --preset default
- name: Upload vcpkg failure logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: vcpkg-logs-${{ github.job }}
path: vcpkg/buildtrees/**/*.log
if-no-files-found: ignore
- name: Build
run: |
cmake --build --preset default
- name: Run tests
env:
FIREBIRD: /tmp/firebird
LD_LIBRARY_PATH: /tmp/firebird/lib
run: |
ctest --preset default --verbose
- name: Build documentation
run: |
cmake --build --preset default --target docs
build-windows:
runs-on: windows-latest
env:
USERNAME: asfernandes
VCPKG_EXE: ${{ github.workspace }}/vcpkg/vcpkg
FEED_URL: ${{ github.repository == 'asfernandes/fb-cpp' && 'https://nuget.pkg.github.com/asfernandes/index.json' || '' }}
VCPKG_BINARY_SOURCES: ${{ github.repository == 'asfernandes/fb-cpp' && 'clear;nuget,https://nuget.pkg.github.com/asfernandes/index.json,readwrite' || '' }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Cache vcpkg artifacts
uses: actions/cache@v4
with:
path: |
vcpkg/downloads
vcpkg/buildtrees
vcpkg/packages
build/vcpkg_installed
key: ${{ runner.os }}-vcpkg-v3-${{ hashFiles('vcpkg.json', 'vcpkg-configuration.json') }}
restore-keys: |
${{ runner.os }}-vcpkg-v3-
- name: Cache Firebird environment
id: cache-firebird
uses: actions/cache@v4
with:
path: C:\Firebird
key: firebird-windows-x64-5.0.3
- name: Download Firebird (embedded)
if: steps.cache-firebird.outputs.cache-hit != 'true'
shell: pwsh
run: |
$url = 'https://github.com/FirebirdSQL/firebird/releases/download/v5.0.3/Firebird-5.0.3.1683-0-windows-x64.zip'
Invoke-WebRequest $url -OutFile Firebird.zip
Expand-Archive Firebird.zip -DestinationPath 'C:\Firebird'
Remove-Item Firebird.zip
- name: Bootstrap vcpkg
shell: cmd
run: |
vcpkg\bootstrap-vcpkg.bat -disableMetrics
- name: Configure vcpkg binary caching
if: github.repository == 'asfernandes/fb-cpp'
shell: pwsh
run: |
.$(${{ env.VCPKG_EXE }} fetch nuget) `
sources add `
-Source "${{ env.FEED_URL }}" `
-StorePasswordInClearText `
-Name GitHubPackages `
-UserName "${{ env.USERNAME }}" `
-Password "${{ secrets.GITHUB_TOKEN }}"
.$(${{ env.VCPKG_EXE }} fetch nuget) `
setapikey "${{ secrets.GITHUB_TOKEN }}" `
-Source "${{ env.FEED_URL }}"
- name: Configure CMake
shell: cmd
run: |
copy CMakeUserPresets.json.embedded-windows.template CMakeUserPresets.json
cmake --preset default
- name: Upload vcpkg failure logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: vcpkg-logs-${{ github.job }}
path: vcpkg/buildtrees/**/*.log
if-no-files-found: ignore
- name: Build
shell: cmd
run: |
cmake --build --preset default
- name: Prepare Firebird embedded for tests
shell: pwsh
run: |
# Configure Firebird for embedded-only operation
$confPath = 'C:\Firebird\firebird.conf'
Add-Content -Path $confPath -Value "`nProviders = Engine13"
Add-Content -Path $confPath -Value "DatabaseAccess = Full"
# Remove ALL vcpkg fbclient.dll copies from the build tree so the
# DLL search falls through to PATH -> C:\Firebird\fbclient.dll
Get-ChildItem -Path build -Recurse -Filter 'fbclient.dll' | ForEach-Object {
Write-Host "Removing: $($_.FullName)"
Remove-Item $_.FullName -Force
}
- name: Run tests
shell: cmd
run: |
set FIREBIRD=C:\Firebird
set PATH=C:\Firebird;%PATH%
ctest --preset default --verbose
build-macos:
runs-on: macos-latest
env:
USERNAME: asfernandes
VCPKG_EXE: ${{ github.workspace }}/vcpkg/vcpkg
FEED_URL: ${{ github.repository == 'asfernandes/fb-cpp' && 'https://nuget.pkg.github.com/asfernandes/index.json' || '' }}
VCPKG_BINARY_SOURCES: ${{ github.repository == 'asfernandes/fb-cpp' && 'clear;nuget,https://nuget.pkg.github.com/asfernandes/index.json,readwrite' || '' }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Cache vcpkg artifacts
uses: actions/cache@v4
with:
path: |
vcpkg/downloads
vcpkg/buildtrees
vcpkg/packages
build/vcpkg_installed
key: ${{ runner.os }}-vcpkg-v3-${{ hashFiles('vcpkg.json', 'vcpkg-configuration.json') }}
restore-keys: |
${{ runner.os }}-vcpkg-v3-
- name: Install system dependencies
run: |
brew install \
autoconf \
autoconf-archive \
automake \
libtool \
mono
- name: Cache Firebird environment
id: cache-firebird
uses: actions/cache@v4
with:
path: /tmp/firebird
key: firebird-embedded-macos-arm64-5.0.3
- name: Download Firebird (embedded)
if: steps.cache-firebird.outputs.cache-hit != 'true'
run: |
wget -nv -O /tmp/Firebird.pkg \
"https://github.com/FirebirdSQL/firebird/releases/download/v5.0.3/Firebird-5.0.3.1683-0-macos-arm64.pkg"
pkgutil --expand /tmp/Firebird.pkg /tmp/firebird-pkg
mkdir -p /tmp/firebird-extract
PAYLOAD=$(find /tmp/firebird-pkg -name 'Payload' -type f | head -1)
tar xzf "$PAYLOAD" -C /tmp/firebird-extract
mv /tmp/firebird-extract/Versions/A /tmp/firebird
rm -rf /tmp/firebird-pkg /tmp/firebird-extract /tmp/Firebird.pkg
- name: Bootstrap vcpkg
run: |
./vcpkg/bootstrap-vcpkg.sh -disableMetrics
- name: Configure vcpkg binary caching
if: github.repository == 'asfernandes/fb-cpp'
run: |
mono `${{ env.VCPKG_EXE }} fetch nuget | tail -n 1` \
sources add \
-Source "${{ env.FEED_URL }}" \
-StorePasswordInClearText \
-Name GitHubPackages \
-UserName "${{ env.USERNAME }}" \
-Password "${{ secrets.GITHUB_TOKEN }}"
mono `${{ env.VCPKG_EXE }} fetch nuget | tail -n 1` \
setapikey "${{ secrets.GITHUB_TOKEN }}" \
-Source "${{ env.FEED_URL }}"
- name: Configure CMake
run: |
cp CMakeUserPresets.json.embedded-posix.template CMakeUserPresets.json
cmake --preset default
- name: Upload vcpkg failure logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: vcpkg-logs-${{ github.job }}
path: vcpkg/buildtrees/**/*.log
if-no-files-found: ignore
- name: Build
run: |
cmake --build --preset default
- name: Prepare Firebird embedded for tests
run: |
# Replace vcpkg's client-only libfbclient with the full distribution
# version that includes the embedded engine provider.
VCPKG_LIB=$(find build/vcpkg_installed -path '*/debug/lib' -type d | head -1)
# Remove vcpkg's client-only copies
find "$VCPKG_LIB" -name 'libfbclient.dylib*' -exec rm -f {} \;
# Copy full distribution library and create versioned symlinks
cp /tmp/firebird/Libraries/libfbclient.dylib "$VCPKG_LIB/libfbclient.dylib.5.0.3"
ln -sf libfbclient.dylib.5.0.3 "$VCPKG_LIB/libfbclient.dylib.2"
ln -sf libfbclient.dylib.5.0.3 "$VCPKG_LIB/libfbclient.dylib"
# Add RPATH so the library can find its dependencies (libtommath, etc.)
install_name_tool -add_rpath /tmp/firebird/Resources "$VCPKG_LIB/libfbclient.dylib.5.0.3"
- name: Run tests
env:
FIREBIRD: /tmp/firebird/Resources
DYLD_LIBRARY_PATH: /tmp/firebird/Libraries:/tmp/firebird/Resources/lib
run: |
ctest --preset default --verbose