From 32d709d6978eb1142a5b97d0dd1e116b50fa1038 Mon Sep 17 00:00:00 2001 From: Luis Enrique Chico Capistrano Date: Thu, 5 Sep 2024 15:28:31 -0300 Subject: [PATCH] feat: adds a smoke test pipeline for specific component --- .../build_component_and_run_tests.yml | 55 +++++++++++++++++++ src/agent/agent_info/CMakeLists.txt | 2 +- src/agent/agent_info/vcpkg.json | 8 +++ src/agent/communicator/CMakeLists.txt | 3 +- src/agent/communicator/vcpkg.json | 12 ++++ src/agent/multitype_queue/CMakeLists.txt | 2 +- src/agent/multitype_queue/vcpkg.json | 11 ++++ src/agent/sqlite_manager/CMakeLists.txt | 48 ++++++++-------- src/agent/sqlite_manager/vcpkg.json | 11 ++++ 9 files changed, 127 insertions(+), 25 deletions(-) create mode 100644 .github/workflows/build_component_and_run_tests.yml create mode 100644 src/agent/agent_info/vcpkg.json create mode 100644 src/agent/communicator/vcpkg.json create mode 100644 src/agent/multitype_queue/vcpkg.json create mode 100644 src/agent/sqlite_manager/vcpkg.json diff --git a/.github/workflows/build_component_and_run_tests.yml b/.github/workflows/build_component_and_run_tests.yml new file mode 100644 index 0000000000..d0cb2f7451 --- /dev/null +++ b/.github/workflows/build_component_and_run_tests.yml @@ -0,0 +1,55 @@ +run-name: Components - Build ${{ inputs.components }} +name: Build and Run Tests + +on: + workflow_dispatch: + inputs: + source_reference: + description: | + Branch from wazuh/wazuh-agent repository to use. + required: true + components: + description: 'Select agent components/s to tested' + required: true + type: choice + - agent_info + - communicator + - configuration_parser + - multitype_queue + - sqlite_manager + + workflow_call: + inputs: + source_reference: + type: string + required: true + components: + type: string + required: true + +jobs: + Build-component-and-test: + runs-on: ubuntu-latest + timeout-minutes: 10 + name: Build ${{ inputs.components }} + + steps: + - name: Checkout wazuh/wazuh-agent repository + uses: actions/checkout@v4 + with: + repository: wazuh/wazuh-agent + ref: ${{ inputs.source_reference }} + + - name: Build component + run: | + ls + git submodule update --init --recursive + cd src/agent/${{ inputs.components }} + mkdir build && cd build + cmake .. -DBUILD_TESTS=ON + make + + - name: Run the tests + run: | + cd src/agent/${{ inputs.components }}/build && ctest -V + diff --git a/src/agent/agent_info/CMakeLists.txt b/src/agent/agent_info/CMakeLists.txt index 203ad0dea1..16166f1954 100644 --- a/src/agent/agent_info/CMakeLists.txt +++ b/src/agent/agent_info/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.22) set(CMAKE_TOOLCHAIN_FILE "${CMAKE_SOURCE_DIR}/../../vcpkg/scripts/buildsystems/vcpkg.cmake") -set(VCPKG_MANIFEST_DIR ${CMAKE_SOURCE_DIR}/../../) +set(VCPKG_MANIFEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/) project(AgentInfo) diff --git a/src/agent/agent_info/vcpkg.json b/src/agent/agent_info/vcpkg.json new file mode 100644 index 0000000000..a514a305c2 --- /dev/null +++ b/src/agent/agent_info/vcpkg.json @@ -0,0 +1,8 @@ +{ + "name": "wazuh-agent-mvp", + "version": "5.0.0", + "dependencies": [ + "boost-uuid", + "sqlitecpp" + ] +} diff --git a/src/agent/communicator/CMakeLists.txt b/src/agent/communicator/CMakeLists.txt index e08eb39d5f..24abf6e399 100644 --- a/src/agent/communicator/CMakeLists.txt +++ b/src/agent/communicator/CMakeLists.txt @@ -1,7 +1,8 @@ cmake_minimum_required(VERSION 3.22) set(CMAKE_TOOLCHAIN_FILE "${CMAKE_SOURCE_DIR}/../../vcpkg/scripts/buildsystems/vcpkg.cmake") -set(VCPKG_MANIFEST_DIR ${CMAKE_SOURCE_DIR}/../../) +set(VCPKG_MANIFEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/) + project(Communicator) diff --git a/src/agent/communicator/vcpkg.json b/src/agent/communicator/vcpkg.json new file mode 100644 index 0000000000..46c7716823 --- /dev/null +++ b/src/agent/communicator/vcpkg.json @@ -0,0 +1,12 @@ +{ + "name": "wazuh-agent-mvp", + "version": "5.0.0", + "dependencies": [ + "boost-asio", + "gtest", + "boost-beast", + "jwt-cpp", + "nlohmann-json", + "openssl" + ] +} diff --git a/src/agent/multitype_queue/CMakeLists.txt b/src/agent/multitype_queue/CMakeLists.txt index d6eb396be8..1526a3aa85 100644 --- a/src/agent/multitype_queue/CMakeLists.txt +++ b/src/agent/multitype_queue/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.22) set(CMAKE_TOOLCHAIN_FILE "${CMAKE_SOURCE_DIR}/../../vcpkg/scripts/buildsystems/vcpkg.cmake") -set(VCPKG_MANIFEST_DIR ${CMAKE_SOURCE_DIR}/../../) +set(VCPKG_MANIFEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/) project(MultiTypeQueue LANGUAGES CXX) diff --git a/src/agent/multitype_queue/vcpkg.json b/src/agent/multitype_queue/vcpkg.json new file mode 100644 index 0000000000..b5dcfe1647 --- /dev/null +++ b/src/agent/multitype_queue/vcpkg.json @@ -0,0 +1,11 @@ +{ + "name": "wazuh-agent-mvp", + "version": "5.0.0", + "dependencies": [ + "boost-asio", + "gtest", + "fmt", + "nlohmann-json", + "sqlitecpp" + ] +} diff --git a/src/agent/sqlite_manager/CMakeLists.txt b/src/agent/sqlite_manager/CMakeLists.txt index 91c031e92e..64937a3d31 100644 --- a/src/agent/sqlite_manager/CMakeLists.txt +++ b/src/agent/sqlite_manager/CMakeLists.txt @@ -1,22 +1,26 @@ -cmake_minimum_required(VERSION 3.22) - -set(CMAKE_TOOLCHAIN_FILE "${CMAKE_SOURCE_DIR}/../../vcpkg/scripts/buildsystems/vcpkg.cmake") -set(VCPKG_MANIFEST_DIR ${CMAKE_SOURCE_DIR}/../../) - -project(SQLiteManager) - -include(../../cmake/CommonSettings.cmake) -set_common_settings() - -find_package(fmt REQUIRED) -find_package(SQLiteCpp REQUIRED) - -add_library(SQLiteManager src/sqlite_manager.cpp) -configure_target(SQLiteManager) -target_include_directories(SQLiteManager PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include PRIVATE ${SQLiteCpp_INCLUDE_DIRS}) -target_link_libraries(SQLiteManager PUBLIC SQLiteCpp PRIVATE fmt::fmt) - -if(BUILD_TESTS) - enable_testing() - add_subdirectory(tests) -endif() +cmake_minimum_required(VERSION 3.22) + +set(CMAKE_TOOLCHAIN_FILE "${CMAKE_SOURCE_DIR}/../../vcpkg/scripts/buildsystems/vcpkg.cmake") +set(VCPKG_MANIFEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/) + +project(SQLiteManager) + +include(../../cmake/CommonSettings.cmake) +set_common_settings() + + +find_package(fmt REQUIRED) +find_package(SQLiteCpp REQUIRED) + +add_library(SQLiteManager src/sqlite_manager.cpp) + +include(../../cmake/ConfigureTarget.cmake) +configure_target(SQLiteManager) + +target_include_directories(SQLiteManager PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include PRIVATE ${SQLiteCpp_INCLUDE_DIRS}) +target_link_libraries(SQLiteManager PUBLIC SQLiteCpp PRIVATE fmt::fmt) + +if(BUILD_TESTS) + enable_testing() + add_subdirectory(tests) +endif() diff --git a/src/agent/sqlite_manager/vcpkg.json b/src/agent/sqlite_manager/vcpkg.json new file mode 100644 index 0000000000..3601b5eb39 --- /dev/null +++ b/src/agent/sqlite_manager/vcpkg.json @@ -0,0 +1,11 @@ +{ + "name": "wazuh-agent-mvp", + "version": "5.0.0", + "dependencies": [ + "boost-asio", + "gtest", + "fmt", + "nlohmann-json", + "sqlitecpp" + ] +}