Skip to content

Commit 9326e84

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 - Add build and test simple device module with binary framework package
1 parent ab04b2b commit 9326e84

File tree

13 files changed

+311
-48
lines changed

13 files changed

+311
-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: 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: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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+
15+
strategy:
16+
matrix:
17+
include:
18+
- os: ubuntu-latest
19+
generator: Ninja
20+
- os: windows-latest
21+
generator: "Visual Studio 17 2022"
22+
23+
runs-on: ${{ matrix.os }}
24+
25+
steps:
26+
- name: Checkout simple device module repo
27+
uses: actions/checkout@v4
28+
29+
- name: Determine openDAQ framework package
30+
id: opendaq-framework
31+
uses: ./.github/actions/framework-latest-release
32+
33+
- name: Download openDAQ framework
34+
uses: ./.github/actions/framework-download
35+
with:
36+
src-opendaq-framework-dev: ${{ steps.opendaq-framework.outputs.uri }}
37+
dst-opendaq-framework-dev: ${{ runner.temp }}/${{ steps.opendaq-framework.outputs.artefact }}
38+
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
39+
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
40+
aws_region: ${{ secrets.AWS_REGION }}
41+
42+
- name: Install openDAQ framework package
43+
uses: ./.github/actions/framework-install
44+
with:
45+
opendaq-framework-package-filename: ${{ steps.opendaq-framework.outputs.artefact }}
46+
47+
- name: Configure simple device module with CMake
48+
run: cmake -B build/output -S . -G "${{ matrix.generator }}" -DEXAMPLE_MODULE_ENABLE_TESTS=ON -DCMAKE_BUILD_TYPE=Release
49+
50+
51+
- name: Build simple device module with CMake
52+
run: cmake --build build/output --config Release
53+
54+
- name: Run simple device module tests with CMake
55+
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

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
set(MODULE_NAME example_module)
22
set(TEST_APP test_${MODULE_NAME})
3+
list(APPEND CMAKE_MESSAGE_CONTEXT ${TEST_APP})
34

45
set(TEST_SOURCES test_example_module.cpp
56
test_app.cpp
@@ -8,11 +9,33 @@ set(TEST_SOURCES test_example_module.cpp
89
add_executable(${TEST_APP} ${TEST_SOURCES}
910
)
1011

11-
target_link_libraries(${TEST_APP} PRIVATE daq::test_utils
12+
find_package(openDAQ ${SIMPLE_DEVICE_MODULE_OPENDAQ_SDK_VER} REQUIRED)
13+
target_link_libraries(${TEST_APP} PRIVATE daq::opendaq
1214
${SDK_TARGET_NAMESPACE}::${MODULE_NAME}
1315
)
1416

17+
if (NOT TARGET gtest)
18+
include(FetchContent)
19+
FetchContent_Declare(
20+
googletest
21+
URL https://github.com/google/googletest/archive/refs/tags/v1.14.0.zip
22+
)
23+
set(BUILD_GMOCK ON CACHE BOOL "" FORCE)
24+
set(BUILD_GTEST ON CACHE BOOL "" FORCE)
25+
FetchContent_MakeAvailable(googletest)
26+
endif()
27+
28+
target_link_libraries(${TEST_APP}
29+
PRIVATE
30+
GTest::gtest
31+
GTest::gtest_main
32+
GTest::gmock
33+
GTest::gmock_main
34+
)
35+
1536
add_test(NAME ${TEST_APP}
1637
COMMAND $<TARGET_FILE_NAME:${TEST_APP}>
17-
WORKING_DIRECTORY bin
38+
WORKING_DIRECTORY $<TARGET_FILE_DIR:${TEST_APP}>
1839
)
40+
41+
set_target_properties(${TEST_APP} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY $<TARGET_FILE_DIR:${TEST_APP}>)

example_module/tests/test_app.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,10 @@
1-
#include <testutils/testutils.h>
2-
#include <testutils/bb_memcheck_listener.h>
1+
#include <gtest/gtest.h>
32
#include <coreobjects/util.h>
4-
#include <opendaq/module_manager_init.h>
5-
#include <coretypes/stringobject_factory.h>
6-
73

84
int main(int argc, char** args)
95
{
10-
daq::daqInitializeCoreObjectsTesting();
11-
daqInitModuleManagerLibrary();
12-
136
testing::InitGoogleTest(&argc, args);
147

15-
testing::TestEventListeners& listeners = testing::UnitTest::GetInstance()->listeners();
16-
listeners.Append(new DaqMemCheckListener());
17-
188
auto res = RUN_ALL_TESTS();
199

2010
return res;

0 commit comments

Comments
 (0)