Skip to content

Commit

Permalink
Merge pull request #79 from wazuh/enhancement/add-github-action-to-bu…
Browse files Browse the repository at this point in the history
…ild-wazuh-agent

Add workflow to build Agent
  • Loading branch information
TomasTurina authored Aug 14, 2024
2 parents a65a0e8 + 8bef758 commit 84b3776
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 13 deletions.
31 changes: 22 additions & 9 deletions .github/actions/compile/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
27 changes: 27 additions & 0 deletions .github/workflows/compile_and_run_tests.yml
Original file line number Diff line number Diff line change
@@ -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/
6 changes: 3 additions & 3 deletions src/agent/agent_queue/tests/queue_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string>());
}

EXPECT_EQ(0, queue.storedItems(MessageType::STATELESS, "fakemodule"));
Expand All @@ -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<std::string>());
EXPECT_EQ("module-" + std::to_string(val), singleMessage.data.at("module").get<std::string>());
}

auto messageReceivedContent1 = queue.getNextN(MessageType::STATELESS, 10, "module-1");
Expand Down
2 changes: 1 addition & 1 deletion src/agent/agent_queue/tests/sqlitestorage_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string>());
}
}

Expand Down

0 comments on commit 84b3776

Please sign in to comment.