Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/ek1/v1.1 #1

Open
wants to merge 7 commits into
base: discovery/ids/v2.0
Choose a base branch
from
Open
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
68 changes: 60 additions & 8 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
@@ -43,8 +43,8 @@ jobs:
if: success() || failure()
with:
ketryx-url: ${{ vars.KETRYX_URL }}
project: ${{ vars.KETRYX_PROJECT }}
api-key: ${{ secrets.KETRYX_API_KEY }}
project: ${{ vars.KETRYX_PROJECT_EK1 }}
api-key: ${{ secrets.KETRYX_API_KEY_EK }}
commit-sha: ${{ github.event.pull_request.head.sha || github.sha }}
build-name: ci-js
test-junit-path: js-src/test-results/jest-junit.xml
@@ -81,12 +81,64 @@ jobs:
if: success() || failure()
with:
ketryx-url: ${{ vars.KETRYX_URL }}
project: ${{ vars.KETRYX_PROJECT }}
api-key: ${{ secrets.KETRYX_API_KEY }}
project: ${{ vars.KETRYX_PROJECT_EK1 }}
api-key: ${{ secrets.KETRYX_API_KEY_EK }}
commit-sha: ${{ github.event.pull_request.head.sha || github.sha }}
build-name: ci-java
test-junit-path: java-src/build/test-results/test/*.xml

test-cpp:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache APT packages
id: cache-apt
uses: actions/cache@v3
with:
path: /var/cache/apt
key: ${{ runner.os }}-apt-cache
restore-keys: |
${{ runner.os }}-apt-cache
- name: Cache APT lists
id: cache-apt-lists
uses: actions/cache@v3
with:
path: /var/lib/apt/lists
key: ${{ runner.os }}-apt-lists
restore-keys: |
${{ runner.os }}-apt-lists
- name: Install cmake
run: sudo apt update && sudo apt install cmake -y
- name: Use cmake
run: cmake --version
- name: Run C++ unit tests
working-directory: cpp-src
run: |
mkdir build -p
cd build
cmake ..
cmake --build .
./cpp_sorter_test --gtest_output=xml
- name: Upload test results
uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: test-results-cpp
path: cpp-src/build/*.xml
retention-days: 7
if-no-files-found: error
- name: Report C++ build to Ketryx
uses: Ketryx/ketryx-github-action@v1
if: success() || failure()
with:
ketryx-url: ${{ vars.KETRYX_URL }}
project: ${{ vars.KETRYX_PROJECT_EK1 }}
api-key: ${{ secrets.KETRYX_API_KEY_EK }}
commit-sha: ${{ github.event.pull_request.head.sha || github.sha }}
build-name: ci-cpp
test-junit-path: cpp-src/build/*.xml

create-sbom:
runs-on: ubuntu-latest
steps:
@@ -103,8 +155,8 @@ jobs:
if: success() || failure()
with:
ketryx-url: ${{ vars.KETRYX_URL }}
project: ${{ vars.KETRYX_PROJECT }}
api-key: ${{ secrets.KETRYX_API_KEY }}
project: ${{ vars.KETRYX_PROJECT_EK1 }}
api-key: ${{ secrets.KETRYX_API_KEY_EK }}
commit-sha: ${{ github.event.pull_request.head.sha || github.sha }}
build-name: ci-sbom
spdx-json-path: |
@@ -121,8 +173,8 @@ jobs:
if: success() || failure()
with:
ketryx-url: ${{ vars.KETRYX_URL }}
project: ${{ vars.KETRYX_PROJECT }}
api-key: ${{ secrets.KETRYX_API_KEY }}
project: ${{ vars.KETRYX_PROJECT_EK1 }}
api-key: ${{ secrets.KETRYX_API_KEY_EK }}
commit-sha: ${{ github.event.pull_request.head.sha || github.sha }}
build-name: check-pr
check-release-status: true
59 changes: 59 additions & 0 deletions cpp-src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
cmake_minimum_required(VERSION 2.8.8)
set(PROJECT_NAME_STR google-test-examples)
project(${PROJECT_NAME_STR} C CXX)

set(CMAKE_CXX_STANDARD 14)

set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
get_filename_component(DEPS_ROOT "${PROJECT_BINARY_DIR}/deps" ABSOLUTE)

include(ExtProjectUtils)

find_package(Threads REQUIRED)

if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -ansi -Wno-deprecated")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -ansi -Wno-deprecated")
endif()

if(MSVC)
#vc 2012 fix for vararg templates
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_VARIADIC_MAX=10")
endif()

if(WIN32)
set(_OPT_CMAKE_ARGS "-Dgtest_force_shared_crt=ON;-DCMAKE_SH=CMAKE_SH-NOTFOUND")
else()
set(_OPT_CMAKE_ARGS "")
endif()

# Will download external CMakeable project from git repo, branch "master" and install it in $DEPS_ROOT
# This also will create "googletest.git" target, which we'll use as dependency for our test project
ExtProjectGit("https://github.com/google/googletest.git" "main" ${DEPS_ROOT} CMAKE_ARGS "${_OPT_CMAKE_ARGS}")

include_directories("${DEPS_ROOT}/include")
link_directories("${DEPS_ROOT}/lib")
link_directories("${DEPS_ROOT}/lib64")

#-------------------
# set common include folder for module
#-------------------
set(COMMON_INCLUDES ${PROJECT_SOURCE_DIR}/include)

#-------------------
# Test
#-------------------
enable_testing()
include_directories(${COMMON_INCLUDES})

file(GLOB TEST_SRC_FILES ${PROJECT_SOURCE_DIR}/test/*.cpp)

# from list of files we'll create tests test_name.cpp -> test_name
foreach(_test_file ${TEST_SRC_FILES})
get_filename_component(_test_name ${_test_file} NAME_WE)
add_executable(${_test_name} ${_test_file})
add_dependencies(${_test_name} "googletest.git")
target_link_libraries(${_test_name} gtest gtest_main ${CMAKE_THREAD_LIBS_INIT})
add_test(${_test_name} ${_test_name})
set_tests_properties(${_test_name} PROPERTIES TIMEOUT 5)
endforeach()
71 changes: 71 additions & 0 deletions cpp-src/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Short sample how-to use Google C++ Test Framework in cmakeable projects

1. Google test will be downloaded from GitHub and built with your project

## How to use:

1. git clone https://github.com/snikulov/google-test-examples.git
2. cd google-test-examples
3. mkdir build
4. cd build
5. cmake ..
6. cmake --build .
7. ctest -VV

## CI status:

[![Build Status](https://travis-ci.org/snikulov/google-test-examples.svg?branch=master)](https://travis-ci.org/snikulov/google-test-examples) | [![Build status](https://ci.appveyor.com/api/projects/status/t30uakdk0awxy88p/branch/master?svg=true)](https://ci.appveyor.com/project/snikulov/google-test-examples/branch/master)

## Known issues:

- TBD
---

# How to use (alternativ with docker containers)

## Get repo
```bash
$ git clone https://github.com/snikulov/google-test-examples.git
$ cd google-test-examples
```

## CMake
We can use CMake to configure/build/running tests:

### Host side
```bash
$ cmake -P build.cmake
```

### Docker Containers side
```bash
cmake -P build_with_docker.cmake
```

## Makefile

### Targets
```bash
$ make [tab]
make all
all build/Makefile configure google-test-examples_test
build clean DOCKER_COMMAND run
build_directory clean_docker_image docker_image
build_docker_image CMAKE_COMMAND DOCKER_IMAGE
```

### Configure/Build/Running tests (with docker containers)
```bash
$ make all
docker build -t atty/google-test-examples:latest --file docker/Dockerfile .
Sending build context to Docker daemon 221.2kB
Step 1/1 : FROM rikorose/gcc-cmake:latest
...
1/1 Test #1: test1 ............................ Passed 0.00 sec
100% tests passed, 0 tests failed out of 1

Total Test time (real) = 0.00 sec
```

## Screencast recording
[![asciicast](https://asciinema.org/a/a03v5lmsoph7l0lhish1jkwqo.png)](https://asciinema.org/a/a03v5lmsoph7l0lhish1jkwqo)
28 changes: 28 additions & 0 deletions cpp-src/build.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
cmake_minimum_required(VERSION 2.8)

set(build_dir ${CMAKE_CURRENT_LIST_DIR}/build)

if(NOT EXISTS ${build_dir})
file(MAKE_DIRECTORY ${build_dir})
endif()

execute_process(
COMMAND ${CMAKE_COMMAND} ..
WORKING_DIRECTORY ${build_dir}
)

execute_process(
COMMAND ${CMAKE_COMMAND} --build .
WORKING_DIRECTORY ${build_dir}
)


execute_process(
COMMAND ctest -VV
WORKING_DIRECTORY ${build_dir}
RESULT_VARIABLE test_result
)

if(${test_result})
message(FATAL_ERROR "test failed")
endif()
50 changes: 50 additions & 0 deletions cpp-src/cmake/ExtProjectUtils.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
include(ExternalProject)
include(CMakeParseArguments)

#
# Function to inject dependency (download from git repo)
#
# Use as ExternalProjectGit( "<url to git repository>" "<tag>" "<destination>" )
# where
# - url to repository for ex. https://github.com/log4cplus/log4cplus.git
# project name will be regexed from url as latest part in our case log4cplus.git
# - tag - tag you want to use
# - destination - where to install your binaries, for example ${CMAKE_BINARY_DIR}/3rdparty
#

function(ExtProjectGit repourl tag destination)

message(STATUS "Get external project from: ${repourl} : ${tag}")

string(REGEX MATCH "([^\\/]+)[.]git$" _name ${repourl})
message(STATUS "_name = ${_name}")

set(options)
set(oneValueArgs)
set(multiValueArgs CMAKE_ARGS)
cmake_parse_arguments(ExtProjectGit "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})

set(cmake_cli_args -DCMAKE_INSTALL_PREFIX=${destination}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE})
if(CMAKE_TOOLCHAIN_FILE)
get_filename_component(_ft_path ${CMAKE_TOOLCHAIN_FILE} ABSOLUTE)
get_filename_component(_cm_rt_opath ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ABSOLUTE)
set(cmake_cli_args ${cmake_cli_args}
-DCMAKE_TOOLCHAIN_FILE=${_ft_path}
-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=${_cm_rt_opath})
endif()

foreach(cmake_key ${ExtProjectGit_CMAKE_ARGS})
set(cmake_cli_args ${cmake_key} ${cmake_cli_args})
endforeach()

message(STATUS "ARGS for ExternalProject_Add(${name}): ${cmake_cli_args}")
message(STATUS "CMAKE_CXX_FLAGS = ${CMAKE_CXX_FLAGS}")

ExternalProject_Add(${_name}
GIT_REPOSITORY ${repourl}
GIT_TAG ${tag}
CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} ${cmake_cli_args} -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS} -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
PREFIX "${destination}"
INSTALL_DIR "${destination}")
endfunction()
12 changes: 12 additions & 0 deletions cpp-src/include/cpp_sorter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#if !defined(CPP_SORTER_H_)
#define CPP_SORTER_H_

// simple sorter for arrays
template <typename T>
void array_sort(T * arr, size_t len)
{
std::sort(arr, arr+len);
}

#endif

Empty file added cpp-src/src/cpp_sort_impl.cpp
Empty file.
42 changes: 42 additions & 0 deletions cpp-src/test/cpp_sorter_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include <algorithm>

#include "cpp_sorter.h"
#include "gtest/gtest.h"

TEST(cpp_sorter_test, null_term_str_sort)
{
RecordProperty("tested-item-id", "KXITM4XS49623PY9F2BFRA2S67Y2JSJ");

char arr[] = "abcdefghab";
char eq[] = "aabbcdefgh";
int sz = sizeof(arr)/sizeof(arr[0]) - 1; // we need it, to avoid terminating \0 in "" definition case

array_sort(arr, sz);

for(int i=0; i<sz; i++)
EXPECT_EQ(arr[i], eq[i]);
}

TEST(cpp_sorter_test, char_arr_sort)
{
char arr[] = {'a','b','c','d','e','f','g','h','a','b'};
char eq[] = {'a','a','b','b','c','d','e','f','g','h'};
int sz = sizeof(arr)/sizeof(arr[0]);

array_sort(arr, sz);

for(int i=0; i<sz; i++)
EXPECT_EQ(arr[i], eq[i]);
}

TEST(cpp_sorter_test, int_arr_sort)
{
int arr[] = {9,8,7,6,5,4,3,2,1,0};
int eq[] = {0,1,2,3,4,5,6,7,8,9};
int sz = sizeof(arr)/sizeof(arr[0]);

array_sort(arr, sz);

for(int i=0; i<sz; i++)
EXPECT_EQ(arr[i], eq[i]);
}
22 changes: 22 additions & 0 deletions js-src/app/createModel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* Instantitate model with specified architecture.
*
* @itemId:spec-model
* @itemTitle:"Model (Javascript)"
* @itemFulfills:CS-1,KD-20
* @itemHasParent:spec-ai-module
*/
export function createModel() {
}

