Skip to content

Commit 95e6049

Browse files
authored
Set recording template (#7)
* Minor: Added ``set_mismatch_template()`` to configure the mismatch HTML template path. * Minor: Custom mismatch template paths now fail if they cannot be resolved. * Minor: Added template format validation for ``oldText`` and ``newText`` markers. * Minor: Added ``in_github_actions()`` to detect when tests run in GitHub Actions. * Patch: Mismatch errors now include full recording/mismatch payload only in GitHub Actions. * Patch: Added a test that prints mismatch error output for debugging and CI diagnostics.
1 parent dcd6183 commit 95e6049

10 files changed

Lines changed: 237 additions & 68 deletions

File tree

.github/workflows/cpp-internal.yml

Lines changed: 29 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
name: C++ Internal
2-
32
on:
43
schedule:
54
- cron: 0 1 * * * # Nightly at 01:00 UTC
65
push:
76
branches:
87
- master
98
pull_request:
10-
119
jobs:
1210
linux_cmake:
1311
timeout-minutes: 45
@@ -42,18 +40,16 @@ jobs:
4240
- ${{ matrix.config.runner }}
4341
name: ${{ matrix.config.name }}
4442
steps:
45-
# This is sometimes needed when running docker builds since these
46-
# sometimes produce files with root ownership
4743
- name: Ensure correct owner of repository
4844
run: sudo chown -R actions-runner:actions-runner .
4945
- name: Checkout source code
5046
uses: actions/checkout@v3
51-
- name: Waf Clean
52-
run: python3 waf clean --no_resolve
5347
- name: Waf Configure
5448
run: python3 waf configure --git_protocol=git@ --cmake_toolchain=${{ matrix.config.toolchain }} --cmake_verbose
5549
- name: Waf Build
56-
run: python3 waf build --run_tests
50+
run: python3 waf build
51+
- name: Waf Run Tests
52+
run: python3 waf --run_tests
5753

5854
valgrind:
5955
timeout-minutes: 45
@@ -65,37 +61,40 @@ jobs:
6561
steps:
6662
- name: Ensure correct owner of repository
6763
run: sudo chown -R actions-runner:actions-runner .
68-
6964
- name: Checkout source code
7065
uses: actions/checkout@v3
71-
72-
- name: Waf Clean
73-
run: python3 waf clean --no_resolve
74-
7566
- name: Waf Configure
7667
run: python3 waf configure --git_protocol=git@ --cmake_toolchain=./resolve_symlinks/toolchains/gcc-toolchain.cmake --cmake_verbose
77-
7868
- name: Waf Build
79-
run: python3 waf build --run_tests --ctest_valgrind
80-
69+
run: python3 waf build
70+
- name: Waf Run Tests
71+
run: python3 waf --run_tests --ctest_valgrind
8172
zig_toolchain_build:
8273
name: Zig Toolchain Build (Docker)
8374
runs-on: [self-hosted, vm, ubuntu-current]
8475
container:
85-
image: ghcr.io/steinwurf/build-images/zig-cpp:0.14.1
76+
image: ghcr.io/steinwurf/build-images/zig-cpp
8677
options: --user 0:0
87-
volumes:
88-
- /root/.ssh:/root/.ssh
8978
steps:
9079
- name: Checkout source code
9180
uses: actions/checkout@v4
92-
- name: Waf Clean
93-
run: python3 waf clean --no_resolve
81+
with:
82+
persist-credentials: false
83+
- name: Configure Github Authentication
84+
run: |
85+
git config --global credential.helper 'store'
86+
git credential approve <<EOF
87+
protocol=https
88+
host=github.com
89+
username=x-access-token
90+
password=${{ secrets.GH_ACCESS_TOKEN }}
91+
EOF
9492
- 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
93+
run: python3 waf configure --git_protocol=https:// --cmake_toolchain=./resolve_symlinks/toolchains/zig-toolchain-x86_64-linux-musl.cmake --cmake_verbose
9694
- name: Waf Build with Zig Toolchain
97-
run: python3 waf build --run_tests
98-
95+
run: python3 waf build
96+
- name: Waf Run Tests
97+
run: python3 waf --run_tests
9998
macos_cmake:
10099
timeout-minutes: 45
101100
strategy:
@@ -117,13 +116,12 @@ jobs:
117116
steps:
118117
- name: Checkout
119118
uses: actions/checkout@v3
120-
- name: Waf Clean
121-
run: python3 waf clean --no_resolve
122119
- name: Waf Configure
123120
run: python3 waf configure --git_protocol=git@ --cmake_toolchain=${{ matrix.config.toolchain }} --cmake_verbose
124121
- name: Waf Build
125-
run: python3 waf build --run_tests
126-
122+
run: python3 waf build
123+
- name: Waf Run Tests
124+
run: python3 waf --run_tests
127125
windows_cmake:
128126
timeout-minutes: 45
129127
strategy:
@@ -133,13 +131,12 @@ jobs:
133131
steps:
134132
- name: Checkout
135133
uses: actions/checkout@v3
136-
- name: Waf Clean
137-
run: python waf clean --no_resolve
138134
- name: Waf Configure
139135
run: python waf configure --git_protocol=git@ --cmake_verbose
140136
- name: Waf Build
141-
run: python waf build --run_tests
142-
137+
run: python waf build
138+
- name: Waf Run Tests
139+
run: python waf --run_tests
143140
clang-format:
144141
timeout-minutes: 45
145142
name: Clang-Format
@@ -153,7 +150,6 @@ jobs:
153150
uses: actions/checkout@v3
154151
- name: Run Clang-format
155152
run: find ./ -iname *.hpp -o -iname *.cpp -o -iname *.c -o -iname *.h | xargs clang-format --dry-run --Werror
156-
157153
workflow-keepalive:
158154
if: github.event_name == 'schedule'
159155
runs-on: [self-hosted, vm, ubuntu-current]
@@ -165,7 +161,6 @@ jobs:
165161
sudo apt update
166162
sudo apt install -y gh
167163
- uses: liskin/gh-workflow-keepalive@v1
168-
169164
concurrency:
170165
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
171-
cancel-in-progress: true
166+
cancel-in-progress: true

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ cmake_build
1616

1717
# Python
1818
*.pyc
19+
.venv/
20+
21+
# Devbox
22+
devbox.lock
1923

2024
# Compiled Doxygen documentation
2125
/doxygen/html

NEWS.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ every change, see the Git log.
66

77
Latest
88
------
9-
* tbd
9+
* Minor: Added ``set_mismatch_template()`` to configure the mismatch HTML template path.
10+
* Minor: Custom mismatch template paths now fail if they cannot be resolved.
11+
* Minor: Added template format validation for ``oldText`` and ``newText`` markers.
12+
* Minor: Added ``in_github_actions()`` to detect when tests run in GitHub Actions.
13+
* Patch: Mismatch errors now include full recording/mismatch payload only in GitHub Actions.
14+
* Patch: Added a test that prints mismatch error output for debugging and CI diagnostics.
1015

1116
2.0.0
1217
-----

README.rst

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,48 @@ Overview
88
datarecorder is a simple C++ library that is meant to provide simple helper
99
functions to ease sometimes tedious testing tasks.
1010

11+
Build and test
12+
==============
13+
14+
Configure::
15+
16+
./waf configure
17+
18+
Build::
19+
20+
./waf build
21+
22+
Run tests::
23+
24+
./waf build --run_tests
25+
26+
Mismatch template
27+
=================
28+
29+
By default, datarecorder will try to find this template:
30+
31+
- ``visualizer/recording_diff.html``
32+
33+
You can override this with::
34+
35+
recorder.set_mismatch_template("path/to/recording_diff.html");
36+
37+
If the provided path is relative, datarecorder resolves it by searching
38+
backwards from the current working directory.
39+
40+
If you provide a custom mismatch template path and it cannot be found,
41+
recording will fail.
42+
43+
Template requirements
44+
---------------------
45+
46+
The template must contain both of these JavaScript markers (using backticks)::
47+
48+
const oldText = `...`;
49+
const newText = `...`;
50+
51+
These placeholders are replaced with recording data and mismatch data.
52+
1153
License
1254
-------
1355
The stub library is released under the BSD license, see the LICENSE.rst file.

devbox.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/jetify-com/devbox/0.16.0/.schema/devbox.schema.json",
3+
"packages": [
4+
"zig_0_13@latest",
5+
"python@3.12.0",
6+
"cmake@3.28.3",
7+
"ninja@1.11.1",
8+
"python312Packages.pip@latest",
9+
"clang_18@18.1.8",
10+
"gcc@13.3.0"
11+
],
12+
"shell": {
13+
"init_hook": [
14+
"echo 'Welcome to devbox!' > /dev/null"
15+
],
16+
"scripts": {
17+
"configure": [
18+
"python3 waf clean --no_resolve",
19+
"python3 waf configure \"$@\""
20+
],
21+
"build": [
22+
"python3 waf build \"$@\""
23+
],
24+
"format": [
25+
"find ./test ./src \\( -iname '*.c' -o -iname '*.h' -o -iname '*.cpp' -o -iname '*.hpp' \\) -print0 | xargs -0 clang-format -i"
26+
]
27+
}
28+
}
29+
}

