Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
8f81706
Add project purposes section to README
Nov 12, 2025
031d65b
Add reusable build SDK workflow with composite actions
Nov 12, 2025
02ad31b
Change CCACHE_BASEDIR to an absolute path
Nov 12, 2025
4a58f6f
Create ccache dir if it does't exist
Nov 12, 2025
56394a5
Set ccache dir as Windows path
Nov 12, 2025
34741dc
Add ccache-enable option
Nov 12, 2025
b4926ca
Add cmake-preset-name option
Nov 13, 2025
6f070ea
Add ctest customization arguments
Nov 14, 2025
674b81a
Fix tests working dir
Nov 14, 2025
4349752
Change CMake config args to build only core, change CTest build dir
Nov 17, 2025
0c9c51d
Temporary cache output directory to debug ctest call faster
Nov 17, 2025
94a3e77
Use openDAQ source path as working directory for cmake steps
Nov 17, 2025
8e6b1fb
Normalize cmake working directory depending on a runner os
Nov 17, 2025
9443a37
Enable tests and cache build output dir
Nov 17, 2025
3dcaee4
Set cmake args as a list
Nov 17, 2025
4eb7bfe
Add ctest configuration argument initialized by cmake config
Nov 17, 2025
78c6270
Fix gtest reports directory normalized according OS
Nov 17, 2025
16a6589
Add Ubuntu and MacOS runners
Nov 17, 2025
3cb1163
Add coreutils dependency for MacOS
Nov 17, 2025
4fceb11
Add cache key calculation according to OS version and arch
Nov 17, 2025
efd3b4a
Remove printing openDAQ working dir
Nov 18, 2025
2546c75
Reduce build-sdk action arguments list
Nov 18, 2025
124f984
Exclude failing tests for macos-latest runner
Nov 18, 2025
963c1cd
Fix excluded tests regex, replace unavailable macos-13 runner with ma…
Nov 18, 2025
581494c
Move CMake/CTest arguments from Setup to appropriate build steps
Nov 18, 2025
7644217
Reduce build-sdk setup step, optimise output values
Nov 18, 2025
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
319 changes: 319 additions & 0 deletions .github/actions/build-sdk/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,319 @@
name: Build openDAQ SDK
description: Configure and build openDAQ SDK

inputs:
source-path:
description: 'Path to openDAQ source directory (defaults to ".")'
required: false
default: ''
build-path:
description: 'Path for build directory (defaults to "{source-path}/build")'
required: false
default: ''
cmake-generator-name:
description: 'CMake generator name (e.g., "Ninja", "Visual Studio 17 2022")'
required: false
default: ''
cmake-preset-name:
description: 'CMake preset name (e.g., "package", "ci")'
required: false
default: ''
cmake-config:
description: 'CMake build configuration (Release, Debug, RelWithDebInfo, MinSizeRel)'
required: false
default: 'Release'
cmake-compiler:
description: 'CMake compiler configuration (e.g., "-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache")'
required: false
default: ''
cmake-config-args:
description: 'Additional CMake configure arguments'
required: false
default: ''
cmake-build-args:
description: 'Additional CMake build arguments'
required: false
default: ''
ccache-enable:
description: 'Enable compiler cache (works best with Ninja generator)'
required: false
default: 'false'
ctest-enable:
description: 'Run tests after build'
required: false
type: boolean
default: false
ctest-output-on-failure:
description: 'Output test output on failure (false = use preset setting)'
required: false
type: boolean
default: false
ctest-preset:
description: 'CTest preset name (e.g., "run_tests")'
required: false
default: ''
ctest-tests-regex:
description: 'Run only tests matching regex'
required: false
default: ''
ctest-exclude-regex:
description: 'Exclude tests matching regex'
required: false
default: ''
ctest-args:
description: 'Additional CTest arguments'
required: false
default: ''
cpack-generator-name:
description: 'CPack generator name (e.g., "DEB", "NSIS", "TGZ", "ZIP")'
required: false
default: ''

outputs:
version:
description: 'openDAQ version'
value: ${{ steps.read-version.outputs.version }}
commit-hash:
description: 'Short commit hash'
value: ${{ steps.read-version.outputs.commit-hash }}
package-path:
description: 'Native absolute path to packages directory (build/_packages)'
value: ${{ steps.setup.outputs.package-path }}
gtest-xml-path:
description: 'Native absolute path to GTest XML reports directory (test_results)'
value: ${{ steps.setup.outputs.gtest-xml-path }}

runs:
using: composite
steps:
- name: Setup paths and parameters
id: setup
shell: bash
run: |
IS_WINDOWS=$(command -v cygpath &> /dev/null && echo "1" || echo "")

# Initialize variables
SOURCE_PATH="${{ inputs.source-path }}"
SOURCE_PATH="${SOURCE_PATH:-.}"