/**
* Load datasets used for training and testing the machine learning models.
*
* @itemId:spec-data
* @itemTitle:"Data (Javascript)"
* @itemFulfills:CS-1,KD-20
* @itemHasParent:spec-model
*/
export function loadTrainTestData() {
}

9 changes: 9 additions & 0 deletions js-src/features/ai-data.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Feature: Data module

@tests:spec-data
Scenario: Test Data
Given Application is open
When Data of 8 is entered
And Form is submitted
Then Sensor is not read
And An error message is shown
9 changes: 9 additions & 0 deletions js-src/features/ai-model.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Feature: Model

@tests:spec-model
Scenario: Test Model
Given Application is open
When Data of 8 is entered
And Form is submitted
Then Sensor is not read
And An error message is shown
9 changes: 9 additions & 0 deletions js-src/features/ai-module.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Feature: AI module

@tests:spec-ai-module
Scenario: Test AI Module (Cucumber)
Given Application is open
When Data of 8 is entered
And Form is submitted
Then Sensor is not read
And An error message is shown
9 changes: 9 additions & 0 deletions js-src/features/ai-subsystem.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Feature: AI subsystem

@tests:spec-ai-subsystem @tests:CS-1 @tests:CS-2 @tests:CS-3
Scenario: Test AI Subsystem
Given Application is open
When Data of 8 is entered
And Form is submitted
Then Sensor is not read
And An error message is shown
4 changes: 2 additions & 2 deletions js-src/features/sensor-module.feature
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Feature: Sensor module

