Skip to content

Commit e495dcc

Browse files
committed
Initial implementation of slick-dynamic-buffer with CI and release workflows
1 parent 1e0dcda commit e495dcc

11 files changed

Lines changed: 831 additions & 2 deletions

File tree

.github/FUNDING.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# These are supported funding model platforms
2+
3+
github: SlickQuant
4+
patreon: # Replace with a single Patreon username
5+
open_collective: # Replace with a single Open Collective username
6+
ko_fi: # Replace with a single Ko-fi username
7+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9+
liberapay: # Replace with a single Liberapay username
10+
issuehunt: # Replace with a single IssueHunt username
11+
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
12+
polar: # Replace with a single Polar username
13+
buy_me_a_coffee: # Replace with a single Buy Me a Coffee username
14+
thanks_dev: # Replace with a single thanks.dev username
15+
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

.github/workflows/ci.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
build-and-test:
14+
strategy:
15+
matrix:
16+
os: [ubuntu-latest, windows-latest, macos-latest]
17+
build_type: [Release, Debug]
18+
19+
runs-on: ${{ matrix.os }}
20+
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
# apt/brew Boost ships no boost_asio-config.cmake, so
25+
# find_package(Boost CONFIG COMPONENTS asio) only works with vcpkg's Boost.
26+
# vcpkg is preinstalled on all GitHub-hosted runners, but the macOS image
27+
# does not set VCPKG_INSTALLATION_ROOT - bootstrap our own copy if missing.
28+
- name: Set up vcpkg
29+
shell: bash
30+
run: |
31+
if [ -z "${VCPKG_INSTALLATION_ROOT:-}" ]; then
32+
git clone --depth 1 https://github.com/microsoft/vcpkg.git "$RUNNER_TEMP/vcpkg"
33+
"$RUNNER_TEMP/vcpkg/bootstrap-vcpkg.sh" -disableMetrics
34+
echo "VCPKG_INSTALLATION_ROOT=$RUNNER_TEMP/vcpkg" >> "$GITHUB_ENV"
35+
echo "$RUNNER_TEMP/vcpkg" >> "$GITHUB_PATH"
36+
fi
37+
38+
# vcpkg stores built packages in VCPKG_DEFAULT_BINARY_CACHE; cache entries are
39+
# content-addressed by vcpkg's ABI hash, keyed on the vcpkg checkout commit so
40+
# the cache is rebuilt exactly when the runner image updates its vcpkg baseline.
41+
- name: Prepare vcpkg binary cache
42+
id: vcpkg-info
43+
shell: bash
44+
run: |
45+
echo "VCPKG_DEFAULT_BINARY_CACHE=$RUNNER_TEMP/vcpkg-binary-cache" >> "$GITHUB_ENV"
46+
mkdir -p "$RUNNER_TEMP/vcpkg-binary-cache"
47+
git config --global --add safe.directory "$VCPKG_INSTALLATION_ROOT"
48+
echo "commit=$(git -C "$VCPKG_INSTALLATION_ROOT" rev-parse --short HEAD || echo unknown)" >> "$GITHUB_OUTPUT"
49+
50+
- name: Restore vcpkg binary cache
51+
uses: actions/cache@v4
52+
with:
53+
path: ${{ env.VCPKG_DEFAULT_BINARY_CACHE }}
54+
key: vcpkg-${{ runner.os }}-${{ runner.arch }}-${{ steps.vcpkg-info.outputs.commit }}
55+
restore-keys: |
56+
vcpkg-${{ runner.os }}-${{ runner.arch }}-
57+
58+
- name: Install Boost.Asio (vcpkg)
59+
shell: bash
60+
run: vcpkg install boost-asio
61+
62+
- name: Configure CMake
63+
shell: bash
64+
run: cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_TOOLCHAIN_FILE="$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake"
65+
66+
- name: Build
67+
run: cmake --build build --config ${{ matrix.build_type }}
68+
69+
- name: Run Tests
70+
working-directory: build
71+
run: ctest -C ${{ matrix.build_type }} --output-on-failure

.github/workflows/release.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Create Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*' # Trigger on version tags like v0.1.0, v1.0.0, etc.
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
create-release:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: Extract version from tag
19+
id: get_version
20+
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
21+
22+
- name: Extract changelog for this version
23+
id: changelog
24+
run: |
25+
if [ -f CHANGELOG.md ]; then
26+
# Extract the section for this version from CHANGELOG.md
27+
VERSION="${{ github.ref_name }}"
28+
# Escape dots in version for regex
29+
VERSION_ESCAPED=$(echo "$VERSION" | sed 's/\./\\./g')
30+
# Use awk to extract content: start at version header, stop at next ## header
31+
CHANGES=$(awk "BEGIN{p=0} /^## $VERSION_ESCAPED( |$)/{p=1;next} /^## /{p=0} p" CHANGELOG.md | sed '/^$/d')
32+
33+
if [ -z "$CHANGES" ]; then
34+
echo "CHANGELOG_CONTENT=No changelog entry found for this version." >> $GITHUB_OUTPUT
35+
else
36+
# Escape newlines for GitHub output
37+
echo "CHANGELOG_CONTENT<<EOF" >> $GITHUB_OUTPUT
38+
echo "$CHANGES" >> $GITHUB_OUTPUT
39+
echo "EOF" >> $GITHUB_OUTPUT
40+
fi
41+
else
42+
echo "CHANGELOG_CONTENT=CHANGELOG.md not found." >> $GITHUB_OUTPUT
43+
fi
44+
45+
- name: Create header archive
46+
run: |
47+
zip -r ./slick-dynamic-buffer-${{ steps.get_version.outputs.VERSION }}.zip include/
48+
tar -czf ./slick-dynamic-buffer-${{ steps.get_version.outputs.VERSION }}.tar.gz include/
49+
50+
- name: Create Release
51+
uses: softprops/action-gh-release@v1
52+
with:
53+
name: Release ${{ github.ref_name }}
54+
body: |
55+
## Changes
56+
57+
${{ steps.changelog.outputs.CHANGELOG_CONTENT }}
58+
59+
draft: true
60+
prerelease: false
61+
generate_release_notes: false
62+
files: |
63+
slick-dynamic-buffer-${{ steps.get_version.outputs.VERSION }}.zip
64+
slick-dynamic-buffer-${{ steps.get_version.outputs.VERSION }}.tar.gz

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,9 @@ vcpkg_installed/
6767
# test output & cache
6868
Testing/
6969
.cache/
70+
71+
.vs
72+
.vscode
73+
cmake-build-*
74+
build
75+
out

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Changelog
2+
3+
## v1.0.0 - 2026-06-12
4+
5+
Initial release.
6+
7+
- `slick::dynamic_buffer` — Boost.Asio `DynamicBuffer_v1` adapter, drop-in
8+
replacement for `boost::beast::flat_buffer`; `consume(n)` publishes the consumed
9+
bytes to consumers as one message record (zero-copy fan-out).
10+
- The API uses the `slick::stream_buffer` spelling of the core buffer, so
11+
slick-stream-buffer >= v1.0.4 is required.
12+
- GoogleTest suites for the asio adapter (including a real TCP loopback test); CI for Windows/Linux/macOS.

