Skip to content

Commit 817d8ee

Browse files
authored
Update (#1)
* Major: Initial release.
1 parent 72569ad commit 817d8ee

9 files changed

Lines changed: 221 additions & 27 deletions

File tree

.github/workflows/cpp-internal.yml

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
name: C++ Internal
2+
3+
on:
4+
schedule:
5+
- cron: 0 1 * * * # Nightly at 01:00 UTC
6+
push:
7+
branches:
8+
- master
9+
pull_request:
10+
11+
jobs:
12+
linux_cmake:
13+
timeout-minutes: 45
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
config:
18+
- runner: ubuntu-current
19+
name: GCC Latest
20+
toolchain: "./resolve_symlinks/toolchains/gcc-toolchain.cmake"
21+
- runner: ubuntu-current
22+
name: Clang Latest
23+
toolchain: "./resolve_symlinks/toolchains/clang-toolchain.cmake"
24+
- runner: ubuntu-current
25+
name: Clang ASAN Latest
26+
toolchain: "./resolve_symlinks/toolchains/clang-asan-toolchain.cmake"
27+
- runner: ubuntu-current
28+
name: Clang TSAN Latest
29+
toolchain: "./resolve_symlinks/toolchains/clang-tsan-toolchain.cmake"
30+
- runner: ubuntu-current
31+
name: Clang UBSAN Latest
32+
toolchain: "./resolve_symlinks/toolchains/clang-ubsan-toolchain.cmake"
33+
- runner: ubuntu-old
34+
name: GCC Oldest
35+
toolchain: "./resolve_symlinks/toolchains/gcc-toolchain.cmake"
36+
- runner: ubuntu-old
37+
name: Clang Oldest
38+
toolchain: "./resolve_symlinks/toolchains/clang-toolchain.cmake"
39+
runs-on:
40+
- self-hosted
41+
- vm
42+
- ${{ matrix.config.runner }}
43+
name: ${{ matrix.config.name }}
44+
steps:
45+
# This is sometimes needed when running docker builds since these
46+
# sometimes produce files with root ownership
47+
- name: Ensure correct owner of repository
48+
run: sudo chown -R actions-runner:actions-runner .
49+
- name: Checkout source code
50+
uses: actions/checkout@v3
51+
- name: Waf Clean
52+
run: python3 waf clean --no_resolve
53+
- name: Waf Configure
54+
run: python3 waf configure --git_protocol=git@ --cmake_toolchain=${{ matrix.config.toolchain }} --cmake_verbose
55+
- name: Waf Build
56+
run: python3 waf build --run_tests
57+
58+
valgrind:
59+
timeout-minutes: 45
60+
runs-on:
61+
- self-hosted
62+
- vm
63+
- ubuntu-current
64+
name: Valgrind
65+
steps:
66+
- name: Ensure correct owner of repository
67+
run: sudo chown -R actions-runner:actions-runner .
68+
69+
- name: Checkout source code
70+
uses: actions/checkout@v3
71+
72+
- name: Waf Clean
73+
run: python3 waf clean --no_resolve
74+
75+
- name: Waf Configure
76+
run: python3 waf configure --git_protocol=git@ --cmake_toolchain=./resolve_symlinks/toolchains/gcc-toolchain.cmake --cmake_verbose
77+
78+
- name: Waf Build
79+
run: python3 waf build --run_tests --ctest_valgrind
80+
81+
zig_toolchain_build:
82+
name: Zig Toolchain Build (Docker)
83+
runs-on: [self-hosted, vm, ubuntu-current]
84+
container:
85+
image: ghcr.io/steinwurf/build-images/zig-cpp:0.14.1
86+
options: --user 0:0
87+
volumes:
88+
- /root/.ssh:/root/.ssh
89+
steps:
90+
- name: Checkout source code
91+
uses: actions/checkout@v4
92+
- name: Waf Clean
93+
run: python3 waf clean --no_resolve
94+
- name: Waf Configure with Zig Toolchain
95+
run: python3 waf configure --git_protocol=git@ --cmake_toolchain=../resolve_symlinks/toolchains/zig-toolchain-x86_64-linux-musl.cmake --cmake_verbose
96+
- name: Waf Build with Zig Toolchain
97+
run: python3 waf build --run_tests
98+
99+
macos_cmake:
100+
timeout-minutes: 45
101+
strategy:
102+
fail-fast: false
103+
matrix:
104+
config:
105+
- arch: ARM64
106+
os: big_sur
107+
name: Apple Big Sur (ARM)
108+
toolchain: "./resolve_symlinks/toolchains/clang-toolchain.cmake"
109+
runs-on:
110+
- self-hosted
111+
- macOS
112+
- ${{ matrix.config.os }}
113+
- ${{ matrix.config.arch }}
114+
- cmake
115+
- builder
116+
name: ${{ matrix.config.name }}
117+
steps:
118+
- name: Checkout
119+
uses: actions/checkout@v3
120+
- name: Waf Clean
121+
run: python3 waf clean --no_resolve
122+
- name: Waf Configure
123+
run: python3 waf configure --git_protocol=git@ --cmake_toolchain=${{ matrix.config.toolchain }} --cmake_verbose
124+
- name: Waf Build
125+
run: python3 waf build --run_tests
126+
127+
windows_cmake:
128+
timeout-minutes: 45
129+
strategy:
130+
fail-fast: false
131+
runs-on: [self-hosted, windows, vm, windows-current]
132+
name: Windows
133+
steps:
134+
- name: Checkout
135+
uses: actions/checkout@v3
136+
- name: Waf Clean
137+
run: python waf clean --no_resolve
138+
- name: Waf Configure
139+
run: python waf configure --git_protocol=git@ --cmake_verbose
140+
- name: Waf Build
141+
run: python waf build --run_tests
142+
143+
clang-format:
144+
timeout-minutes: 45
145+
name: Clang-Format
146+
runs-on: [self-hosted, vm, ubuntu-current]
147+
steps:
148+
- name: Ensure correct owner of repository
149+
run: sudo chown -R actions-runner:actions-runner .
150+
- name: Clang format version
151+
run: clang-format --version
152+
- name: Checkout source code
153+
uses: actions/checkout@v3
154+
- name: Run Clang-format
155+
run: find ./ -iname *.hpp -o -iname *.cpp -o -iname *.c -o -iname *.h | xargs clang-format --dry-run --Werror
156+
157+
workflow-keepalive:
158+
if: github.event_name == 'schedule'
159+
runs-on: [self-hosted, vm, ubuntu-current]
160+
permissions:
161+
actions: write
162+
steps:
163+
- name: Install GitHub CLI
164+
run: |
165+
sudo apt update
166+
sudo apt install -y gh
167+
- uses: liskin/gh-workflow-keepalive@v1
168+
169+
concurrency:
170+
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
171+
cancel-in-progress: true

CMakeLists.txt

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ if(NOT DEFINED STEINWURF_RESOLVE)
1616

1717
endif()
1818

19+
# Include common CMake settings
20+
include("${STEINWURF_RESOLVE}/toolchains/common_settings.cmake")
21+
1922
# poke dependency
2023
if(NOT TARGET steinwurf::poke)
2124
add_subdirectory("${STEINWURF_RESOLVE}/poke"
@@ -40,7 +43,7 @@ endif()
4043

4144
# Define library
4245
add_library(datarecorder INTERFACE)
43-
target_compile_features(datarecorder INTERFACE cxx_std_14)
46+
target_compile_features(datarecorder INTERFACE cxx_std_17)
4447
target_include_directories(datarecorder INTERFACE src/)
4548
add_library(steinwurf::datarecorder ALIAS datarecorder)
4649
target_link_libraries(datarecorder
@@ -57,18 +60,15 @@ install(
5760
FILES_MATCHING
5861
PATTERN *.hpp)
5962

60-
61-
6263
# Is top level project?
6364
if(${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME})
6465

65-
# Setup testing
66-
enable_testing()
66+
6767

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

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

7979

8080
add_executable(datarecorder_test ${datarecorder_test_sources})
81+
target_compile_features(datarecorder_test PRIVATE cxx_std_17)
8182
target_link_libraries(datarecorder_test datarecorder)
8283
target_link_libraries(datarecorder_test steinwurf::gtest)
8384
target_link_libraries(datarecorder_test ${steinwurf_object_libraries})
@@ -86,4 +87,7 @@ if(${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME})
8687

8788
add_test(NAME datarecorder_test COMMAND datarecorder_test)
8889

90+
# Setup testing
91+
enable_testing()
92+
8993
endif()

src/datarecorder/datarecorder.hpp

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
// Copyright (c) 2025 Steinwurf ApS
22
// All Rights Reserved
33
//
4-
// THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF STEINWURF
5-
// The copyright notice above does not evidence any
6-
// actual or intended publication of such source code.
4+
// Distributed under the "BSD License". See the accompanying LICENSE.rst file.
75

86
#pragma once
97

@@ -123,8 +121,25 @@ class datarecorder
123121

124122
/// Set the callback that will be called when a mismatch is found.
125123
///
126-
/// If no mismatch handler is set, the default mismatch handler will be
127-
/// used.
124+
/// If no mismatch handler is set, a default mismatch handler will be used.
125+
/// The callback should return a `poke::error` object describing the
126+
/// mismatch.
127+
///
128+
/// Example:
129+
/// recorder.on_mismatch([](datarecorder::mismatch_info mismatch)
130+
/// {
131+
/// std::cout << "Mismatch found!" << std::endl;
132+
/// std::cout << "Recording data: " << mismatch.recording_data
133+
/// << std::endl;
134+
/// std::cout << "Mismatch data: " << mismatch.mismatch_data
135+
/// << std::endl;
136+
/// return poke::make_error(
137+
//// std::make_error_code(std::errc::invalid_argument),
138+
/// poke::log::str{"recording_data",
139+
/// mismatch.recording_data},
140+
/// poke::log::str{"mismatch_data",
141+
/// mismatch.mismatch_data});
142+
/// });
128143
void on_mismatch(std::function<poke::error(mismatch_info)> callback)
129144
{
130145
m_on_mismatch = callback;

src/datarecorder/filter_json.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
// Copyright (c) 2025 Steinwurf ApS
22
// All Rights Reserved
33
//
4-
// THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF STEINWURF
5-
// The copyright notice above does not evidence any
6-
// actual or intended publication of such source code.
4+
// Distributed under the "BSD License". See the accompanying LICENSE.rst file.
75

86
#pragma once
97

src/datarecorder/mismatch_info.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
// Copyright (c) 2025 Steinwurf ApS
22
// All Rights Reserved
33
//
4-
// THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF STEINWURF
5-
// The copyright notice above does not evidence any
6-
// actual or intended publication of such source code.
4+
// Distributed under the "BSD License". See the accompanying LICENSE.rst file.
75

86
#pragma once
97

src/datarecorder/to_json_property.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
// Copyright (c) 2025 Steinwurf ApS
22
// All Rights Reserved
33
//
4-
// THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF STEINWURF
5-
// The copyright notice above does not evidence any
6-
// actual or intended publication of such source code.
4+
// Distributed under the "BSD License". See the accompanying LICENSE.rst file.
75

86
#pragma once
97

test/main.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
1-
// Copyright (c) 2014 Steinwurf ApS
1+
// Copyright (c) 2025 Steinwurf ApS
22
// All Rights Reserved
33
//
44
// Distributed under the "BSD License". See the accompanying LICENSE.rst file.
55

66
#include <cstdint>
77
#include <ctime>
88

9+
#include <google/protobuf/stubs/common.h>
910
#include <gtest/gtest.h>
1011

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

1516
testing::InitGoogleTest(&argc, argv);
17+
18+
// Delete all global objects allocated by libprotobuf. Otherwise Valgrind
19+
// will complain about memory leaks.
20+
google::protobuf::ShutdownProtobufLibrary();
21+
1622
return RUN_ALL_TESTS();
1723
}

test/src/test_datarecorder.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
// Copyright (c) 2025 Steinwurf ApS
2+
// All Rights Reserved
3+
//
4+
// Distributed under the "BSD License". See the accompanying LICENSE.rst file.
5+
16
#include <datarecorder/datarecorder.hpp>
27
#include <filesystem>
38
#include <fstream>
@@ -6,7 +11,6 @@
611

712
TEST(datarecorder, record_string)
813
{
9-
1014
datarecorder::datarecorder recorder;
1115

1216
recorder.set_recording_dir("test/recordings");

waf

Lines changed: 5 additions & 5 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)