Skip to content

Commit 68daa9f

Browse files
author
Aliaksandr Adziareika
committed
<TBBAS-2530> Add CI script installing prebuilt openDAQ, building module, running tests, and uploading reports
- Add download framework action - Add install framework action - Add determine openDAQ version action - Set export example device module interface explicitly for Windows builds
1 parent ab04b2b commit 68daa9f

File tree

12 files changed

+387
-27
lines changed

12 files changed

+387
-27
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Setup build tools on Windows
2+
3+
outputs:
4+
vcpkg-toolchain-file:
5+
value: ${{ steps.cvpkg-toolchain.outputs.filename }}
6+
7+
8+
runs:
9+
using: composite
10+
steps:
11+
- name: Install Chocolatey (if not installed)
12+
shell: pwsh
13+
run: |
14+
if (-not (Get-Command choco -ErrorAction SilentlyContinue)) {
15+
Set-ExecutionPolicy Bypass -Scope Process -Force
16+
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
17+
Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
18+
}
19+
20+
- name: Install CMake 4
21+
shell: pwsh
22+
run: |
23+
$cmakeVersion = (cmake --version | Select-String -Pattern "cmake version").ToString().Split()[2]
24+
Write-Host "Detected CMake version: $cmakeVersion"
25+
26+
if ([Version]$cmakeVersion -lt [Version]"4.0.3") {
27+
Write-Host "Installing CMake 4.0.3..."
28+
choco install cmake --version=4.0.3 --installargs '"ADD_CMAKE_TO_PATH=System"' -y
29+
} else {
30+
Write-Host "CMake $cmakeVersion is already >= 4.0.3. Skipping install."
31+
}
32+
33+
- name: Clone vcpkg
34+
shell: pwsh
35+
run: |
36+
$vcpkgRoot = "C:/vcpkg"
37+
38+
if (Test-Path "$vcpkgRoot/vcpkg.exe") {
39+
Write-Host "✅ vcpkg already installed at $vcpkgRoot"
40+
"$vcpkgRoot/bootstrap-vcpkg.bat"
41+
}
42+
else {
43+
if (Test-Path $vcpkgRoot) {
44+
Write-Host "⚠️ Found $vcpkgRoot but it's not a valid vcpkg, cleaning up..."
45+
Remove-Item -Recurse -Force $vcpkgRoot
46+
}
47+
git clone https://github.com/microsoft/vcpkg.git $vcpkgRoot
48+
& "$vcpkgRoot/bootstrap-vcpkg.bat"
49+
}
50+
51+
- name: Install fmt via vcpkg
52+
shell: pwsh
53+
run: |
54+
C:\vcpkg\vcpkg install date fmt tsl-ordered-map pkgconf xxhash
55+
56+
- name: Set CMake toolchain file for vcpkg
57+
id: cvpkg-toolchain
58+
shell: pwsh
59+
run: |
60+
echo "filename=C:/vcpkg/scripts/buildsystems/vcpkg.cmake" > $env:GITHUB_OUTPUT
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Download openDAQ framework package
2+
description: "Download a package from S3 for Linux or Windows"
3+
4+
inputs:
5+
src-opendaq-framework-dev:
6+
required: true
7+
description: "S3 path to the package"
8+
dst-opendaq-framework-dev:
9+
required: false
10+
default: ${{ runner.temp }}
11+
description: "Destination path for downloaded package"
12+
13+
aws_access_key_id:
14+
required: true
15+
description: "AWS Access Key ID"
16+
aws_secret_access_key:
17+
required: true
18+
description: "AWS Secret Access Key"
19+
aws_region:
20+
required: true
21+
description: "AWS Region"
22+
23+
runs:
24+
using: composite
25+
steps:
26+
- name: Configure AWS
27+
uses: aws-actions/configure-aws-credentials@v4
28+
with:
29+
aws-access-key-id: ${{ inputs.aws_access_key_id }}
30+
aws-secret-access-key: ${{ inputs.aws_secret_access_key }}
31+
aws-region: ${{ inputs.aws_region }}
32+
33+
- name: Download package from S3 (Linux/macOS)
34+
if: runner.os != 'Windows'
35+
shell: bash
36+
run: |
37+
set -e
38+
DST="${{ inputs.dst-opendaq-framework-dev }}"
39+
SRC="${{ inputs.src-opendaq-framework-dev }}"
40+
echo "Downloading $SRC to $DST"
41+
aws s3 cp "$SRC" "$DST"
42+
43+
- name: Download package from S3 (Windows)
44+
if: runner.os == 'Windows'
45+
shell: pwsh
46+
run: |
47+
$dst = "${{ inputs.dst-opendaq-framework-dev }}"
48+
$src = "${{ inputs.src-opendaq-framework-dev }}"
49+
Write-Host "Downloading $src to $dst"
50+
aws s3 cp "$src" "$dst"
51+
52+
- name: Upload Windows installer as artifact
53+
if: runner.os == 'Windows'
54+
uses: actions/upload-artifact@v4
55+
with:
56+
name: opendaq-installer
57+
path: ${{ inputs.dst-opendaq-framework-dev }}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Install openDAQ framework package
2+
3+
inputs:
4+
opendaq-framework-package-filename:
5+
required: true
6+
7+
opendaq-framework-package-path:
8+
required: false
9+
default: ${{ runner.temp }}
10+
11+
runs:
12+
using: composite
13+
14+
steps:
15+
- name: Install openDAQ framework package (Windows)
16+
if: runner.os == 'Windows'
17+
shell: pwsh
18+
run: |
19+
$packagePath = Join-Path "${{ inputs.opendaq-framework-package-path }}" "${{ inputs.opendaq-framework-package-filename }}"
20+
$process = Start-Process -FilePath $packagePath -ArgumentList "/S" -Wait -NoNewWindow -PassThru
21+
if ($process.ExitCode -eq 0) {
22+
Write-Host "OpenDAQ installed successfully, updating PATH..."
23+
$openDAQBin = "C:\Program Files\openDAQ\bin"
24+
Add-Content -Path $env:GITHUB_ENV -Value "PATH=$openDAQBin`;$env:PATH"
25+
Write-Host $env:PATH
26+
}
27+
else {
28+
Write-Host "OpenDAQ installation failed with exit code $($process.ExitCode)"
29+
exit $process.ExitCode
30+
}
31+
32+
- name: Install openDAQ framework package (Linux)
33+
if: runner.os == 'Linux'
34+
shell: bash
35+
run: sudo dpkg -i "${{ inputs.opendaq-framework-package-path }}/${{ inputs.opendaq-framework-package-filename }}"
36+
37+
- name: Unsupported runner OS
38+
if: runner.os != 'Windows' && runner.os != 'Linux'
39+
shell: bash
40+
run: |
41+
echo "Install openDAQ is not supported for ${{ runner.os }}"
42+
exit 1
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: Determine latest openDAQ framework artefact
2+
3+
inputs:
4+
win32-force:
5+
required: false
6+
default: false
7+
8+
outputs:
9+
version:
10+
description: "Latest openDAQ release version"
11+
value: ${{ steps.determine-latest-package.outputs.version }}
12+
platform:
13+
description: "Detected platform"
14+
value: ${{ steps.determine-latest-package.outputs.platform }}
15+
packaging:
16+
description: "Package type (deb/exe)"
17+
value: ${{ steps.determine-latest-package.outputs.packaging }}
18+
artefact:
19+
description: "Artefact filename"
20+
value: ${{ steps.determine-latest-package.outputs.artefact }}
21+
uri:
22+
description: "Full URI to artefact"
23+
value: ${{ steps.determine-latest-package.outputs.uri }}
24+
scheme:
25+
description: "Scheme (s3)"
26+
value: ${{ steps.determine-latest-package.outputs.scheme }}
27+
authority:
28+
description: "Authority (bucket)"
29+
value: ${{ steps.determine-latest-package.outputs.authority }}
30+
path:
31+
description: "Path inside bucket"
32+
value: ${{ steps.determine-latest-package.outputs.path }}
33+
34+
runs:
35+
using: composite
36+
steps:
37+
- name: Determine latest openDAQ package
38+
id: determine-latest-package
39+
shell: bash
40+
run: |
41+
set -e
42+
43+
version=$(gh api repos/openDAQ/openDAQ/releases/latest --jq '.tag_name')
44+
if [[ -z "$version" || "$version" == "null" ]]; then
45+
echo "::error::Failed to determine latest openDAQ release version"
46+
exit 1
47+
fi
48+
49+
version=${version#v}
50+
platform=""
51+
packaging=""
52+
53+
if [[ "$RUNNER_OS" == "Linux" ]]; then
54+
arch=$(uname -m)
55+
if [[ "$arch" == "x86_64" ]]; then
56+
platform="ubuntu22.04-x86_64"
57+
elif [[ "$arch" == "aarch64" ]]; then
58+
platform="ubuntu22.04-arm64"
59+
else
60+
echo "::error::Unsupported Linux arch: $arch"
61+
exit 1
62+
fi
63+
packaging="deb"
64+
65+
elif [[ "$RUNNER_OS" == "Windows" ]]; then
66+
WIN32_FORCE="${{ inputs.win32-force }}"
67+
if [[ "$WIN32_FORCE" == "true" ]]; then
68+
platform="win32"
69+
else
70+
platform="win64"
71+
fi
72+
packaging="exe"
73+
74+
else
75+
echo "::error::Unsupported runner OS $RUNNER_OS"
76+
exit 1
77+
fi
78+
79+
artefact="opendaq-${version}-${platform}.${packaging}"
80+
scheme="s3"
81+
authority="bb-blueberry-sdk-releases"
82+
sdk="releases/v${version}/SDK"
83+
84+
echo "version=$version" >> $GITHUB_OUTPUT
85+
echo "platform=$platform" >> $GITHUB_OUTPUT
86+
echo "packaging=$packaging" >> $GITHUB_OUTPUT
87+
echo "artefact=$artefact" >> $GITHUB_OUTPUT
88+
echo "scheme=$scheme" >> $GITHUB_OUTPUT
89+
echo "authority=$authority" >> $GITHUB_OUTPUT
90+
echo "path=$sdk" >> $GITHUB_OUTPUT
91+
echo "uri=${scheme}://${authority}/${sdk}/${artefact}" >> $GITHUB_OUTPUT

.github/workflows/ci.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Build and Test simple device module with latest openDAQ release
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
- jira/*
8+
9+
env:
10+
GH_TOKEN: ${{ github.token }}
11+
12+
jobs:
13+
build-and-test:
14+
runs-on: ${{ matrix.os }}
15+
16+
strategy:
17+
matrix:
18+
os: [ubuntu-latest, windows-latest]
19+
20+
steps:
21+
- name: Checkout simple device module repo
22+
uses: actions/checkout@v4
23+
24+
- name: Determine openDAQ framework package
25+
id: opendaq-framework
26+
uses: ./.github/actions/framework-latest-release
27+
28+
- name: Download openDAQ framework
29+
uses: ./.github/actions/framework-download
30+
with:
31+
src-opendaq-framework-dev: ${{ steps.opendaq-framework.outputs.uri }}
32+
dst-opendaq-framework-dev: ${{ runner.temp }}/${{ steps.opendaq-framework.outputs.artefact }}
33+
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
34+
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
35+
aws_region: ${{ secrets.AWS_REGION }}
36+
37+
- name: Install openDAQ framework package
38+
uses: ./.github/actions/framework-install
39+
with:
40+
opendaq-framework-package-filename: ${{ steps.opendaq-framework.outputs.artefact }}
41+
42+
# - name: Archive installed openDAQ
43+
# if: runner.os == 'Windows'
44+
# shell: pwsh
45+
# run: |
46+
# Compress-Archive -Path "C:/Program Files/openDAQ" -DestinationPath "$env:RUNNER_TEMP/opendaq.zip"
47+
48+
# - name: Upload openDAQ artifact
49+
# if: runner.os == 'Windows'
50+
# uses: actions/upload-artifact@v4
51+
# with:
52+
# name: opendaq-install
53+
# path: ${{ runner.temp }}/opendaq.zip
54+
55+
# - name: Install Windows dependencies
56+
# id: windows-dependencies-install
57+
# if: runner.os == 'Windows'
58+
# uses: ./.github/actions/dependencies-install
59+
60+
- name: Configure simple device module with CMake Windows
61+
if: runner.os == 'Windows'
62+
# run: cmake -B build/output -S . -G Ninja -DOPENDAQ_ENABLE_TESTS=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=${{ steps.windows-dependencies-install.outputs.vcpkg-toolchain-file }}
63+
run: cmake -B build/output -S . -G "Visual Studio 17 2022" -DOPENDAQ_ENABLE_TESTS=ON -DOPENDAQ_MSVC_SINGLE_PROCESS_BUILD=ON -DDAQMODULES_PARQUET_RECORDER_MODULE=ON -DCMAKE_BUILD_TYPE=Release
64+
65+
- name: Build simple device module with CMake Windows
66+
if: runner.os == 'Windows'
67+
run: cmake --build build/output --config Release
68+
69+
- name: Run simple device module tests via CTest with GTest report Windows
70+
if: runner.os == 'Windows'
71+
run: |
72+
New-Item -ItemType Directory -Force -Path build/reports | Out-Null
73+
$env:GTEST_OUTPUT = "xml:$PWD/build/reports/gtest-report.xml"
74+
ctest --test-dir build/output --output-on-failure -C Release -V
75+
76+
- name: Configure simple device module with CMake
77+
if: runner.os != 'Windows'
78+
run: cmake -B build/output -S . -G Ninja -DOPENDAQ_ENABLE_TESTS=ON -DCMAKE_BUILD_TYPE=Release
79+
80+
- name: Build simple device module with CMake
81+
if: runner.os != 'Windows'
82+
run: cmake --build build/output --target all
83+
84+
- name: Run simple device module tests via CTest with GTest report
85+
if: runner.os != 'Windows'
86+
run: |
87+
mkdir -p build/reports
88+
GTEST_OUTPUT=xml:$(pwd)/build/reports/gtest-report.xml ctest --test-dir build/output --output-on-failure -V

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
cmake_minimum_required(VERSION 3.25)
22
set(REPO_NAME example_device_module)
33
set(REPO_OPTION_PREFIX EXAMPLE_MODULE)
4+
set(SDK_TARGET_NAMESPACE daq)
45

56
project(${REPO_NAME} VERSION 1.0.0)
67

@@ -30,6 +31,11 @@ if(OPENDAQ_DEVICE_EXAMPLE_ENABLE_SERVER_APP)
3031
set(OPENDAQ_ENABLE_NATIVE_STREAMING ON CACHE BOOL "" FORCE)
3132
endif()
3233

34+
if (OPENDAQ_ENABLE_TESTS)
35+
message(STATUS "Unit tests are ENABLED")
36+
enable_testing()
37+
endif()
38+
3339
add_subdirectory(external)
3440
add_subdirectory(example_module)
3541

example_module/src/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,16 @@ add_library(${LIB_NAME} SHARED ${SRC_Include}
3232
)
3333

3434
add_library(${SDK_TARGET_NAMESPACE}::${LIB_NAME} ALIAS ${LIB_NAME})
35+
if(WIN32 AND (MSVC OR MINGW))
36+
message(STATUS "WIN32 AND (MSVC OR MINGW) -> set OPENDAQ_MODULE_EXPORTS")
37+
target_compile_definitions(${LIB_NAME} PUBLIC OPENDAQ_MODULE_EXPORTS)
38+
endif()
3539

3640
if (MSVC)
3741
target_compile_options(${LIB_NAME} PRIVATE /bigobj)
3842
endif()
3943

44+
find_package(openDAQ 3.20.4 REQUIRED)
4045
target_link_libraries(${LIB_NAME} PUBLIC daq::opendaq
4146
)
4247

0 commit comments

Comments
 (0)