From 44243ac5f7d42c3de221836770d4b56e551e9392 Mon Sep 17 00:00:00 2001 From: jr0me Date: Wed, 14 Aug 2024 00:14:24 +0200 Subject: [PATCH 1/2] fix: compilation errors fixed in tests --- src/agent/agent_queue/tests/queue_test.cpp | 6 +++--- src/agent/agent_queue/tests/sqlitestorage_test.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/agent/agent_queue/tests/queue_test.cpp b/src/agent/agent_queue/tests/queue_test.cpp index 364eb15298..04d06e0659 100644 --- a/src/agent/agent_queue/tests/queue_test.cpp +++ b/src/agent/agent_queue/tests/queue_test.cpp @@ -444,7 +444,7 @@ TEST_F(QueueTest, PushMultipleGetMultipleWithModule) int i = 0; for (auto singleMessage : messagesReceived) { - EXPECT_EQ("content " + std::to_string(++i), singleMessage.data.at("data")); + EXPECT_EQ("content " + std::to_string(++i), singleMessage.data.at("data").get()); } EXPECT_EQ(0, queue.storedItems(MessageType::STATELESS, "fakemodule")); @@ -471,8 +471,8 @@ TEST_F(QueueTest, PushSinglesleGetMultipleWithModule) for (auto singleMessage : messagesReceived) { auto val = ++i; - EXPECT_EQ("content-" + std::to_string(val), singleMessage.data.at("data")); - EXPECT_EQ("module-" + std::to_string(val), singleMessage.data.at("module")); + EXPECT_EQ("content-" + std::to_string(val), singleMessage.data.at("data").get()); + EXPECT_EQ("module-" + std::to_string(val), singleMessage.data.at("module").get()); } auto messageReceivedContent1 = queue.getNextN(MessageType::STATELESS, 10, "module-1"); diff --git a/src/agent/agent_queue/tests/sqlitestorage_test.cpp b/src/agent/agent_queue/tests/sqlitestorage_test.cpp index fdb36e4769..0783e00901 100644 --- a/src/agent/agent_queue/tests/sqlitestorage_test.cpp +++ b/src/agent/agent_queue/tests/sqlitestorage_test.cpp @@ -136,7 +136,7 @@ TEST_F(SQLiteStorageTest, RetrieveMultipleMessagesWithModule) int i = 0; for (auto singleMessage : retrievedMessages) { - EXPECT_EQ("value" + std::to_string(++i), singleMessage.at("data").at("key")); + EXPECT_EQ("value" + std::to_string(++i), singleMessage.at("data").at("key").get()); } } From 8bef75867e7ed9e172dfa56503b3a6a11647bfd2 Mon Sep 17 00:00:00 2001 From: jr0me Date: Tue, 13 Aug 2024 18:32:28 +0200 Subject: [PATCH 2/2] feat: add workflow to build agent on changes --- .github/actions/compile/action.yml | 31 +++++++++++++++------ .github/workflows/compile_and_run_tests.yml | 27 ++++++++++++++++++ 2 files changed, 49 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/compile_and_run_tests.yml diff --git a/.github/actions/compile/action.yml b/.github/actions/compile/action.yml index ff7c41cd70..07ae5ea1c0 100644 --- a/.github/actions/compile/action.yml +++ b/.github/actions/compile/action.yml @@ -10,16 +10,29 @@ inputs: runs: using: "composite" steps: - - name: Compile + - name: Generate CMake project run: | - SRC_FOLDER=$(pwd)/src - - VERSION=$(cat src/VERSION) - echo $VERSION - REVISION=$(cat src/REVISION) - echo $REVISION + SRC_FOLDER=$(pwd)/${{ inputs.path }} - cd ${{ inputs.path }} mkdir -p build && cd build - cmake -DSRC_FOLDER=${SRC_FOLDER} -DVERSION="$VERSION" -DREVISION="$REVISION" .. && make -j2 + cmake ${SRC_FOLDER} -DBUILD_TESTS=1 -G "Unix Makefiles" + echo "CMake project generated in $(pwd)" + shell: bash + + - name: Compile + run: | + cd build + if [ ! -f CMakeCache.txt ]; then + echo "CMake cache not found in $(pwd). Aborting." + exit 1 + fi + cmake --build . + shell: bash + + - name: Run Tests + continue-on-error: true + run: | + set +e + cd build + ctest || echo "Tests failed, but continuing" shell: bash diff --git a/.github/workflows/compile_and_run_tests.yml b/.github/workflows/compile_and_run_tests.yml new file mode 100644 index 0000000000..d4a0d02f93 --- /dev/null +++ b/.github/workflows/compile_and_run_tests.yml @@ -0,0 +1,27 @@ +name: Compile and Run Tests + +on: + push: + branches: + - '**' + pull_request: + types: + - opened + - synchronize + - reopened + +jobs: + compile: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + submodules: true + fetch-depth: 0 + + - name: Run Compile Action + uses: ./.github/actions/compile + with: + path: src/