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
50 changes: 50 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: CI

on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y cmake g++

- name: Build project
run: |
mkdir build
cd build
cmake ..
cmake --build .

- name: Run unit tests
run: |
cd build
./tomport_unit_tests

- name: Run integration tests
run: |
cd build
./tomport_integration_tests

- name: Run all tests with CTest
run: |
cd build
ctest --output-on-failure

- name: Test binary manually
run: |
./build/tomport sample-server.xml

- name: Test with invalid file
run: |
./build/tomport nonexistent.xml || true
55 changes: 55 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Build and Release

on:
push:
tags:
- 'v*'
workflow_dispatch:

jobs:
build-linux:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y cmake g++

- name: Build project
run: |
mkdir build
cd build
cmake ..
cmake --build .

- name: Test binary
run: |
./build/tomport sample-server.xml

- name: Package binary
run: |
mkdir -p tomport-linux-x64
cp build/tomport tomport-linux-x64/
cp README.md tomport-linux-x64/
cp sample-server.xml tomport-linux-x64/
tar -czf tomport-linux-x64.tar.gz tomport-linux-x64/

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: tomport-linux-x64
path: tomport-linux-x64.tar.gz

- name: Create Release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v1
with:
files: tomport-linux-x64.tar.gz
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40 changes: 40 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Build directories
build/
cmake-build-*/

# Compiled Object files
*.o
*.obj
*.lo

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Compiled Static libraries
*.a
*.lib
*.la

# Executables
*.exe
*.out
*.app
tomport

# IDE files
.vscode/
.idea/
*.swp
*.swo
*~

# CMake files
CMakeCache.txt
CMakeFiles/
cmake_install.cmake
Makefile

# Test outputs
Testing/
69 changes: 69 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
cmake_minimum_required(VERSION 3.10)
project(tomport VERSION 1.0.0)

# Set C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Option to build tests
option(BUILD_TESTS "Build tests" ON)

# Create a library with the core functionality
add_library(tomport_core STATIC
src/tomport_core.cpp
src/tinyxml2.cpp
)
target_include_directories(tomport_core PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/src
)

# Main executable
add_executable(tomport
src/main.cpp
)
target_link_libraries(tomport tomport_core)

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

# Install target
install(TARGETS tomport DESTINATION bin)

# Testing
if(BUILD_TESTS)
enable_testing()

# Download and configure Google Test
include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/release-1.12.1.zip
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)

# Unit tests
add_executable(tomport_unit_tests
tests/unit_tests.cpp
)
target_link_libraries(tomport_unit_tests
tomport_core
GTest::gtest_main
)

# Integration tests
add_executable(tomport_integration_tests
tests/integration_tests.cpp
)
target_link_libraries(tomport_integration_tests
tomport_core
GTest::gtest_main
)

include(GoogleTest)
gtest_discover_tests(tomport_unit_tests)
gtest_discover_tests(tomport_integration_tests)
endif()
Loading