@tests:spec-sensor-reading-warning
Scenario: Test Sensor Reading Warning (Cucumber)
@implements:test-sensor-module
Scenario: Test Sensor Module (Cucumber)
Given Application is open
When Data of 8 is entered
And Form is submitted
9 changes: 9 additions & 0 deletions js-src/features/sensor-warning-module.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Feature: Sensor Warning module

@tests:spec-sensor-reading-warning
Scenario: Test Sensor Reading Warning (Cucumber)
Given Application is open
When Data of 8 is entered
And Form is submitted
Then Sensor is not read
And An error message is shown
2 changes: 1 addition & 1 deletion js-src/tests/testSensorModule.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
describe('Javascript automated test for sensor module @tests:KXITM4XS49623PY9F2BFRA2S67Y2JSJ', () => {
describe('Javascript automated test for sensor module @tests:KXITM1A9B9BCRVK8NBSTS9NKXWFKC1E', () => {
it('sensor module functions correctly', () => {
// This would test the sensor module.
expect(1 + 2).toBe(3);
10 changes: 10 additions & 0 deletions markdown/spec-ai-module.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
itemId: spec-ai-module
itemType: Software Item Spec
itemFulfills: CS-1,CS-2,CS-3,KD-20
itemHasParent: spec-ai-subsystem
---

# AI Module (Markdown)

The AI Module integrates various components to enable intelligent data analysis and decision-making for the device.
11 changes: 11 additions & 0 deletions markdown/spec-ai-subsystem.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
itemId: spec-ai-subsystem
itemType: Software Item Spec
itemFulfills: CS-1,CS-2,CS-3,KD-20
---

# AI Subsystem (Markdown)

The AI Subsystem integrates various components to enable intelligent data analysis and decision-making for devices.


1 change: 1 addition & 0 deletions markdown/spec-sensor-module.md
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@
itemId: spec-sensor-module
itemType: Software Item Spec
itemFulfills: CS-1,CS-2,CS-3,KD-20
itemHasParent: spec-ai-subsystem,KD-2
---

# Sensor Module (Markdown)