Skip to content

Commit 8d1d5da

Browse files
committed
Merge branch '11-docs-add-badges-to-readme' into release
2 parents 931fe46 + 62560fe commit 8d1d5da

54 files changed

Lines changed: 29727 additions & 3 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ release, staging ]
6+
pull_request:
7+
branches: [ release, staging ]
8+
env:
9+
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
10+
11+
jobs:
12+
build:
13+
name: ${{ matrix.os }} / ${{ matrix.compiler }}
14+
runs-on: ${{ matrix.os }}
15+
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
os: [ubuntu-22.04, ubuntu-24.04]
20+
compiler: [gcc-13, gcc-14, gcc-15, clang-17, clang-18, clang-19, clang-20]
21+
include:
22+
- compiler: gcc-13
23+
compiler-version: 13
24+
- compiler: gcc-14
25+
compiler-version: 14
26+
- compiler: gcc-15
27+
compiler-version: 15
28+
- compiler: clang-17
29+
compiler-version: 17
30+
- compiler: clang-18
31+
compiler-version: 18
32+
- compiler: clang-19
33+
compiler-version: 19
34+
- compiler: clang-20
35+
compiler-version: 20
36+
steps:
37+
- name: Set badge output directory
38+
id: path
39+
run: |
40+
if [[ "${GITHUB_REF##*/}" == "staging" ]]; then
41+
echo "dir=status-staging" >> $GITHUB_OUTPUT
42+
else
43+
echo "dir=status" >> $GITHUB_OUTPUT
44+
fi
45+
46+
- name: Check skip list
47+
id: skip_check
48+
run: |
49+
skip_list=(
50+
"ubuntu-22.04:gcc-14"
51+
"ubuntu-22.04:gcc-15"
52+
"ubuntu-24.04:gcc-15"
53+
"ubuntu-24.04:clang-17"
54+
"macos-13:gcc-13"
55+
"macos-13:gcc-14"
56+
"macos-13:gcc-15"
57+
)
58+
59+
combo="${{ matrix.os }}:${{ matrix.compiler }}"
60+
echo "Checking combination: $combo"
61+
for skip in "${skip_list[@]}"; do
62+
if [[ "$combo" == "$skip" ]]; then
63+
echo "SKIP_COMPILE=true" >> "$GITHUB_ENV"
64+
exit 0
65+
fi
66+
done
67+
echo "SKIP_COMPILE=false" >> "$GITHUB_ENV"
68+
69+
- name: Setup compiler on macOS
70+
if: ${{ env.SKIP_COMPILE == 'false' && runner.os == 'macOS' }}
71+
run: |
72+
brew install llvm@${{ matrix.compiler-version }}
73+
echo "CC=$(brew --prefix llvm@${{ matrix.compiler-version }})/bin/clang" >> $GITHUB_ENV
74+
echo "CXX=$(brew --prefix llvm@${{ matrix.compiler-version }})/bin/clang++" >> $GITHUB_ENV
75+
76+
- name: Setup compiler on Linux
77+
if: ${{ env.SKIP_COMPILE == 'false' && runner.os == 'Linux' }}
78+
run: |
79+
compiler="${{ matrix.compiler }}"
80+
version="${{ matrix.compiler-version }}"
81+
82+
if [[ "$compiler" == clang-* ]]; then
83+
sudo apt-get update
84+
sudo apt-get install -y wget gnupg lsb-release software-properties-common
85+
wget https://apt.llvm.org/llvm.sh
86+
chmod +x llvm.sh
87+
codename="$(. /etc/os-release && echo "$VERSION_CODENAME")"
88+
sudo DISTRIB_CODENAME="$codename" ./llvm.sh "$version" all
89+
CXX="clang++-$version"
90+
elif [[ "$compiler" == gcc-* ]]; then
91+
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
92+
sudo apt-get update
93+
sudo apt-get install -y g++-"$version"
94+
CXX="g++-$version"
95+
else
96+
CXX="g++"
97+
fi
98+
99+
which "$CXX" || { echo "$CXX not found in PATH"; exit 1; }
100+
echo "CXX=$(which $CXX)" >> "$GITHUB_ENV"
101+
102+
- name: Checkout
103+
uses: actions/checkout@v5
104+
with:
105+
fetch-depth: 0
106+
107+
- name: Install system dependencies on macOS
108+
if: ${{ env.SKIP_COMPILE == 'false' && runner.os == 'macOS' }}
109+
run: |
110+
brew update
111+
112+
- name: Install system dependencies on Linux
113+
if: ${{ env.SKIP_COMPILE == 'false' && runner.os == 'Linux' }}
114+
run: |
115+
sudo apt-get update
116+
sudo apt-get install -y cmake ninja-build
117+
118+
- name: Configure
119+
if: env.SKIP_COMPILE == 'false'
120+
run: cmake -B build -DCMAKE_CXX_COMPILER=$CXX -DCMAKE_CXX_STANDARD=23 -DCMAKE_BUILD_TYPE=Release
121+
122+
- name: Build
123+
if: env.SKIP_COMPILE == 'false'
124+
run: cmake --build build --parallel
125+
126+
- name: Test
127+
if: env.SKIP_COMPILE == 'false'
128+
run: ctest --test-dir build --output-on-failure
129+
130+
- name: Record Badge Status
131+
if: always()
132+
run: |
133+
mkdir -p badge-status
134+
status="skipped"
135+
if [[ "$SKIP_COMPILE" == "false" ]]; then
136+
status="${{ job.status }}"
137+
fi
138+
139+
cat <<EOF > badge-status/status-${{ matrix.os }}-${{ matrix.compiler }}.json
140+
{
141+
"os": "${{ matrix.os }}",
142+
"compiler": "${{ matrix.compiler }}",
143+
"status": "$status"
144+
}
145+
EOF
146+
- name: Upload Status Artifact
147+
if: always()
148+
uses: actions/upload-artifact@v6
149+
with:
150+
name: status-${{ matrix.os }}-${{ matrix.compiler }}
151+
path: badge-status/status-${{ matrix.os }}-${{ matrix.compiler }}.json
152+
153+
generate-badges:
154+
name: Generate SVG Badges
155+
runs-on: ubuntu-latest
156+
needs: build
157+
if: always()
158+
159+
steps:
160+
- name: Determine badge target directory
161+
id: badge_dir
162+
run: |
163+
if [[ "${GITHUB_REF##*/}" == "staging" ]]; then
164+
echo "dir=badges-staging" >> $GITHUB_OUTPUT
165+
else
166+
echo "dir=badges" >> $GITHUB_OUTPUT
167+
fi
168+
169+
- name: Install jq
170+
run: sudo apt-get update && sudo apt-get install -y jq
171+
172+
- name: Download all badge status artifacts
173+
uses: actions/download-artifact@v7
174+
with:
175+
path: badge-status
176+
pattern: status-*
177+
merge-multiple: true
178+
179+
- name: Generate SVG Badges
180+
run: |
181+
mkdir -p ${{ steps.badge_dir.outputs.dir }}
182+
for f in badge-status/*.json; do
183+
echo "file name: $f"
184+
[[ ! -f "$f" ]] && continue
185+
os=$(jq -r .os "$f")
186+
compiler=$(jq -r .compiler "$f")
187+
status=$(jq -r .status "$f")
188+
189+
color="gray"
190+
symbol="□"
191+
prefix="unknown"
192+
193+
[[ "$status" == "success" ]] && { symbol="✔"; color="green"; prefix="ok"; }
194+
[[ "$status" == "skipped" ]] && { symbol="○"; color="gray"; prefix="na"; }
195+
[[ "$status" == "failure" ]] && { symbol="✘"; color="red"; prefix="failed"; }
196+
197+
label="${os}-${compiler}"
198+
badge="${{ steps.badge_dir.outputs.dir }}/${label}.svg"
199+
echo "https://img.shields.io/badge/${prefix}-${symbol}-${color}.svg $badge"
200+
curl -s "https://img.shields.io/badge/${prefix}-${symbol}-${color}.svg" -o "$badge"
201+
done
202+
203+
- name: Upload badge folder to GitHub Pages
204+
uses: peaceiris/actions-gh-pages@v4
205+
with:
206+
github_token: ${{ secrets.GITHUB_TOKEN }}
207+
publish_dir: ./${{ steps.badge_dir.outputs.dir }}
208+
destination_dir: ${{ steps.badge_dir.outputs.dir }}

.github/workflows/docs.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Deploy Documentation
2+
3+
on:
4+
push:
5+
branches: [release, staging]
6+
7+
permissions:
8+
contents: write
9+
10+
jobs:
11+
deploy:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout repo
16+
uses: actions/checkout@v4
17+
18+
- name: Set up Python
19+
uses: actions/setup-python@v5
20+
with:
21+
python-version: '3.x'
22+
23+
- name: Install MkDocs + Material theme
24+
run: |
25+
pip install mkdocs mkdocs-material
26+
27+
- name: Build documentation
28+
run: mkdocs build
29+
30+
- name: Deploy to GitHub Pages
31+
uses: peaceiris/actions-gh-pages@v4
32+
with:
33+
github_token: ${{ secrets.GITHUB_TOKEN }}
34+
publish_dir: ./site

CMakeLists.txt

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
# This file is part of the libdecimal project and is licensed under the MIT License.
2+
#
3+
# Copyright © 2025–2026 Varga Labs, Toronto, ON, Canada 🇨🇦
4+
# Contact: info@vargalabs.com
5+
6+
cmake_minimum_required(VERSION 3.22)
7+
project(libdecimal VERSION 0.1.0 DESCRIPTION "Deterministic Decimal Arithmetic Built on Intel LIBBID" LANGUAGES CXX)
8+
9+
include(GNUInstallDirs)
10+
include(CMakePackageConfigHelpers)
11+
include(CTest)
12+
13+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
14+
15+
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
16+
message(WARNING "In-source builds are discouraged. Skipping compile_commands.json symlink.")
17+
else()
18+
execute_process(
19+
COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/compile_commands.json ${CMAKE_SOURCE_DIR}/compile_commands.json
20+
RESULT_VARIABLE symlink_result OUTPUT_QUIET ERROR_QUIET)
21+
endif()
22+
23+
set(CMAKE_CXX_STANDARD 23)
24+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
25+
set(CMAKE_CXX_EXTENSIONS OFF)
26+
27+
option(libdecimal_BUILD_TESTS "Build tests" ${BUILD_TESTING})
28+
option(libdecimal_BUILD_DOCS "Enable MkDocs documentation targets" ON)
29+
30+
set(git_commit_hash "unknown")
31+
set(git_tag "")
32+
33+
find_package(Git QUIET)
34+
if(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
35+
execute_process( COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE git_commit_hash OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
36+
execute_process( COMMAND ${GIT_EXECUTABLE} describe --tags --abbrev=0 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE git_tag OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET )
37+
endif()
38+
39+
if(git_tag)
40+
set(libdecimal_version_string "${git_tag}")
41+
else()
42+
set(libdecimal_version_string "${PROJECT_VERSION}")
43+
endif()
44+
45+
# Third-party dependencies
46+
add_subdirectory(thirdparty EXCLUDE_FROM_ALL)
47+
# Public library target
48+
49+
add_library(libdecimal INTERFACE)
50+
add_library(libdecimal::libdecimal ALIAS libdecimal)
51+
target_compile_features(libdecimal INTERFACE cxx_std_23)
52+
target_include_directories(libdecimal INTERFACE $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
53+
target_compile_definitions(libdecimal INTERFACE libdecimal_SOFTWARE_VERSION="${libdecimal_version_string}" libdecimal_SOFTWARE_COMMIT_HASH="${git_commit_hash}" )
54+
target_link_libraries(libdecimal INTERFACE libdecimal::libbid_static )
55+
# ------------------------------------------------------------------------------
56+
# Installation
57+
# ------------------------------------------------------------------------------
58+
install( FILES ${CMAKE_SOURCE_DIR}/include/libdecimal.hpp DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
59+
install( TARGETS libdecimal libbid_static EXPORT libdecimal_targets)
60+
install( FILES ${libbid_static_archive} DESTINATION ${CMAKE_INSTALL_LIBDIR} )
61+
install( DIRECTORY ${libbid_static_include_dir}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libbid FILES_MATCHING PATTERN "*.h")
62+
install( EXPORT libdecimal_targets FILE libdecimal_targets.cmake NAMESPACE libdecimal:: DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libdecimal)
63+
64+
configure_package_config_file( ${CMAKE_SOURCE_DIR}/cmake/libdecimal_config.cmake.in ${CMAKE_BINARY_DIR}/libdecimal_config.cmake INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libdecimal )
65+
write_basic_package_version_file( ${CMAKE_BINARY_DIR}/libdecimal_config_version.cmake VERSION ${PROJECT_VERSION} COMPATIBILITY SameMajorVersion )
66+
install( FILES ${CMAKE_BINARY_DIR}/libdecimal_config.cmake ${CMAKE_BINARY_DIR}/libdecimal_config_version.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libdecimal )
67+
# ------------------------------------------------------------------------------
68+
# Tests
69+
# ------------------------------------------------------------------------------
70+
if(libdecimal_BUILD_TESTS)
71+
enable_testing()
72+
function(add_test_case file_name)
73+
add_executable(test-${file_name} test/${file_name}.cpp)
74+
set_target_properties(test-${file_name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} )
75+
target_link_libraries(test-${file_name} PRIVATE libdecimal::libdecimal libdoctest)
76+
if(CMAKE_BUILD_TYPE MATCHES "Debug")
77+
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
78+
target_compile_options(test-${file_name} PRIVATE -fsanitize=address,undefined -fno-omit-frame-pointer )
79+
target_link_options(test-${file_name} PRIVATE -fsanitize=address,undefined )
80+
target_compile_definitions(test-${file_name} PRIVATE DEBUG)
81+
endif()
82+
endif()
83+
add_test(NAME test-${file_name} COMMAND test-${file_name})
84+
endfunction()
85+
86+
add_test_case(example)
87+
add_test_case(decimal)
88+
endif()
89+
# ------------------------------------------------------------------------------
90+
# MkDocs Documentation Targets
91+
# ------------------------------------------------------------------------------
92+
if(libdecimal_BUILD_DOCS)
93+
find_program(PYTHON_EXECUTABLE python3 REQUIRED)
94+
set(DOCS_VENV ${CMAKE_SOURCE_DIR}/.venv)
95+
set(DOCS_ACTIVATE ${DOCS_VENV}/bin/activate)
96+
set(DOCS_REQUIREMENTS ${CMAKE_SOURCE_DIR}/requirements.txt)
97+
set(DOCS_BASE_URL http://127.0.0.1:9000/blog)
98+
99+
add_custom_target(docs_venv
100+
COMMAND ${CMAKE_COMMAND} -E echo "Setting up Python virtual environment"
101+
COMMAND ${PYTHON_EXECUTABLE} -m venv ${DOCS_VENV}
102+
COMMAND ${DOCS_VENV}/bin/pip install --upgrade pip
103+
COMMAND ${DOCS_VENV}/bin/pip install -r ${DOCS_REQUIREMENTS}
104+
BYPRODUCTS ${DOCS_ACTIVATE}
105+
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
106+
COMMENT "Creating .venv and installing MkDocs dependencies"
107+
VERBATIM
108+
)
109+
110+
add_custom_target(docs_serve
111+
COMMAND ${CMAKE_COMMAND} -E echo "Starting MkDocs server at ${DOCS_BASE_URL}"
112+
COMMAND ${DOCS_VENV}/bin/mkdocs serve --livereload --dev-addr=127.0.0.1:9000
113+
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
114+
DEPENDS docs_venv
115+
COMMENT "Serving MkDocs site"
116+
USES_TERMINAL
117+
)
118+
119+
add_custom_target(docs_build
120+
COMMAND ${DOCS_VENV}/bin/mkdocs build
121+
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
122+
DEPENDS docs_venv
123+
COMMENT "Building MkDocs site"
124+
VERBATIM
125+
)
126+
127+
add_custom_target(docs_clean
128+
COMMAND ${CMAKE_COMMAND} -E rm -rf ${DOCS_VENV}
129+
COMMAND ${CMAKE_COMMAND} -E rm -rf ${CMAKE_SOURCE_DIR}/site
130+
COMMAND ${CMAKE_COMMAND} -E rm -f ${CMAKE_SOURCE_DIR}/docs/assets/social/*.png
131+
COMMENT "Cleaning documentation artifacts"
132+
)
133+
endif()

COPYRIGHT

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Copyright © 2025–2026 Varga Labs, Toronto, ON, Canada 🇨🇦
2+
SPDX-License-Identifier: MIT
3+
4+
This file is part of the RLP project. It is licensed under the MIT License.
5+
You may use, modify, and redistribute it under the terms of that license,
6+
but you must not misrepresent its origin or authorship.

LICENSE

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2025 Varga Consulting
3+
Copyright © 2025–2026 Varga Labs, Toronto, ON, Canada 🇨🇦
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal
@@ -19,3 +19,5 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
SOFTWARE.
22+
23+

0 commit comments

Comments
 (0)