Skip to content

Commit c15cb26

Browse files
committed
base
0 parents  commit c15cb26

File tree

16 files changed

+980
-0
lines changed

16 files changed

+980
-0
lines changed

.clang-format

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
BasedOnStyle: LLVM

.codespellignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
claus
2+
moint

.github/CODEOWNERS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2+
# Codeowners for reviews on PRs
3+
4+
* @camio @Hels15 @DeveloperPaul123 @wusatosi

.github/workflows/ci_tests.yml

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2+
3+
name: Continuous Integration Tests
4+
5+
on:
6+
push:
7+
pull_request:
8+
# Allows you to run this workflow manually from the Actions tab
9+
workflow_dispatch:
10+
schedule:
11+
- cron: '30 15 * * *'
12+
13+
jobs:
14+
# preset-test:
15+
# runs-on: ubuntu-latest
16+
# strategy:
17+
# matrix:
18+
# preset: []
19+
# name: "Preset Test: ${{ matrix.preset }}"
20+
# steps:
21+
# - uses: actions/checkout@v4
22+
# - name: Setup build environment
23+
# uses: lukka/get-cmake@latest
24+
# with:
25+
# cmakeVersion: "~3.25.0"
26+
# ninjaVersion: "^1.11.1"
27+
# - name: Run preset
28+
# run: cmake --workflow --preset ${{ matrix.preset }}
29+
30+
test:
31+
strategy:
32+
fail-fast: false
33+
matrix:
34+
platform: [ubuntu-24.04]
35+
compiler:
36+
- cpp: g++
37+
c: gcc
38+
- cpp: clang++
39+
c: clang
40+
cpp_version: [23]
41+
cmake_args:
42+
- description: "Default"
43+
args: ""
44+
- description: "TSan"
45+
args: "-DCMAKE_CXX_FLAGS=-fsanitize=thread"
46+
- description: "ASan"
47+
args: "-DCMAKE_CXX_FLAGS='-fsanitize=address -fsanitize=undefined'"
48+
include:
49+
- platform: ubuntu-24.04
50+
compiler:
51+
cpp: g++
52+
c: gcc
53+
cpp_version: 23
54+
cmake_args:
55+
description: "Werror"
56+
args: "-DCMAKE_CXX_FLAGS='-Wall -Wextra -Wpedantic -Werror'"
57+
- platform: ubuntu-24.04
58+
compiler:
59+
cpp: g++
60+
c: gcc
61+
cpp_version: 23
62+
cmake_args:
63+
description: "Dynamic"
64+
cmake_args: "-DBUILD_SHARED_LIBS=on"
65+
66+
name: "Build & Test: ${{ matrix.compiler.c }} ${{ matrix.cpp_version }} ${{ matrix.cmake_args.description }}"
67+
runs-on: ${{ matrix.platform }}
68+
steps:
69+
- uses: actions/checkout@v4
70+
- name: Install Ninja
71+
uses: lukka/get-cmake@latest
72+
with:
73+
cmakeVersion: "~3.25.0"
74+
ninjaVersion: "^1.11.1"
75+
- name: Install latest compiler
76+
run: |
77+
if [ "${{ matrix.compiler.cpp}}" == "g++" ]; then
78+
# Install gcc-14
79+
sudo apt-get update
80+
sudo apt-get install -y gcc-14 g++-14
81+
82+
sudo rm /usr/bin/gcc
83+
sudo ln -s /usr/bin/gcc-14 /usr/bin/gcc
84+
85+
sudo rm /usr/bin/g++
86+
sudo ln -s /usr/bin/g++-14 /usr/bin/g++
87+
else
88+
# Install llvm
89+
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"
90+
fi
91+
- name: Print installed software
92+
run: |
93+
clang++ --version
94+
g++ --version
95+
cmake --version
96+
ninja --version
97+
- name: Configure CMake
98+
run: |
99+
cmake -B build -S . -DCMAKE_CXX_STANDARD=${{ matrix.cpp_version }} ${{ matrix.cmake_args.args }}
100+
env:
101+
CC: ${{ matrix.compiler.c }}
102+
CXX: ${{ matrix.compiler.cpp }}
103+
CMAKE_GENERATOR: "Ninja Multi-Config"
104+
- name: Build Release
105+
run: |
106+
cmake --build build --config Release --verbose
107+
# TODO: cmake --build build --config Release --target all_verify_interface_header_sets
108+
cmake --install build --config Release --prefix /tmp/beman.inplace_vector
109+
find /tmp/beman.inplace_vector -type f
110+
- name: Test Release
111+
run: ctest --test-dir build --build-config Release
112+
- name: Build Debug
113+
run: |
114+
cmake --build build --config Debug --verbose
115+
# TODO: cmake --build build --config Debug --target all_verify_interface_header_sets
116+
cmake --install build --config Debug --prefix /tmp/beman.inplace_vector
117+
find /tmp/beman.inplace_vector -type f
118+
- name: Test Debug
119+
run: ctest --test-dir build --build-config Debug
120+
121+
create-issue-when-fault:
122+
runs-on: ubuntu-latest
123+
needs: [test]
124+
if: failure() && github.event_name == 'schedule'
125+
steps:
126+
# See https://github.com/cli/cli/issues/5075
127+
- uses: actions/checkout@v4
128+
- name: Create issue
129+
run: |
130+
issue_num=$(gh issue list -s open -S "[SCHEDULED-BUILD] Build & Test failure" -L 1 --json number | jq 'if length == 0 then -1 else .[0].number end')
131+
132+
body="**Build-and-Test Failure Report**
133+
- **Time of Failure**: $(date -u '+%B %d, %Y, %H:%M %Z')
134+
- **Commit**: [${{ github.sha }}](${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }})
135+
- **Action Run**: [View logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
136+
137+
The scheduled build-and-test triggered by cron has failed.
138+
Please investigate the logs and recent changes associated with this commit or rerun the workflow if you believe this is an error."
139+
140+
if [[ $issue_num -eq -1 ]]; then
141+
gh issue create --repo ${{ github.repository }} --title "[SCHEDULED-BUILD] Build & Test failure" --body "$body"
142+
else
143+
gh issue comment --repo ${{ github.repository }} $issue_num --body "$body"
144+
fi
145+
env:
146+
GH_TOKEN: ${{ github.token }}

.github/workflows/pre-commit.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Lint Check (pre-commit)
2+
3+
on:
4+
# We have to use pull_request_target here as pull_request does not grant
5+
# enough permission for reviewdog
6+
pull_request_target:
7+
push:
8+
9+
jobs:
10+
pre-commit-push:
11+
name: Pre-Commit check on Push
12+
runs-on: ubuntu-latest
13+
if: ${{ github.event_name == 'push' }}
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
19+
- name: Set up Python
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: 3.13
23+
24+
# We wish to run pre-commit on all files instead of the changes
25+
# only made in the push commit.
26+
#
27+
# So linting error persists when there's formatting problem.
28+
- uses: pre-commit/[email protected]
29+
30+
pre-commit-pr:
31+
name: Pre-Commit check on PR
32+
runs-on: ubuntu-latest
33+
if: ${{ github.event_name == 'pull_request_target' }}
34+
35+
permissions:
36+
contents: read
37+
checks: write
38+
issues: write
39+
pull-requests: write
40+
41+
steps:
42+
- name: Checkout repository
43+
uses: actions/checkout@v4
44+
45+
# pull_request_target checkout the base of the repo
46+
# We need to checkout the actual pr to lint the changes.
47+
- name: Checkout pr
48+
run: gh pr checkout ${{ github.event.number }}
49+
env:
50+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
52+
- name: Set up Python
53+
uses: actions/setup-python@v5
54+
with:
55+
python-version: 3.13
56+
57+
# we only lint on the changed file in PR.
58+
- name: Get Changed Files
59+
id: changed-files
60+
uses: tj-actions/changed-files@v45
61+
62+
# See:
63+
# https://github.com/tj-actions/changed-files?tab=readme-ov-file#using-local-git-directory-
64+
- uses: pre-commit/[email protected]
65+
id: run-pre-commit
66+
with:
67+
extra_args: --files ${{ steps.changed-files.outputs.all_changed_files }}
68+
69+
# Review dog posts the suggested change from pre-commit to the pr.
70+
- name: suggester / pre-commit
71+
uses: reviewdog/action-suggester@v1
72+
if: ${{ failure() && steps.run-pre-commit.conclusion == 'failure' }}
73+
with:
74+
tool_name: pre-commit
75+
level: warning
76+
reviewdog_flags: "-fail-level=error"

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/build
2+
/out
3+
CMakeUserPresets.json

.markdownlint.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# MD033/no-inline-html : Inline HTML : https://github.com/DavidAnson/markdownlint/blob/v0.35.0/doc/md033.md
2+
# Disable inline html linter is needed for <details> <summary>
3+
MD033: false
4+
5+
# MD013/line-length : Line length : https://github.com/DavidAnson/markdownlint/blob/v0.35.0/doc/md013.md
6+
# Conforms to .clang-format ColumnLimit
7+
# Update the comment in .clang-format if we no-longer tie these two column limits.
8+
MD013:
9+
line_length: 119

.pre-commit-config.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v5.0.0
6+
hooks:
7+
- id: trailing-whitespace
8+
- id: end-of-file-fixer
9+
- id: check-yaml
10+
- id: check-added-large-files
11+
12+
# Clang-format for C++
13+
# This brings in a portable version of clang-format.
14+
# See also: https://github.com/ssciwr/clang-format-wheel
15+
- repo: https://github.com/pre-commit/mirrors-clang-format
16+
rev: v18.1.8
17+
hooks:
18+
- id: clang-format
19+
types_or: [c++, c]
20+
21+
# CMake linting and formatting
22+
- repo: https://github.com/BlankSpruce/gersemi
23+
rev: 0.15.1
24+
hooks:
25+
- id: gersemi
26+
name: CMake linting
27+
28+
# Markdown linting
29+
# Config file: .markdownlint.yaml
30+
- repo: https://github.com/igorshubovych/markdownlint-cli
31+
rev: v0.42.0
32+
hooks:
33+
- id: markdownlint
34+
35+
- repo: https://github.com/codespell-project/codespell
36+
rev: v2.3.0
37+
hooks:
38+
- id: codespell
39+
files: ^.*\.(cmake|cpp|hpp|txt|md|json|in|yaml|yml)$
40+
args: ["--ignore-words", ".codespellignore" ]

CMakeLists.txt

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# cmake-format: off
2+
# /CMakeLists.txt -*-makefile-*-
3+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4+
# cmake-format: on
5+
6+
cmake_minimum_required(VERSION 3.23)
7+
8+
project(
9+
beman.inplace_vector
10+
VERSION 1.0.0
11+
DESCRIPTION
12+
"A dynamically-resizable vector with fixed capacity and embedded storage"
13+
LANGUAGES CXX
14+
)
15+
16+
# [CMAKE.SKIP_EXAMPLES]
17+
option(
18+
BEMAN_EXEMPLAR_BUILD_EXAMPLES
19+
"Enable building examples. Default: ON. Values: { ON, OFF }."
20+
${PROJECT_IS_TOP_LEVEL}
21+
)
22+
23+
# [CMAKE.SKIP_TESTS]
24+
option(
25+
BEMAN_INPLACE_VECTOR_BUILD_TESTS
26+
"Enable building tests and test infrastructure. Default: ON. Values: { ON, OFF }."
27+
${PROJECT_IS_TOP_LEVEL}
28+
)
29+
30+
include(GNUInstallDirs)
31+
32+
add_library(beman.inplace_vector INTERFACE)
33+
# [CMAKE.LIBRARY_ALIAS]
34+
add_library(beman::inplace_vector ALIAS beman.inplace_vector)
35+
36+
target_include_directories(
37+
beman.inplace_vector
38+
INTERFACE
39+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
40+
$<INSTALL_INTERFACE:include>
41+
)
42+
43+
# Install the InplaceVector library to the appropriate destination
44+
install(
45+
TARGETS beman.inplace_vector
46+
EXPORT ${TARGETS_EXPORT_NAME}
47+
DESTINATION
48+
${CMAKE_INSTALL_LIBDIR}
49+
)
50+
51+
# Install the header files to the appropriate destination
52+
install(
53+
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/
54+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${CMAKE_PROJECT_NAME}
55+
FILES_MATCHING
56+
PATTERN
57+
"${CMAKE_CURRENT_SOURCE_DIR}/include/beman/inplace_vector/inplace_vector.hpp"
58+
)
59+
60+
if(BEMAN_INPLACE_VECTOR_BUILD_TESTS)
61+
include(CTest)
62+
add_subdirectory(tests/beman/inplace_vector)
63+
endif()
64+
65+
if(BEMAN_EXEMPLAR_BUILD_EXAMPLES)
66+
add_subdirectory(examples)
67+
endif()

0 commit comments

Comments
 (0)