BUILD_PATH="${{ inputs.build-path }}"
BUILD_PATH="${BUILD_PATH:-$SOURCE_PATH/build}"

# Convert to Unix-style paths on Windows
if [ -n "$IS_WINDOWS" ]; then
SOURCE_PATH=$(cygpath -u "$SOURCE_PATH")
BUILD_PATH=$(cygpath -u "$BUILD_PATH")
fi

# Create directories and convert to absolute paths
mkdir -p "$BUILD_PATH"
SOURCE_PATH=$(cd "$SOURCE_PATH" && pwd)
BUILD_PATH=$(cd "$BUILD_PATH" && pwd)

# Derive additional paths
GTEST_XML_PATH="$BUILD_PATH/test_results"
PACKAGE_PATH="$BUILD_PATH/_packages"

# Create directories and convert to native paths on Windows
mkdir -p "$GTEST_XML_PATH"
if [ -n "$IS_WINDOWS" ]; then
GTEST_XML_PATH=$(cygpath -w "$GTEST_XML_PATH")
PACKAGE_PATH=$(cygpath -w "$PACKAGE_PATH")
fi

# Write outputs
echo "source-path=$SOURCE_PATH" >> "$GITHUB_OUTPUT"
echo "build-path=$BUILD_PATH" >> "$GITHUB_OUTPUT"
echo "gtest-xml-path=$GTEST_XML_PATH" >> "$GITHUB_OUTPUT"
echo "package-path=$PACKAGE_PATH" >> "$GITHUB_OUTPUT"

if [ -n "$IS_WINDOWS" ]; then
echo "opendaq-working-dir=$(cygpath -w "$SOURCE_PATH")" >> "$GITHUB_OUTPUT"
else
echo "opendaq-working-dir=$SOURCE_PATH" >> "$GITHUB_OUTPUT"
fi

- name: Read version and commit hash
id: read-version
shell: bash
working-directory: ${{ steps.setup.outputs.opendaq-working-dir }}
run: |
# Read openDAQ version
version=$(cat opendaq_version)
version="v${version%%dev}"
echo "openDAQ version: $version"
echo "version=$version" >> "$GITHUB_OUTPUT"

# Get short commit hash
commit_hash=$(git rev-parse --short HEAD)
echo "Commit hash: $commit_hash"
echo "commit-hash=$commit_hash" >> "$GITHUB_OUTPUT"

- name: Setup compiler cache directory
if: inputs.ccache-enable == 'true'
id: ccache-config
shell: bash
working-directory: ${{ steps.setup.outputs.opendaq-working-dir }}
run: |
# Set ccache directory and create if it doesn't exist
CCACHE_DIR=".ccache"
mkdir -p "$CCACHE_DIR"
CCACHE_DIR="$(cd "$CCACHE_DIR" && pwd)"

# Windows-specific settings
if command -v cygpath &> /dev/null; then
CCACHE_DIR="$(cygpath -w "$CCACHE_DIR")"
CCACHE_BASEDIR="$(cygpath -w "$(pwd)")"
echo "CCACHE_DIR=$CCACHE_DIR" >> "$GITHUB_ENV"
echo "CCACHE_BASEDIR=$CCACHE_BASEDIR" >> "$GITHUB_ENV"
echo "CCACHE_SLOPPINESS=pch_defines,time_macros" >> "$GITHUB_ENV"
echo "Using CCACHE_DIR: $CCACHE_DIR"
echo "Using CCACHE_BASEDIR: $CCACHE_BASEDIR"
else
echo "CCACHE_DIR=$CCACHE_DIR" >> "$GITHUB_ENV"
echo "Using CCACHE_DIR: $CCACHE_DIR"
fi

echo "ccache-dir=$CCACHE_DIR" >> "$GITHUB_OUTPUT"

- name: Restore compiler cache
if: inputs.ccache-enable == 'true'
uses: actions/cache@v4
with:
path: ${{ steps.ccache-config.outputs.ccache-dir }}
key: ccache-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('**/*.c','**/*.cpp') }}
restore-keys: |
ccache-${{ runner.os }}-${{ runner.arch }}-

- name: Configure CMake
shell: bash
working-directory: ${{ steps.setup.outputs.opendaq-working-dir }}
run: |
echo "CMake Configuration:"
echo " Source: ${{ steps.setup.outputs.source-path }}"
echo " Build: ${{ steps.setup.outputs.build-path }}"
echo " Generator: ${{ inputs.cmake-generator-name }}"
echo " Preset: ${{ inputs.cmake-preset-name }}"
echo " Config: ${{ inputs.cmake-config }}"
echo ""

# Format CMake arguments
CMAKE_ARGS="-B ${{ steps.setup.outputs.build-path }}"

