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
171 changes: 171 additions & 0 deletions .github/workflows/cpp-internal.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
name: C++ Internal

on:
schedule:
- cron: 0 1 * * * # Nightly at 01:00 UTC
push:
branches:
- master
pull_request:

jobs:
linux_cmake:
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
config:
- runner: ubuntu-current
name: GCC Latest
toolchain: "./resolve_symlinks/toolchains/gcc-toolchain.cmake"
- runner: ubuntu-current
name: Clang Latest
toolchain: "./resolve_symlinks/toolchains/clang-toolchain.cmake"
- runner: ubuntu-current
name: Clang ASAN Latest
toolchain: "./resolve_symlinks/toolchains/clang-asan-toolchain.cmake"
- runner: ubuntu-current
name: Clang TSAN Latest
toolchain: "./resolve_symlinks/toolchains/clang-tsan-toolchain.cmake"
- runner: ubuntu-current
name: Clang UBSAN Latest
toolchain: "./resolve_symlinks/toolchains/clang-ubsan-toolchain.cmake"
- runner: ubuntu-old
name: GCC Oldest
toolchain: "./resolve_symlinks/toolchains/gcc-toolchain.cmake"
- runner: ubuntu-old
name: Clang Oldest
toolchain: "./resolve_symlinks/toolchains/clang-toolchain.cmake"
runs-on:
- self-hosted
- vm
- ${{ matrix.config.runner }}
name: ${{ matrix.config.name }}
steps:
# This is sometimes needed when running docker builds since these
# sometimes produce files with root ownership
- name: Ensure correct owner of repository
run: sudo chown -R actions-runner:actions-runner .
- name: Checkout source code
uses: actions/checkout@v3
- name: Waf Clean
run: python3 waf clean --no_resolve
- name: Waf Configure
run: python3 waf configure --git_protocol=git@ --cmake_toolchain=${{ matrix.config.toolchain }} --cmake_verbose
- name: Waf Build
run: python3 waf build --run_tests

valgrind:
timeout-minutes: 45
runs-on:
- self-hosted
- vm
- ubuntu-current
name: Valgrind
steps:
- name: Ensure correct owner of repository
run: sudo chown -R actions-runner:actions-runner .

- name: Checkout source code
uses: actions/checkout@v3

- name: Waf Clean
run: python3 waf clean --no_resolve

- name: Waf Configure
run: python3 waf configure --git_protocol=git@ --cmake_toolchain=./resolve_symlinks/toolchains/gcc-toolchain.cmake --cmake_verbose

- name: Waf Build
run: python3 waf build --run_tests --ctest_valgrind

zig_toolchain_build:
name: Zig Toolchain Build (Docker)
runs-on: [self-hosted, vm, ubuntu-current]
container:
image: ghcr.io/steinwurf/build-images/zig-cpp:0.14.1
options: --user 0:0
volumes:
- /root/.ssh:/root/.ssh
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Waf Clean
run: python3 waf clean --no_resolve
- name: Waf Configure with Zig Toolchain
run: python3 waf configure --git_protocol=git@ --cmake_toolchain=../resolve_symlinks/toolchains/zig-toolchain-x86_64-linux-musl.cmake --cmake_verbose
- name: Waf Build with Zig Toolchain
run: python3 waf build --run_tests

