Skip to content

Commit 66952b1

Browse files
Aliaksandr Adziareikaalexadereyko
authored andcommitted
<TBBAS-2530> Add CI script installing prebuilt openDAQ, building module, and running tests
- Add download framework action - Add install framework action - Add determine openDAQ version action - Add build and test simple device module with binary framework package
1 parent ab04b2b commit 66952b1

File tree

13 files changed

+351
-48
lines changed

13 files changed

+351
-48
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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"
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: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
name: Determine latest openDAQ framework artefact
2+
3+
inputs:
4+
5+
opendaq-framework-release-version:
6+
required: false
7+
default: latest
8+
9+
win32-force:
10+
required: false
11+
default: false
12+
13+
outputs:
14+
15+
version:
16+
description: "Latest openDAQ release version"
17+
value: ${{ steps.determine-latest-package.outputs.version }}
18+
19+
platform:
20+
description: "Detected platform"
21+
value: ${{ steps.determine-latest-package.outputs.platform }}
22+
23+
packaging:
24+
description: "Package type (deb/exe)"
25+
value: ${{ steps.determine-latest-package.outputs.packaging }}
26+
27+
artefact:
28+
description: "Artefact filename"
29+
value: ${{ steps.determine-latest-package.outputs.artefact }}
30+
31+
uri:
32+
description: "Full URI to artefact"
33+
value: ${{ steps.determine-latest-package.outputs.uri }}
34+
35+
scheme:
36+
description: "Scheme (s3)"
37+
value: ${{ steps.determine-latest-package.outputs.scheme }}
38+
39+
authority:
40+
description: "Authority (bucket)"
41+
value: ${{ steps.determine-latest-package.outputs.authority }}
42+
43+
path:
44+
description: "Path inside bucket"
45+
value: ${{ steps.determine-latest-package.outputs.path }}
46+
47+
runs:
48+
using: composite
49+
steps:
50+
- name: Determine latest openDAQ package
51+
id: determine-latest-package
52+
shell: bash
53+
run: |
54+
set -e
55+
56+
input_version="${{ inputs.opendaq-framework-release-version }}"
57+
58+
if [[ -z "$input_version" || "$input_version" == "latest" ]]; then
59+
version=$(gh api repos/openDAQ/openDAQ/releases/latest --jq '.tag_name')
60+
if [[ -z "$version" || "$version" == "null" ]]; then
61+
echo "::error::Failed to determine latest openDAQ release version"
62+
exit 1
63+
fi
64+
65+
version=${version#v}
66+
else
67+
version="$input_version"
68+
fi
69+
70+
platform=""
71+
packaging=""
72+
73+
if [[ "$RUNNER_OS" == "Linux" ]]; then
74+
arch=$(uname -m)
75+
if [[ "$arch" == "x86_64" ]]; then
76+
platform="ubuntu22.04-x86_64"
77+
elif [[ "$arch" == "aarch64" ]]; then
78+
platform="ubuntu22.04-arm64"
79+
else
80+
echo "::error::Unsupported Linux arch: $arch"
81+
exit 1
82+
fi
83+
packaging="deb"
84+
85+
elif [[ "$RUNNER_OS" == "Windows" ]]; then
86+
WIN32_FORCE="${{ inputs.win32-force }}"
87+
if [[ "$WIN32_FORCE" == "true" ]]; then
88+
platform="win32"
89+
else
90+
platform="win64"
91+
fi
92+
packaging="exe"
93+
94+
else
95+
echo "::error::Unsupported runner OS $RUNNER_OS"
96+
exit 1
97+
fi
98+
99+
artefact="opendaq-${version}-${platform}.${packaging}"
100+
scheme="s3"
101+
authority="bb-blueberry-sdk-releases"
102+
sdk="releases/v${version}/SDK"
103+
104+
echo "version=$version" >> $GITHUB_OUTPUT
105+
echo "platform=$platform" >> $GITHUB_OUTPUT
106+
echo "packaging=$packaging" >> $GITHUB_OUTPUT
107+
echo "artefact=$artefact" >> $GITHUB_OUTPUT
108+
echo "scheme=$scheme" >> $GITHUB_OUTPUT
109+
echo "authority=$authority" >> $GITHUB_OUTPUT
110+
echo "path=$sdk" >> $GITHUB_OUTPUT
111+
echo "uri=${scheme}://${authority}/${sdk}/${artefact}" >> $GITHUB_OUTPUT

.github/workflows/ci.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Build and Test simple device module with latest openDAQ release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
pull_request:
9+
branches:
10+
- main
11+
- jira/*
12+
13+
workflow_dispatch:
14+
inputs:
15+
16+
branch:
17+
required: false
18+
default: "main"
19+
20+
opendaq-framework-version:
21+
required: false
22+
type: string
23+
default: latest
24+
25+
env:
26+
GH_TOKEN: ${{ github.token }}
27+
28+
jobs:
29+
build-and-test:
30+
31+
strategy:
32+
matrix:
33+
include:
34+
- os: ubuntu-latest
35+
generator: Ninja
36+
37+
- os: windows-latest
38+
generator: "Visual Studio 17 2022"
39+
40+
runs-on: ${{ matrix.os }}
41+
42+
steps:
43+
- name: Checkout simple device module repo
44+
uses: actions/checkout@v4
45+
with:
46+
ref: ${{ github.event.inputs.branch || github.event.client_payload.branch || github.ref }}
47+
48+
- name: Determine openDAQ framework package
49+
id: opendaq-framework
50+
uses: ./.github/actions/framework-latest-release
51+
with:
52+
opendaq-framework-release-version: ${{ github.event.inputs.opendaq-framework-version || 'latest' }}
53+
54+
- name: Download openDAQ framework
55+
uses: ./.github/actions/framework-download
56+
with:
57+
src-opendaq-framework-dev: ${{ steps.opendaq-framework.outputs.uri }}
58+
dst-opendaq-framework-dev: ${{ runner.temp }}/${{ steps.opendaq-framework.outputs.artefact }}
59+
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
60+
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
61+
aws_region: ${{ secrets.AWS_REGION }}
62+
63+
- name: Install openDAQ framework package
64+
uses: ./.github/actions/framework-install
65+
with:
66+
opendaq-framework-package-filename: ${{ steps.opendaq-framework.outputs.artefact }}
67+
68+
- name: Configure simple device module with CMake
69+
run: cmake -B build/output -S . -G "${{ matrix.generator }}" -DEXAMPLE_MODULE_ENABLE_TESTS=ON -DCMAKE_BUILD_TYPE=Release
70+
71+
- name: Build simple device module with CMake
72+
run: cmake --build build/output --config Release
73+
74+
- name: Run simple device module tests with CMake
75+
run: ctest --test-dir build/output --output-on-failure -C Release -V

CMakeLists.txt

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,23 @@
11
cmake_minimum_required(VERSION 3.25)
2-
set(REPO_NAME example_device_module)
2+
project(SimpleDeviceModule VERSION 1.0.0)
3+
4+
set(SIMPLE_DEVICE_MODULE_OPENDAQ_SDK_VER "" CACHE STRING "Version of openDAQ SDK to build SimpleDeviceModule with")
5+
36
set(REPO_OPTION_PREFIX EXAMPLE_MODULE)
7+
set(SDK_TARGET_NAMESPACE daq)
8+
9+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
10+
set(CMAKE_MESSAGE_CONTEXT_SHOW ON CACHE BOOL "Show CMake message context")
11+
12+
option(EXAMPLE_MODULE_ENABLE_TESTS "Enable building tests for example_module" ON)
13+
option(SIMPLE_DEVICE_MODULE_ENABLE_SERVER_APP "Enable building example server application" OFF)
14+
if(SIMPLE_DEVICE_MODULE_ENABLE_SERVER_APP)
15+
set(DAQMODULES_OPENDAQ_SERVER_MODULE ON CACHE BOOL "" FORCE)
16+
set(OPENDAQ_ENABLE_NATIVE_STREAMING ON CACHE BOOL "" FORCE)
17+
endif()
418

5-
project(${REPO_NAME} VERSION 1.0.0)
19+
list(APPEND CMAKE_MESSAGE_CONTEXT ${PROJECT_NAME})
20+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
621

722
if (POLICY CMP0135)
823
cmake_policy(SET CMP0135 NEW)
@@ -12,29 +27,21 @@ if (POLICY CMP0077)
1227
cmake_policy(SET CMP0077 NEW)
1328
endif()
1429

15-
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
16-
list(APPEND CMAKE_MESSAGE_CONTEXT ${REPO_NAME})
17-
set(CMAKE_MESSAGE_CONTEXT_SHOW ON CACHE BOOL "Show CMake message context")
18-
19-
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
20-
2130
add_definitions(-DFMT_HEADER_ONLY)
2231

23-
option(OPENDAQ_DEVICE_EXAMPLE_ENABLE_SERVER_APP "Enable building example server application" OFF)
24-
2532
include(CommonUtils)
2633
setup_repo(${REPO_OPTION_PREFIX})
2734

28-
if(OPENDAQ_DEVICE_EXAMPLE_ENABLE_SERVER_APP)
29-
set(DAQMODULES_OPENDAQ_SERVER_MODULE ON CACHE BOOL "" FORCE)
30-
set(OPENDAQ_ENABLE_NATIVE_STREAMING ON CACHE BOOL "" FORCE)
35+
if (EXAMPLE_MODULE_ENABLE_TESTS)
36+
message(STATUS "Unit tests are ENABLED")
37+
enable_testing()
3138
endif()
3239

3340
add_subdirectory(external)
3441
add_subdirectory(example_module)
3542

36-
if(OPENDAQ_DEVICE_EXAMPLE_ENABLE_SERVER_APP)
37-
message(STATUS "Enbled example server application")
43+
if(SIMPLE_DEVICE_MODULE_ENABLE_SERVER_APP)
44+
message(STATUS "Enbled example server application")
3845
add_subdirectory(server_application)
3946
endif()
4047

@@ -56,4 +63,4 @@ elseif (UNIX AND NOT APPLE)
5663
endif()
5764

5865
# Include CPack for packaging
59-
include(CPack)
66+
include(CPack)

example_module/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ project(ExampleModule VERSION 1.0.0 LANGUAGES CXX)
33

44
add_subdirectory(src)
55

6-
if (OPENDAQ_ENABLE_TESTS)
6+
if (EXAMPLE_MODULE_ENABLE_TESTS)
77
add_subdirectory(tests)
88
endif()

example_module/src/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
set(LIB_NAME example_module)
22
set(MODULE_HEADERS_DIR ../include/${TARGET_FOLDER_NAME})
3+
list(APPEND CMAKE_MESSAGE_CONTEXT ${LIB_NAME})
34

45
set(SRC_Include common.h
56
module_dll.h
@@ -37,6 +38,7 @@ if (MSVC)
3738
target_compile_options(${LIB_NAME} PRIVATE /bigobj)
3839
endif()
3940

41+
find_package(openDAQ ${SIMPLE_DEVICE_MODULE_OPENDAQ_SDK_VER} REQUIRED)
4042
target_link_libraries(${LIB_NAME} PUBLIC daq::opendaq
4143
)
4244

0 commit comments

Comments
 (0)