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/ 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()); } }