macos_cmake:
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
config:
- arch: ARM64
os: big_sur
name: Apple Big Sur (ARM)
toolchain: "./resolve_symlinks/toolchains/clang-toolchain.cmake"
runs-on:
- self-hosted
- macOS
- ${{ matrix.config.os }}
- ${{ matrix.config.arch }}
- cmake
- builder
name: ${{ matrix.config.name }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Waf Clean
run: python3 waf clean --no_resolve
- name: Waf Configure
run: python3 waf configure --git_protocol=git@ --cmake_toolchain=${{ matrix.config.toolchain }} --cmake_verbose
- name: Waf Build
run: python3 waf build --run_tests

windows_cmake:
timeout-minutes: 45
strategy:
fail-fast: false
runs-on: [self-hosted, windows, vm, windows-current]
name: Windows
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Waf Clean
run: python waf clean --no_resolve
- name: Waf Configure
run: python waf configure --git_protocol=git@ --cmake_verbose
- name: Waf Build
run: python waf build --run_tests

clang-format:
timeout-minutes: 45
name: Clang-Format
runs-on: [self-hosted, vm, ubuntu-current]
steps:
- name: Ensure correct owner of repository
run: sudo chown -R actions-runner:actions-runner .
- name: Clang format version
run: clang-format --version
- name: Checkout source code
uses: actions/checkout@v3
- name: Run Clang-format
run: find ./ -iname *.hpp -o -iname *.cpp -o -iname *.c -o -iname *.h | xargs clang-format --dry-run --Werror

workflow-keepalive:
if: github.event_name == 'schedule'
runs-on: [self-hosted, vm, ubuntu-current]
permissions:
actions: write
steps:
- name: Install GitHub CLI
run: |
sudo apt update
sudo apt install -y gh
- uses: liskin/gh-workflow-keepalive@v1

concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true
16 changes: 10 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ if(NOT DEFINED STEINWURF_RESOLVE)

endif()

# Include common CMake settings
include("${STEINWURF_RESOLVE}/toolchains/common_settings.cmake")

# poke dependency
if(NOT TARGET steinwurf::poke)
add_subdirectory("${STEINWURF_RESOLVE}/poke"
Expand All @@ -40,7 +43,7 @@ endif()

# Define library
add_library(datarecorder INTERFACE)
target_compile_features(datarecorder INTERFACE cxx_std_14)
target_compile_features(datarecorder INTERFACE cxx_std_17)
target_include_directories(datarecorder INTERFACE src/)
add_library(steinwurf::datarecorder ALIAS datarecorder)
target_link_libraries(datarecorder
Expand All @@ -57,18 +60,15 @@ install(
FILES_MATCHING
PATTERN *.hpp)



# Is top level project?
if(${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME})

# Setup testing
enable_testing()


# Google Test dependency
add_subdirectory("${STEINWURF_RESOLVE}/gtest" EXCLUDE_FROM_ALL)


# Get all steinwurf object libraries and link directly with them.
get_property(steinwurf_object_libraries GLOBAL
PROPERTY steinwurf::object_libraries)
Expand All @@ -78,6 +78,7 @@ if(${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME})


add_executable(datarecorder_test ${datarecorder_test_sources})
target_compile_features(datarecorder_test PRIVATE cxx_std_17)
target_link_libraries(datarecorder_test datarecorder)
target_link_libraries(datarecorder_test steinwurf::gtest)
target_link_libraries(datarecorder_test ${steinwurf_object_libraries})
Expand All @@ -86,4 +87,7 @@ if(${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME})

add_test(NAME datarecorder_test COMMAND datarecorder_test)

# Setup testing
enable_testing()

endif()
25 changes: 20 additions & 5 deletions src/datarecorder/datarecorder.hpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// Copyright (c) 2025 Steinwurf ApS
// All Rights Reserved
//
// THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF STEINWURF
// The copyright notice above does not evidence any
// actual or intended publication of such source code.
// Distributed under the "BSD License". See the accompanying LICENSE.rst file.

#pragma once

Expand Down Expand Up @@ -123,8 +121,25 @@ class datarecorder

/// Set the callback that will be called when a mismatch is found.
///
/// If no mismatch handler is set, the default mismatch handler will be
/// used.
/// If no mismatch handler is set, a default mismatch handler will be used.
/// The callback should return a `poke::error` object describing the
/// mismatch.
///
/// Example:
/// recorder.on_mismatch([](datarecorder::mismatch_info mismatch)
/// {
/// std::cout << "Mismatch found!" << std::endl;
/// std::cout << "Recording data: " << mismatch.recording_data
/// << std::endl;
/// std::cout << "Mismatch data: " << mismatch.mismatch_data
/// << std::endl;
/// return poke::make_error(
//// std::make_error_code(std::errc::invalid_argument),
/// poke::log::str{"recording_data",
/// mismatch.recording_data},
/// poke::log::str{"mismatch_data",
/// mismatch.mismatch_data});
/// });
void on_mismatch(std::function<poke::error(mismatch_info)> callback)
{
m_on_mismatch = callback;
Expand Down
4 changes: 1 addition & 3 deletions src/datarecorder/filter_json.hpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// Copyright (c) 2025 Steinwurf ApS
// All Rights Reserved
//
// THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF STEINWURF
// The copyright notice above does not evidence any
// actual or intended publication of such source code.
// Distributed under the "BSD License". See the accompanying LICENSE.rst file.

#pragma once

Expand Down
4 changes: 1 addition & 3 deletions src/datarecorder/mismatch_info.hpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// Copyright (c) 2025 Steinwurf ApS
// All Rights Reserved
//
// THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF STEINWURF
// The copyright notice above does not evidence any
// actual or intended publication of such source code.
// Distributed under the "BSD License". See the accompanying LICENSE.rst file.

#pragma once

Expand Down
4 changes: 1 addition & 3 deletions src/datarecorder/to_json_property.hpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// Copyright (c) 2025 Steinwurf ApS
// All Rights Reserved
//
// THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF STEINWURF
// The copyright notice above does not evidence any
// actual or intended publication of such source code.
// Distributed under the "BSD License". See the accompanying LICENSE.rst file.

#pragma once

Expand Down
8 changes: 7 additions & 1 deletion test/main.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
// Copyright (c) 2014 Steinwurf ApS
// Copyright (c) 2025 Steinwurf ApS
// All Rights Reserved
//
// Distributed under the "BSD License". See the accompanying LICENSE.rst file.

#include <cstdint>
#include <ctime>

#include <google/protobuf/stubs/common.h>
#include <gtest/gtest.h>

int main(int argc, char** argv)
{
srand(static_cast<uint32_t>(time(0)));

testing::InitGoogleTest(&argc, argv);

// Delete all global objects allocated by libprotobuf. Otherwise Valgrind
// will complain about memory leaks.
google::protobuf::ShutdownProtobufLibrary();

return RUN_ALL_TESTS();
}
6 changes: 5 additions & 1 deletion test/src/test_datarecorder.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
// Copyright (c) 2025 Steinwurf ApS
// All Rights Reserved
//
// Distributed under the "BSD License". See the accompanying LICENSE.rst file.

#include <datarecorder/datarecorder.hpp>
#include <filesystem>
#include <fstream>
Expand All @@ -6,7 +11,6 @@

TEST(datarecorder, record_string)
{

datarecorder::datarecorder recorder;

recorder.set_recording_dir("test/recordings");
Expand Down
10 changes: 5 additions & 5 deletions waf

Large diffs are not rendered by default.