lock_version_resolve.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
"sha1": "8e016b57dd5361fe7f66ae47f3df42ab634321c5"
1616
},
1717
"bourne": {
18-
"commit_id": "cf4fed3ea15525a6608722db56f10ff4314c2354",
19-
"resolver_info": "11.0.0",
18+
"commit_id": "b824b289f1d8cbfeecc26743ea5579e5d3051c8c",
19+
"resolver_info": "11.1.0",
2020
"sha1": "f705097630cc09ecd747eaf3b5eef8966cfa4fba"
2121
},
2222
"endian": {
@@ -35,8 +35,8 @@
3535
"sha1": "5078750ed20c6d6323d27ed96fb2ddebc43bb247"
3636
},
3737
"fmt": {
38-
"commit_id": "5d5eb0f166979fa523704114620a40b3e9e6bb08",
39-
"resolver_info": "5.0.0",
38+
"commit_id": "3fba272021d507b310f4d059e3a4c1883b65fbc4",
39+
"resolver_info": "5.0.1",
4040
"sha1": "160978c7e6571cc06d6c8a590e5e0c4f3c826fba"
4141
},
4242
"fmt-source": {
@@ -60,13 +60,13 @@
6060
"sha1": "650d881b8cb6cc1adf354d47d6353db6ec4fd6a5"
6161
},
6262
"platform": {
63-
"commit_id": "7740600dfa6c8800819737dd85fb89c16c1c0c01",
64-
"resolver_info": "6.0.0",
63+
"commit_id": "9dacaa6bba5ff933d126620c073ddfe09e993336",
64+
"resolver_info": "6.1.0",
6565
"sha1": "7a014ba5a95cf7f0193213e95d3d2d8fcfa313b7"
6666
},
6767
"poke": {
68-
"commit_id": "08f354b5e559a03238d57f9cdd3826d2a32190ec",
69-
"resolver_info": "17.0.0",
68+
"commit_id": "c6175a2954de4fa6bdafaa845d66c0c2990b96b2",
69+
"resolver_info": "17.1.3",
7070
"sha1": "26bfb0923f6668c93d72f6955e9f39d3dba0ce01"
7171
},
7272
"protobuf": {
@@ -90,13 +90,13 @@
9090
"sha1": "67edfd49ad879868b7d6a48b4e72d7f0cd969b46"
9191
},
9292
"toolchains": {
93-
"commit_id": "d771e98c84304735f43db13d50edffd8e7d5a9d6",
94-
"resolver_info": "1.0.5",
93+
"commit_id": "655f6d386f0a9d4a0038388fdccb5fbfe463f1b0",
94+
"resolver_info": "1.1.0",
9595
"sha1": "443cb23b0570dffd39283d8679ec393ed809302f"
9696
},
9797
"verify": {
98-
"commit_id": "27b970938379a5a1bc1c9f4377c2686943763893",
99-
"resolver_info": "6.0.4",
98+
"commit_id": "42e744725e5a9f9e303da4b53446030a1a20a321",
99+
"resolver_info": "6.1.0",
100100
"sha1": "fed379602b6ea7bd611fc249daffa11b9e593800"
101101
},
102102
"zlib-source": {

0 commit comments

Comments
 (0)