Skip to content
Draft
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
200 changes: 200 additions & 0 deletions .github/actions/build-sdk/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
name: Build openDAQ SDK
description: Configure, build and test openDAQ SDK

inputs:
additional-dependencies:
description: 'Additional packages to install (apt on Linux, choco on Windows)'
required: false
default: ''
cmake-generator:
description: 'CMake generator (e.g., "Ninja", "Visual Studio 17 2022")'
required: false
default: ''
cmake-config-preset:
description: 'CMake configure preset name'
required: false
default: ''
cmake-config-args:
description: 'Additional CMake configure arguments (e.g., -D flags)'
required: false
default: ''
cmake-build-type:
description: 'Build configuration (Release, Debug). Required for multi-config generators (Visual Studio)'
required: false
default: ''
enable-32bit:
description: 'Build for 32-bit architecture'
required: false
default: 'false'
enable-tests:
description: 'Run tests after build'
required: false
default: 'false'
ctest-preset:
description: 'CTest preset name'
required: false
default: ''

outputs:
gtest-xml-path:
description: 'Path to GTest XML reports directory'
value: ${{ steps.test.outputs.gtest-xml-path }}

runs:
using: composite
steps:
- name: Check inputs
shell: bash
env:
CMAKE_GENERATOR: ${{ inputs.cmake-generator }}
run: |
if [ -z "$CMAKE_GENERATOR" ]; then
echo "::error::✗ The cmake-generator input is not set."
exit 1
fi

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.14'
architecture: ${{ inputs.enable-32bit == 'true' && 'x86' || 'x64' }}

- name: Setup cmake
uses: jwlawson/actions-setup-cmake@v2

- name: Install Windows dependencies
if: runner.os == 'Windows' && inputs.additional-dependencies != ''
shell: pwsh
run: choco install ${{ inputs.additional-dependencies }} -y --no-progress

- name: Install Linux dependencies
if: runner.os == 'Linux'
shell: bash
run: |
sudo apt-get update && sudo apt-get install -y --no-install-recommends \
${{ inputs.additional-dependencies || '' }} \
lld mono-runtime libmono-system-json-microsoft4.0-cil libmono-system-data4.0-cil \
libx11-dev libxi-dev libxcursor-dev libxrandr-dev libgl-dev libudev-dev libfreetype6-dev

- name: Install macOS dependencies
if: runner.os == 'macOS'
shell: bash
run: |
HOMEBREW_NO_AUTO_UPDATE=1 brew install mono ${{ inputs.additional-dependencies }}

- name: Install ninja-build
if: inputs.cmake-generator == 'Ninja'
uses: seanmiddleditch/gha-setup-ninja@v5

- name: Setup MSYS2 MINGW64
if: runner.os == 'Windows'
id: msys2
uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
update: false
install: mingw-w64-x86_64-crt-git mingw-w64-x86_64-gcc

- name: Add MSYS2 MINGW64 to PATH
if: runner.os == 'Windows'
shell: bash
run: |
echo "${{ steps.msys2.outputs.msys2-location }}/mingw64/bin" >> $GITHUB_PATH
echo "Added MSYS2 MINGW64 to PATH: ${{ steps.msys2.outputs.msys2-location }}/mingw64/bin"

# https://github.com/actions/runner-images/issues/10001
- name: Setup MSVC toolchain
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1

- name: Install Python dependencies
shell: bash
run: |
echo "Installing numpy for Python versions: $(python --version)"
python -m pip install numpy
echo "Done installing Python dependencies"

- name: Configure
id: cmake-config
shell: bash
env:
CMAKE_BUILD_TYPE: ${{ inputs.cmake-build-type }}
CMAKE_GENERATOR: ${{ inputs.cmake-generator }}
CI_GIT_BRANCH: ${{ github.head_ref }}
run: |
CMAKE_BUILD_PATH="build"
mkdir -p "$CMAKE_BUILD_PATH"
CMAKE_BUILD_PATH=$(cd "$CMAKE_BUILD_PATH" && pwd)
echo "build-path=$CMAKE_BUILD_PATH" >> "$GITHUB_OUTPUT"

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

# Visual Studio specific options
if [[ "$CMAKE_GENERATOR" == "Visual Studio"* ]]; then
CMAKE_ARGS="$CMAKE_ARGS -DOPENDAQ_MSVC_SINGLE_PROCESS_BUILD=ON"
fi

