Skip to content

Commit

Permalink
Added testing, reorganized submodules, enable build as object lib (#27)
Browse files Browse the repository at this point in the history
- Added GTest Dependency
- regorganized git submodules
- Added CMake Options to accommodate the new test options
- Added CMake Option to build tcp_pubsub as object lib
- Improved GH Action scripts to execute tests
  • Loading branch information
FlorianReimold authored Nov 21, 2024
1 parent 55c9b15 commit 4fd6970
Show file tree
Hide file tree
Showing 23 changed files with 762 additions and 82 deletions.
15 changes: 13 additions & 2 deletions .github/workflows/build-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,24 @@ jobs:
submodules: 'true'
fetch-depth: 0


- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{github.workspace}}/_build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
run: |
cmake -B ${{github.workspace}}/_build \
-DTCP_PUBSUB_BUILD_SAMPLES=ON \
-DTCP_PUBSUB_BUILD_TESTS=ON \
-DTCP_PUBSUB_USE_BUILTIN_ASIO=ON \
-DTCP_PUBSUB_USE_BUILTIN_RECYCLE=ON \
-DTCP_PUBSUB_USE_BUILTIN_GTEST=ON \
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \
shell: bash

- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/_build --config ${{env.BUILD_TYPE}}

- name: Run Tests
run: ctest -C Release -V
working-directory: ${{ github.workspace }}/_build

78 changes: 39 additions & 39 deletions .github/workflows/build-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ jobs:
build-ubuntu:

strategy:
fail-fast: false
matrix:
library_type: [static, shared]
os: [ubuntu-22.04, ubuntu-20.04]
library_type: [static, shared, object]
os: [ubuntu-24.04, ubuntu-22.04, ubuntu-20.04]

# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
# You can convert this to a matrix build if you need cross-platform coverage.
Expand All @@ -28,41 +29,19 @@ jobs:
- name: Set Variables
run: |
if [[ '${{ matrix.library_type }}' == 'static' ]]; then
echo "build_shared_libs=OFF" >> "$GITHUB_ENV"
echo "package_postfix=static" >> "$GITHUB_ENV"
else
echo "build_shared_libs=ON" >> "$GITHUB_ENV"
echo "package_postfix=shared" >> "$GITHUB_ENV"
echo "build_shared_libs=OFF" >> "$GITHUB_ENV"
echo "tcp_pubsub_library_type=STATIC" >> "$GITHUB_ENV"
echo "package_postfix=static" >> "$GITHUB_ENV"
elif [[ '${{ matrix.library_type }}' == 'shared' ]]; then
echo "build_shared_libs=ON" >> "$GITHUB_ENV"
echo "tcp_pubsub_library_type=SHARED" >> "$GITHUB_ENV"
echo "package_postfix=shared" >> "$GITHUB_ENV"
elif [[ '${{ matrix.library_type }}' == 'object' ]]; then
echo "build_shared_libs=OFF" >> "$GITHUB_ENV"
echo "tcp_pubsub_library_type=OBJECT" >> "$GITHUB_ENV"
echo "package_postfix=object" >> "$GITHUB_ENV"
fi
- name: Getting closer to vanilla Ubuntu 18.04
run: |
if [[ '${{ matrix.os }}' == 'ubuntu-18.04' ]]; then
sudo apt-get -y update
echo "Creating directory for libgcc1"
mkdir libgcc1_deb
cd libgcc1_deb
pwd
echo "Downloading bionic-security libgcc1"
apt-get download -t bionic-security libgcc1
echo "Purging GH Actions toolchain PPA"
sudo apt-get -y install ppa-purge
sudo ppa-purge -y ubuntu-toolchain-r/test
echo "installing libgcc1_deb"
sudo dpkg -i *
echo "Installing g++"
sudo apt-get -y install g++
cd ..
fi
shell: bash

- name: Checkout
uses: actions/checkout@v4
with:
Expand All @@ -78,13 +57,23 @@ jobs:
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: |
cmake -B ${{github.workspace}}/_build \
-DTCP_PUBSUB_BUILD_SAMPLES=ON \
-DTCP_PUBSUB_BUILD_TESTS=ON \
-DTCP_PUBSUB_USE_BUILTIN_ASIO=ON \
-DTCP_PUBSUB_USE_BUILTIN_RECYCLE=ON \
-DTCP_PUBSUB_USE_BUILTIN_GTEST=ON \
-DTCP_PUBSUB_LIBRARY_TYPE=${{env.tcp_pubsub_library_type}} \
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \
-DBUILD_SHARED_LIBS=${{ env.build_shared_libs }}
- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/_build --config ${{env.BUILD_TYPE}}