CMakeLists.txt

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
cmake_minimum_required(VERSION 3.10)
2+
3+
project(slick-dynamic-buffer
4+
VERSION 1.0.0
5+
DESCRIPTION "Header-only Boost.Asio DynamicBuffer adapter for slick-stream-buffer - zero-copy fan-out of received network bytes to lock-free SPMC consumers across threads and processes"
6+
LANGUAGES CXX)
7+
8+
set(CMAKE_CXX_STANDARD 20)
9+
10+
# Options:
11+
option(BUILD_SLICK_DYNAMIC_BUFFER_TESTS "Build tests" ${PROJECT_IS_TOP_LEVEL})
12+
13+
find_package(Boost CONFIG REQUIRED COMPONENTS asio)
14+
find_package(slick-stream-buffer CONFIG QUIET)
15+
16+
if (NOT slick-stream-buffer_FOUND)
17+
include(FetchContent)
18+
19+
# Disable slick-stream-buffer tests and examples, but allow installation
20+
set(BUILD_SLICK_STREAM_BUFFER_TESTS OFF CACHE BOOL "" FORCE)
21+
FetchContent_Declare(
22+
slick-stream-buffer
23+
GIT_REPOSITORY https://github.com/SlickQuant/slick-stream-buffer.git
24+
GIT_TAG v1.0.4 # See https://github.com/SlickQuant/slick-stream-buffer/releases for latest version
25+
)
26+
FetchContent_MakeAvailable(slick-stream-buffer)
27+
else()
28+
message(STATUS "slick-stream-buffer: ${slick-stream-buffer_VERSION}")
29+
endif()
30+
31+
add_library(slick-dynamic-buffer INTERFACE)
32+
add_library(slick::dynamic_buffer ALIAS slick-dynamic-buffer)
33+
34+
target_include_directories(slick-dynamic-buffer INTERFACE
35+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
36+
$<INSTALL_INTERFACE:include>
37+
)
38+
set_target_properties(slick-dynamic-buffer PROPERTIES EXPORT_NAME dynamic_buffer)
39+
40+
target_link_libraries(slick-dynamic-buffer INTERFACE slick::stream_buffer Boost::asio)
41+
42+
if(BUILD_SLICK_DYNAMIC_BUFFER_TESTS)
43+
enable_testing()
44+
add_subdirectory(tests)
45+
endif()
46+
47+
# Generate and install CMake config files for vcpkg compatibility
48+
include(CMakePackageConfigHelpers)
49+
50+
# Create the config file
51+
configure_package_config_file(
52+
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/slick-dynamic-bufferConfig.cmake.in"
53+
"${CMAKE_CURRENT_BINARY_DIR}/slick-dynamic-bufferConfig.cmake"
54+
INSTALL_DESTINATION lib/cmake/slick-dynamic-buffer
55+
)
56+
57+
# Create the version file
58+
write_basic_package_version_file(
59+
"${CMAKE_CURRENT_BINARY_DIR}/slick-dynamic-bufferConfigVersion.cmake"
60+
VERSION ${PROJECT_VERSION}
61+
COMPATIBILITY SameMajorVersion
62+
)
63+
64+
# Install the config files
65+
install(FILES
66+
"${CMAKE_CURRENT_BINARY_DIR}/slick-dynamic-bufferConfig.cmake"
67+
"${CMAKE_CURRENT_BINARY_DIR}/slick-dynamic-bufferConfigVersion.cmake"
68+
DESTINATION lib/cmake/slick-dynamic-buffer
69+
)
70+
71+
# Install the target
72+
install(TARGETS slick-dynamic-buffer
73+
EXPORT slick-dynamic-bufferTargets
74+
)
75+
76+
# Install the export set
77+
install(EXPORT slick-dynamic-bufferTargets
78+
FILE slick-dynamic-bufferTargets.cmake
79+
NAMESPACE slick::
80+
DESTINATION lib/cmake/slick-dynamic-buffer
81+
)
82+
83+
message(STATUS "${PROJECT_NAME}: ${PROJECT_VERSION}")

0 commit comments

Comments
 (0)