if [ -n "$CMAKE_BUILD_TYPE" ]; then
CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE"
fi

CMAKE_ARGS="$CMAKE_ARGS -DCI_GIT_BRANCH=$CI_GIT_BRANCH"

echo "::group::CMake Configure"
cmake -B "$CMAKE_BUILD_PATH" -G "$CMAKE_GENERATOR" $CMAKE_ARGS ${{ inputs.cmake-config-args }}
echo "::endgroup::"

- name: Build
shell: bash
env:
SHORT_SHA: ci # .NET bindings version suffix (e.g., 1.0.0-beta-ci)
CMAKE_BUILD_TYPE: ${{ inputs.cmake-build-type }}
CMAKE_BUILD_PATH: ${{ steps.cmake-config.outputs.build-path }}
run: |
CMAKE_BUILD_ARGS=""
if [ -n "$CMAKE_BUILD_TYPE" ]; then
CMAKE_BUILD_ARGS="--config $CMAKE_BUILD_TYPE"
fi

echo "::group::CMake Build"
cmake --build "$CMAKE_BUILD_PATH" $CMAKE_BUILD_ARGS
echo "::endgroup::"

- name: Test
id: test
if: inputs.enable-tests == 'true'
shell: bash
env:
CMAKE_BUILD_TYPE: ${{ inputs.cmake-build-type }}
CMAKE_BUILD_PATH: ${{ steps.cmake-config.outputs.build-path }}
run: |
GTEST_XML_PATH="$CMAKE_BUILD_PATH/test_results"
mkdir -p "$GTEST_XML_PATH"

if command -v cygpath &> /dev/null; then
GTEST_XML_PATH=$(cygpath -w "$GTEST_XML_PATH")
fi

export GTEST_OUTPUT="xml:$GTEST_XML_PATH/"
echo "gtest-xml-path=$GTEST_XML_PATH" >> "$GITHUB_OUTPUT"

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

if [ -n "$CMAKE_BUILD_TYPE" ]; then
CTEST_ARGS="$CTEST_ARGS --build-config $CMAKE_BUILD_TYPE"
fi

SUDO_CMD=""
if command -v sudo &> /dev/null; then
SUDO_CMD="sudo -E"
fi

echo "::group::CTest"
$SUDO_CMD ctest --test-dir "$CMAKE_BUILD_PATH" --output-on-failure $CTEST_ARGS
echo "::endgroup::"
97 changes: 97 additions & 0 deletions .github/actions/setup-compiler-oneapi/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: Setup Intel oneAPI Compiler
description: Install and configure Intel oneAPI C++ compiler (icx)

runs:
using: composite
steps:
- name: Download installer
if: runner.os == 'Windows'
id: download-windows
shell: pwsh
run: |
$url = "https://registrationcenter-download.intel.com/akdlm/IRC_NAS/1f18901e-877d-469d-a41a-a10f11b39336/intel-oneapi-base-toolkit-2025.3.0.372_offline.exe"
$output = "$env:TEMP\oneapi_installer.exe"

Write-Host "Downloading Intel oneAPI Base Toolkit..."
Write-Host "See: https://github.com/oneapi-src/oneapi-ci"
Write-Host "URL: $url"
Write-Host "Output: $output"

curl.exe -L -o $output $url --retry 5 --retry-delay 5 --fail --show-error

if ($LASTEXITCODE -ne 0) {
Write-Error "Download failed with exit code $LASTEXITCODE"
exit 1
}

if (-not (Test-Path $output)) {
Write-Error "Downloaded file not found: $output"
exit 1
}

$size = (Get-Item $output).Length / 1MB
Write-Host "Download complete: $([math]::Round($size, 2)) MB"