- name: Run Tests
run: ctest -C Release -V
working-directory: ${{ github.workspace }}/_build

- name: Read Project Version from CMakeCache
run: |
cmake_project_version_string=$(cat "${{github.workspace}}/_build/CMakeCache.txt" | grep "^CMAKE_PROJECT_VERSION:")
Expand All @@ -96,18 +85,21 @@ jobs:
- name: CPack
run: cpack -G DEB
working-directory: ${{ github.workspace }}/_build
if: ${{ matrix.library_type != 'object' }}

- name: Rename .deb installer
run: |
mv *.deb '${{ env.PROJECT_NAME }}-${{ env.CMAKE_PROJECT_VERSION }}-${{ matrix.os }}-${{ env.package_postfix }}.deb'
shell: bash
working-directory: ${{github.workspace}}/_build/_package/
if: ${{ matrix.library_type != 'object' }}

- name: Upload binaries
uses: actions/upload-artifact@v4
with:
name: ${{ env.PROJECT_NAME }}-${{ env.CMAKE_PROJECT_VERSION }}-${{ matrix.os }}-${{ env.package_postfix }}
path: ${{github.workspace}}/_build/_package/*.deb
if: ${{ matrix.library_type != 'object' }}

############################################
# Test if our binary can be linked against
Expand All @@ -116,24 +108,32 @@ jobs:
- name: Install binaries
shell: bash
run: sudo dpkg -i ${{ github.workspace }}/_build/_package/*.deb
if: ${{ matrix.library_type != 'object' }}

- name: Compile integration test (Release)
run: |
cmake -B ${{github.workspace}}/samples/integration_test/_build/release -DCMAKE_BUILD_TYPE=Release
cmake -B ${{github.workspace}}/samples/integration_test/_build/release \
-DCMAKE_BUILD_TYPE=Release
cmake --build ${{github.workspace}}/samples/integration_test/_build/release
working-directory: ${{ github.workspace }}/samples/integration_test
if: ${{ matrix.library_type != 'object' }}

- name: Run integration test (Release)
run: ./integration_test
working-directory: ${{ github.workspace }}/samples/integration_test/_build/release
if: ${{ matrix.library_type != 'object' }}

- name: Compile integration test (Debug)
run: |
cmake -B ${{github.workspace}}/samples/integration_test/_build/debug -DCMAKE_BUILD_TYPE=Debug
cmake --build ${{github.workspace}}/samples/integration_test/_build/debug
cmake -B ${{github.workspace}}/samples/integration_test/_build/debug \
-DCMAKE_BUILD_TYPE=Debug
cmake --build ${{github.workspace}}/samples/integration_test/_build/debug
working-directory: ${{ github.workspace }}/samples/integration_test
if: ${{ matrix.library_type != 'object' }}

- name: Run integration test (Debug)
run: ./integration_test
working-directory: ${{ github.workspace }}/samples/integration_test/_build/debug

if: ${{ matrix.library_type != 'object' }}
58 changes: 45 additions & 13 deletions .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ jobs:
build-windows:

strategy:
fail-fast: false
matrix:
library_type: [static, shared]
build_arch: [x64, win32]
library_type: [static, shared, object]
build_arch: [x64, win32]

# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
# You can convert this to a matrix build if you need cross-platform coverage.
Expand All @@ -31,13 +32,18 @@ jobs:
run: |
if ( '${{ matrix.library_type }}' -eq 'static' )
{
echo "build_shared_libs=OFF" >> "$Env:GITHUB_ENV"
echo "package_postfix=static" >> "$Env:GITHUB_ENV"
echo "tcp_pubsub_library_type=STATIC" >> "$Env:GITHUB_ENV"
echo "package_postfix=static" >> "$Env:GITHUB_ENV"
}
else
elseif( '${{ matrix.library_type }}' -eq 'shared' )
{
echo "build_shared_libs=ON" >> "$Env:GITHUB_ENV"
echo "package_postfix=shared" >> "$Env:GITHUB_ENV"
echo "tcp_pubsub_library_type=SHARED" >> "$Env:GITHUB_ENV"
echo "package_postfix=shared" >> "$Env:GITHUB_ENV"
}
elseif( '${{ matrix.library_type }}' -eq 'object' )
{
echo "tcp_pubsub_library_type=OBJECT" >> "$Env:GITHUB_ENV"
echo "package_postfix=object" >> "$Env:GITHUB_ENV"
}
- name: Checkout
Expand All @@ -59,20 +65,39 @@ jobs:
-G "Visual Studio 16 2019" ^
-A ${{ matrix.build_arch }} ^
-T ${{ env.VS_TOOLSET }} ^
-DCMAKE_INSTALL_PREFIX=${{env.INSTALL_PREFIX}} ^
-DBUILD_SHARED_LIBS=${{ env.build_shared_libs }}
-DTCP_PUBSUB_BUILD_SAMPLES=ON ^
-DTCP_PUBSUB_BUILD_TESTS=ON ^
-DTCP_PUBSUB_USE_BUILTIN_ASIO=ON ^
-DTCP_PUBSUB_USE_BUILTIN_RECYCLE=ON ^
-DTCP_PUBSUB_USE_BUILTIN_GTEST=ON ^
-DTCP_PUBSUB_LIBRARY_TYPE=${{env.tcp_pubsub_library_type}} ^
-DCMAKE_INSTALL_PREFIX=${{env.INSTALL_PREFIX}}
- name: Build (Release)
shell: cmd
run: |
cmake --build ${{github.workspace}}/_build --config Release --parallel
- name: Install (Release)
shell: cmd
run: |
cmake --build ${{github.workspace}}/_build --config Release --target INSTALL
if: ${{ matrix.library_type != 'object' }}

- name: Build (Debug)
shell: cmd
run: |
cmake --build ${{github.workspace}}/_build --config Debug --parallel
- name: Install (Debug)
shell: cmd
run: |
cmake --build ${{github.workspace}}/_build --config Debug --target INSTALL
if: ${{ matrix.library_type != 'object' }}

- name: Run Tests
run: ctest -C Release -V
working-directory: ${{ github.workspace }}/_build

- name: Read Project Version from CMakeCache
run: |
Expand All @@ -85,23 +110,27 @@ jobs:
with:
name: ${{ env.PROJECT_NAME }}-${{ env.CMAKE_PROJECT_VERSION }}-windows-${{ matrix.build_arch }}-${{ env.VS_NAME }}-${{ matrix.library_type }}
path: ${{github.workspace}}/${{env.INSTALL_PREFIX}}
if: ${{ matrix.library_type != 'object' }}

############################################
# Test if our binary can be linked against
############################################

- name: CMake integration test
shell: cmd
shell: powershell
run: |
cmake -B ${{github.workspace}}/samples/integration_test/_build ^
-A ${{ matrix.build_arch }} ^
-DCMAKE_PREFIX_PATH=${{github.workspace}}/${{env.INSTALL_PREFIX}}
cmake -B "${{github.workspace}}/samples/integration_test/_build" `
-A ${{ matrix.build_arch }} `
-DCMAKE_PREFIX_PATH="${{github.workspace}}/${{env.INSTALL_PREFIX}}"
working-directory: ${{ github.workspace }}/samples/integration_test
if: ${{ matrix.library_type != 'object' }}

- name: Compile integration test (Release)
shell: cmd
run: cmake --build ${{github.workspace}}/samples/integration_test/_build --config Release
working-directory: ${{ github.workspace }}/samples/integration_test
if: ${{ matrix.library_type != 'object' }}

- name: Run integration test (Release)
run: |
Expand All @@ -111,11 +140,13 @@ jobs:
}
.\integration_test.exe
working-directory: ${{ github.workspace }}/samples/integration_test/_build/Release
if: ${{ matrix.library_type != 'object' }}

- name: Compile integration test (Debug)
shell: cmd
run: cmake --build ${{github.workspace}}/samples/integration_test/_build --config Debug
working-directory: ${{ github.workspace }}/samples/integration_test
if: ${{ matrix.library_type != 'object' }}

- name: Run integration test (Debug)
run: |
Expand All @@ -125,3 +156,4 @@ jobs:
}
.\integration_test.exe
working-directory: ${{ github.workspace }}/samples/integration_test/_build/Debug
if: ${{ matrix.library_type != 'object' }}
11 changes: 7 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
[submodule "thirdparty/asio"]
path = thirdparty/asio
[submodule "thirdparty/asio/asio"]
path = thirdparty/asio/asio
url = https://github.com/chriskohlhoff/asio.git
[submodule "thirdparty/recycle"]
path = thirdparty/recycle
[submodule "thirdparty/recycle/recycle"]
path = thirdparty/recycle/recycle
url = https://github.com/steinwurf/recycle.git
[submodule "thirdparty/gtest/googletest"]
path = thirdparty/gtest/googletest
url = https://github.com/google/googletest.git
Loading

0 comments on commit 4fd6970

Please sign in to comment.