Skip to content

[up] update git workflow and dependancies management #9

[up] update git workflow and dependancies management

[up] update git workflow and dependancies management #9

Workflow file for this run

# Github CI
name: CMake on multiple platforms
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
# Keep fail-fast disabled to collect failures from every platform simultaneously.
fail-fast: false
# Each include entry is a fully-specified job; no cartesian explosion needed.
matrix:
include:
- os: ubuntu-latest
c_compiler: gcc
cpp_compiler: g++
build_type: Release
- os: ubuntu-latest
c_compiler: clang
cpp_compiler: clang++
build_type: Release
- os: macos-latest
c_compiler: gcc
cpp_compiler: g++
build_type: Release
- os: macos-latest
c_compiler: clang
cpp_compiler: clang++
build_type: Release
- os: windows-latest
# MSVC is auto-detected by the Visual Studio generator; no explicit compiler flag needed.
build_type: Release
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
# ── Linux ────────────────────────────────────────────────────────────────
- name: Install dependencies (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y libssl-dev libargon2-dev zlib1g-dev
# ── macOS ────────────────────────────────────────────────────────────────
- name: Install dependencies (macOS)
if: matrix.os == 'macos-latest'
run: |
brew install openssl@3 argon2
# Export Homebrew prefix so all cmake find_* commands resolve Homebrew packages.
# On Apple Silicon this is /opt/homebrew; on Intel Macs it is /usr/local.
echo "CMAKE_PREFIX_PATH=$(brew --prefix)" >> "$GITHUB_ENV"
# ── Windows ──────────────────────────────────────────────────────────────
- name: Install dependencies (Windows)
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
# vcpkg is pre-installed on GitHub Actions Windows runners.
# The toolchain file makes find_package() / find_path() / find_library()
# automatically search vcpkg's installed tree.
vcpkg install openssl:x64-windows argon2:x64-windows zlib:x64-windows
echo "VCPKG_TOOLCHAIN=$env:VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" >> $env:GITHUB_ENV
# ── Shared ───────────────────────────────────────────────────────────────
- name: Set reusable strings
id: strings
shell: bash
run: |
echo "build-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
# Logical CPU count — each platform exposes it differently.
if [ "$RUNNER_OS" = "Windows" ]; then echo "jobs=$NUMBER_OF_PROCESSORS"
elif [ "$RUNNER_OS" = "macOS" ]; then echo "jobs=$(sysctl -n hw.logicalcpu)"
else echo "jobs=$(nproc)"
fi >> "$GITHUB_OUTPUT"
- name: Configure CMake
shell: bash
run: |
CMAKE_ARGS=(
"-B" "${{ steps.strings.outputs.build-dir }}"
"-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}"
"-DQB_BUILD_TESTS=ON"
"-S" "${{ github.workspace }}"
)
# On POSIX hosts, pick the compiler explicitly.
# On Windows, the Visual Studio generator detects MSVC automatically.
if [ "$RUNNER_OS" != "Windows" ]; then
CMAKE_ARGS+=( "-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}" )
CMAKE_ARGS+=( "-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}" )
fi
# Inject the vcpkg toolchain on Windows so find_package/find_library
# resolve into the vcpkg installed tree.
if [ -n "${VCPKG_TOOLCHAIN}" ]; then
CMAKE_ARGS+=( "-DCMAKE_TOOLCHAIN_FILE=${VCPKG_TOOLCHAIN}" )
CMAKE_ARGS+=( "-DVCPKG_TARGET_TRIPLET=x64-windows" )
fi
cmake "${CMAKE_ARGS[@]}"
- name: Build
run: >
cmake --build ${{ steps.strings.outputs.build-dir }}
--config ${{ matrix.build_type }}
--parallel ${{ steps.strings.outputs.jobs }}
- name: Test
working-directory: ${{ steps.strings.outputs.build-dir }}
run: ctest --build-config ${{ matrix.build_type }} --output-on-failure --parallel 4