Skip to content
Merged
Show file tree
Hide file tree
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
89 changes: 16 additions & 73 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ on:
branches: [ main, master, develop ]

jobs:
build-and-test:
build-test-analyze:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
build_type: [Release, Debug]
build_type: [Release]

steps:
- uses: actions/checkout@v4
Expand All @@ -27,7 +27,8 @@ jobs:
libgoogle-glog-dev \
libgtest-dev \
cmake \
build-essential
build-essential \
clang-format

- name: Install dependencies (macOS)
if: matrix.os == 'macos-latest'
Expand All @@ -37,9 +38,19 @@ jobs:
libpcap \
glog \
googletest \
cmake
cmake \
clang-format

- name: Check code formatting
env:
PKG_CONFIG_PATH: ${{ matrix.os == 'macos-latest' && '/opt/homebrew/opt/libpcap/lib/pkgconfig' || '' }}
run: |
chmod +x format_code.sh
./format_code.sh --check

- name: Configure CMake
env:
PKG_CONFIG_PATH: ${{ matrix.os == 'macos-latest' && '/opt/homebrew/opt/libpcap/lib/pkgconfig' || '' }}
run: |
cmake -B build \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
Expand All @@ -58,34 +69,6 @@ jobs:
which pkt2flow
pkt2flow -h || true # Show help (exits with non-zero)

static-analysis:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
libpcap-dev \
libgoogle-glog-dev \
libgtest-dev \
cmake \
build-essential \
cppcheck \
clang-format

- name: Run cppcheck
run: |
cppcheck --enable=all --error-exitcode=1 --suppress=missingIncludeSystem \
--suppress=unusedFunction \
--inline-suppr \
*.c *.h

- name: Check code formatting
run: |
clang-format --dry-run --Werror *.c *.h

build-docs:
runs-on: ubuntu-latest
steps:
Expand All @@ -99,44 +82,4 @@ jobs:
- name: Generate documentation
run: |
doxygen --version
# Documentation generation can be added when Doxyfile is created

cross-compile:
runs-on: ubuntu-latest
strategy:
matrix:
target: [x86_64, aarch64]
steps:
- uses: actions/checkout@v4

- name: Install cross-compilation tools
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu

- name: Install dependencies
run: |
sudo apt-get install -y \
libpcap-dev \
libgoogle-glog-dev \
cmake \
build-essential

- name: Configure CMake (x86_64)
if: matrix.target == 'x86_64'
run: |
cmake -B build \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_TESTS=OFF

- name: Configure CMake (aarch64)
if: matrix.target == 'aarch64'
run: |
cmake -B build \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_TESTS=OFF \
-DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc \
-DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++

- name: Build
run: cmake --build build -j $(nproc)
# Documentation generation can be added when Doxyfile is created
21 changes: 13 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ find_package(glog REQUIRED)

# Source files
set(PKT2FLOW_SOURCES
pkt2flow.cpp
flow_db.cpp
utilities.c
src/pkt2flow.cpp
src/flow_db.cpp
src/utilities.cpp
)

# Create the main executable
Expand All @@ -66,7 +66,7 @@ target_link_libraries(pkt2flow

# Include directories
target_include_directories(pkt2flow PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/src
${PCAP_INCLUDE_DIRS}
)

Expand Down Expand Up @@ -108,7 +108,7 @@ if(BUILD_TESTS)

# Include directories for tests
target_include_directories(pkt2flow_tests PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/src
${PCAP_INCLUDE_DIRS}
)

Expand All @@ -120,12 +120,12 @@ if(BUILD_TESTS)

# Create a library from the source files for testing
add_library(pkt2flow_lib STATIC
flow_db.cpp
utilities.c
src/flow_db.cpp
src/utilities.cpp
)

target_include_directories(pkt2flow_lib PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/src
${PCAP_INCLUDE_DIRS}
)

Expand All @@ -140,6 +140,11 @@ if(BUILD_TESTS)
target_link_libraries(pkt2flow_tests pkt2flow_lib)
endif()

# Build example in examples/
add_executable(example_pkt2flow examples/example_pkt2flow.c)
target_link_libraries(example_pkt2flow pkt2flow_lib)
target_include_directories(example_pkt2flow PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)

# CPack configuration for packaging
include(CPack)
set(CPACK_PACKAGE_NAME "pkt2flow")
Expand Down
Loading