- name: Install oneAPI
if: runner.os == 'Windows'
id: install-windows
shell: pwsh
run: |
Write-Host "Extracting installer..."
$extract = Start-Process -Wait -PassThru -FilePath "$env:TEMP\oneapi_installer.exe" `
-ArgumentList "-s", "-x", "-f", "$env:TEMP\oneapi_extracted", "--log", "extract.log"
if ($extract.ExitCode -ne 0) {
Write-Error "Extraction failed with exit code $($extract.ExitCode)"
Get-Content extract.log -ErrorAction SilentlyContinue
exit 1
}

Write-Host "Installing component: intel.oneapi.win.cpp-dpcpp-common"
$installArgs = "-s --action install --eula=accept --components=intel.oneapi.win.cpp-dpcpp-common -p=NEED_VS2017_INTEGRATION=0 -p=NEED_VS2019_INTEGRATION=0 -p=NEED_VS2022_INTEGRATION=0 --log-dir=."
Write-Host "Running: bootstrapper.exe $installArgs"
$install = Start-Process -Wait -PassThru -FilePath "$env:TEMP\oneapi_extracted\bootstrapper.exe" -ArgumentList $installArgs
if ($install.ExitCode -ne 0) {
Write-Error "Installation failed with exit code $($install.ExitCode)"
Get-ChildItem *.log | ForEach-Object { Write-Host "=== $($_.Name) ==="; Get-Content $_ }
exit 1
}

# Verify installation
$compilerPath = "C:\Program Files (x86)\Intel\oneAPI\compiler"
if (-not (Test-Path $compilerPath)) {
Write-Error "Compiler directory not found after installation"
Write-Host "Contents of Intel oneAPI directory:"
Get-ChildItem "C:\Program Files (x86)\Intel\oneAPI" -ErrorAction SilentlyContinue
exit 1
}
Write-Host "Installation complete"
Get-ChildItem $compilerPath

# Cleanup installer files
Remove-Item -Force "$env:TEMP\oneapi_installer.exe" -ErrorAction SilentlyContinue
Remove-Item -Recurse -Force "$env:TEMP\oneapi_extracted" -ErrorAction SilentlyContinue

# Output scripts for environment setup
"scripts<<EOF" >> $env:GITHUB_OUTPUT
"C:\Program Files (x86)\Intel\oneAPI\setvars-vcvarsall.bat" >> $env:GITHUB_OUTPUT
"C:\Program Files (x86)\Intel\oneAPI\compiler\latest\env\vars.bat" >> $env:GITHUB_OUTPUT
"EOF" >> $env:GITHUB_OUTPUT

- name: Export oneAPI environment
if: runner.os == 'Windows'
uses: ./.github/actions/source-script
with:
scripts: ${{ steps.install-windows.outputs.scripts }}

- name: Verify compiler
if: runner.os == 'Windows'
shell: pwsh
run: |
Write-Host "Verifying Intel oneAPI compiler..."
$icxPath = Get-Command icx -ErrorAction SilentlyContinue
if (-not $icxPath) {
Write-Error "icx compiler not found in PATH"
exit 1
}
Write-Host "Found: $($icxPath.Source)"
icx --version
65 changes: 65 additions & 0 deletions .github/actions/source-script/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: 'Source Script'
description: 'Run scripts and export environment variable changes to GITHUB_ENV'
inputs:
scripts:
description: 'Scripts to run that modify environment (one per line, .bat, .cmd, .sh, etc.)'
required: true

runs:
using: composite
steps:
- name: Source scripts and export env changes
shell: pwsh
run: |
$scripts = @"
${{ inputs.scripts }}
"@ -split "`n" | ForEach-Object { $_.Trim() } | Where-Object { $_ }

# Save current env
$before = @{}
Get-ChildItem Env: | ForEach-Object { $before[$_.Name] = $_.Value }

# Run each script
foreach ($script in $scripts) {
Write-Host "Running: $script"

$ext = [System.IO.Path]::GetExtension($script).ToLower()
if ($ext -in '.bat', '.cmd') {
cmd /c "`"$script`"" 2>&1 | Out-Null
$output = cmd /c "`"$script`" && set" 2>&1
} else {
$output = bash -c "source '$script' >/dev/null 2>&1 && env" 2>&1
}

# Update env for next script
$output | ForEach-Object {
if ($_ -match '^([^=]+)=(.*)$') {
[Environment]::SetEnvironmentVariable($Matches[1], $Matches[2], 'Process')
}
}
}

# Get final env state
$after = @{}
Get-ChildItem Env: | ForEach-Object { $after[$_.Name] = $_.Value }

# Export new/changed vars
$new = 0; $changed = 0
foreach ($key in $after.Keys) {
$newVal = $after[$key]
$oldVal = $before[$key]

if ($null -eq $oldVal) {
Write-Host " + $key"
$new++
} elseif ($oldVal -ne $newVal) {
Write-Host " ~ $key"
$changed++
} else {
continue
}

"$key=$newVal" >> $env:GITHUB_ENV
}

Write-Host "New: $new, Changed: $changed"
Loading
Loading