if [ -n "${{ inputs.cmake-generator-name }}" ]; then
CMAKE_ARGS="$CMAKE_ARGS -G \"${{ inputs.cmake-generator-name }}\""
fi

if [ -n "${{ inputs.cmake-preset-name }}" ]; then
CMAKE_ARGS="$CMAKE_ARGS --preset ${{ inputs.cmake-preset-name }}"
fi

if [ -n "${{ inputs.cmake-config }}" ]; then
CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_BUILD_TYPE=${{ inputs.cmake-config }}"
fi

if [ -n "${{ inputs.cmake-compiler }}" ]; then
CMAKE_ARGS="$CMAKE_ARGS ${{ inputs.cmake-compiler }}"
fi

if [ -n "${{ inputs.cmake-config-args }}" ]; then
CMAKE_ARGS="$CMAKE_ARGS ${{ inputs.cmake-config-args }}"
fi

echo "::group::CMake Configuration Output"
eval cmake $CMAKE_ARGS
echo "::endgroup::"
echo "✓ CMake configuration completed"

- name: Build
shell: bash
working-directory: ${{ steps.setup.outputs.opendaq-working-dir }}
run: |
echo "CMake Build:"
echo " Build dir: ${{ steps.setup.outputs.build-path }}"
echo " Config: ${{ inputs.cmake-config }}"
echo ""

# Format CMake build arguments
CMAKE_BUILD_ARGS="--build ${{ steps.setup.outputs.build-path }}"

if [ -n "${{ inputs.cmake-config }}" ]; then
CMAKE_BUILD_ARGS="$CMAKE_BUILD_ARGS --config ${{ inputs.cmake-config }}"
fi

if [ -n "${{ inputs.cmake-build-args }}" ]; then
CMAKE_BUILD_ARGS="$CMAKE_BUILD_ARGS ${{ inputs.cmake-build-args }}"
fi

echo "::group::CMake Build Output"
eval cmake $CMAKE_BUILD_ARGS
echo "::endgroup::"
echo "✓ Build completed successfully"

- name: Test
if: inputs.ctest-enable == 'true'
shell: bash
working-directory: ${{ steps.setup.outputs.opendaq-working-dir }}
env:
GTEST_OUTPUT: xml:${{ steps.setup.outputs.gtest-xml-path }}/
run: |
echo "Running tests:"
echo " Source dir: ${{ steps.setup.outputs.source-path }}"
echo " Build dir: ${{ steps.setup.outputs.build-path }}"
echo " GTest output: $GTEST_OUTPUT"
echo " CTest preset: ${{ inputs.ctest-preset }}"
echo ""

# Format CTest arguments
CTEST_ARGS="--test-dir ${{ steps.setup.outputs.build-path }}"

if [ -n "${{ inputs.cmake-config }}" ]; then
CTEST_ARGS="$CTEST_ARGS -C ${{ inputs.cmake-config }}"
fi

if [ "${{ inputs.ctest-output-on-failure }}" = "true" ]; then
CTEST_ARGS="$CTEST_ARGS --output-on-failure"
fi

if [ -n "${{ inputs.ctest-preset }}" ]; then
CTEST_ARGS="$CTEST_ARGS --preset ${{ inputs.ctest-preset }}"
fi

if [ -n "${{ inputs.ctest-tests-regex }}" ]; then
CTEST_ARGS="$CTEST_ARGS --tests-regex '${{ inputs.ctest-tests-regex }}'"
fi

if [ -n "${{ inputs.ctest-exclude-regex }}" ]; then
CTEST_ARGS="$CTEST_ARGS --exclude-regex '${{ inputs.ctest-exclude-regex }}'"
fi

if [ -n "${{ inputs.ctest-args }}" ]; then
CTEST_ARGS="$CTEST_ARGS ${{ inputs.ctest-args }}"
fi

echo "::group::CTest Output"
eval ctest $CTEST_ARGS
echo "::endgroup::"
echo "✓ Tests completed"

- name: Package
if: inputs.cpack-generator-name != ''
shell: bash
working-directory: ${{ steps.setup.outputs.opendaq-working-dir }}
run: |
echo "CPack Packaging:"
echo " Build dir: ${{ steps.setup.outputs.build-path }}"
echo " Generator: ${{ inputs.cpack-generator-name }}"
echo ""
echo "::group::CPack Output"
cpack --config "${{ steps.setup.outputs.build-path }}/CPackConfig.cmake" -G ${{ inputs.cpack-generator-name }}
echo "::endgroup::"
echo "✓ Package created successfully"

- name: Print compiler cache stats
if: inputs.ccache-enable == 'true'
shell: bash
run: |
echo "::group::Compiler cache statistics"
ccache -s -v
echo "::endgroup::"
Loading