Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions cookiecutter.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{
"_jinja2_env_vars": {
"trim_blocks": true,
"lstrip_blocks": true
},
"project_name": "My C++ Project",
"remote_url": "None",
"project_slug": "{%- if cookiecutter.remote_url == 'None' -%}{{ cookiecutter.project_name|replace('+', 'p')|slugify }}{% else %}{{ cookiecutter.remote_url.split('/')[-1]|replace('.git', '')}}{%- endif -%}",
Expand All @@ -21,6 +25,6 @@
"local_extensions.CurrentDateExtension"
],
"__python_module": "{{ cookiecutter|modname }}",
"_catch_version": "3.15.1",
"_cibuildwheel_version": "4.1.0"
"_catch_version": "3.15.3",
"_cibuildwheel_version": "4.2.0"
}
49 changes: 24 additions & 25 deletions {{cookiecutter.project_slug}}/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,26 @@ jobs:
{% if cookiecutter.use_submodules == "Yes" %}
with:
submodules: 'recursive'
{%- endif %}
{% endif %}
{% if cookiecutter.doxygen == "Yes" %}

- name: Install Doxygen
uses: ssciwr/doxygen-install@v2
{% endif %}
- name: Make build directory
run: cmake -E make_directory ${{ "{{ github.workspace }}" }}/build

- name: Configure cmake
shell: bash
working-directory: ${{ "{{ github.workspace }}" }}/build
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=Debug -D{{ cookiecutter.project_slug }}_BUILD_TESTING=ON -D{{ cookiecutter.project_slug }}_BUILD_DOCS=OFF -D{{ cookiecutter.project_slug }}_BUILD_PYTHON=OFF
run: cmake --preset test

- name: Build
shell: bash
working-directory: ${{ "{{ github.workspace }}" }}/build
run: cmake --build .
run: cmake --build --preset test

- name: Run tests
shell: bash
working-directory: ${{ "{{ github.workspace }}" }}/build
run: ctest
{%- if cookiecutter.python_bindings != "None" %}
run: ctest --preset test
{% if cookiecutter.python_bindings != "None" %}

python-testing:
name: Python package testing on ${{ "{{matrix.os}}" }}
runs-on: ${{ "{{matrix.os}}" }}
Expand All @@ -60,25 +57,27 @@ jobs:
{% if cookiecutter.use_submodules == "Yes" %}
with:
submodules: 'recursive'
{%- endif %}
{% endif %}

- name: Set up Python
uses: actions/setup-python@v6
uses: actions/setup-python@v7
with:
python-version: "3.14"
{% if cookiecutter.doxygen == "Yes" %}

- name: Install Doxygen
uses: ssciwr/doxygen-install@v2
{% endif %}

- name: Run Python tests
shell: bash
run: |
python -m pip install .
python -m pip install -r requirements-dev.txt
pytest
{%- endif %}

{% endif %}
{% if cookiecutter.codecovio == "Yes" %}

coverage-test:
name: Coverage Testing
runs-on: ubuntu-latest
Expand All @@ -88,45 +87,44 @@ jobs:
{% if cookiecutter.use_submodules == "Yes" %}
with:
submodules: 'recursive'
{%- endif %}
{% endif %}

- name: Install LCov
run: |
sudo apt-get install -y lcov
{% if cookiecutter.doxygen == "Yes" %}

- name: Install Doxygen
uses: ssciwr/doxygen-install@v2
{% endif %}
{% if cookiecutter.python_bindings != "None" %}

- name: Install Python package editable
run: |
python -m pip install scikit_build_core {% if cookiecutter.python_bindings == "pybind11" -%}pybind11[global]{%- elif cookiecutter.python_bindings == "nanobind" %}nanobind[global]{% endif %}
python -m pip install scikit_build_core {{ "pybind11[global]" if cookiecutter.python_bindings == "pybind11" else "nanobind[global]" }}
python -m pip install --no-build-isolation --config-settings=build-dir="${{ "{{ github.workspace }}" }}/build" --config-settings=cmake.define.CMAKE_CXX_FLAGS="--coverage" --config-settings=cmake.define.BUILD_TESTING="ON" -v -e .
python -m pip install -r requirements-dev.txt

- name: Run Python tests
run: |
python -m pytest --cov --cov-report=xml
{% else %}
- name: Create cmake build directory
run: cmake -E make_directory ${{ "{{ github.workspace }}" }}/build

- name: Configure cmake
shell: bash
working-directory: ${{ "{{ github.workspace }}" }}/build
run: |
cmake $GITHUB_WORKSPACE -DCMAKE_CXX_FLAGS="--coverage" -D{{ cookiecutter.project_slug }}_BUILD_TESTING=ON -D{{ cookiecutter.project_slug }}_BUILD_DOCS=OFF
cmake --preset test \
-DCMAKE_CXX_FLAGS="--coverage -fprofile-update=atomic -O0 -g" \
-DCMAKE_EXE_LINKER_FLAGS="--coverage"

- name: Build
shell: bash
working-directory: ${{ "{{ github.workspace }}" }}/build
run: cmake --build .
run: cmake --build --preset test
{% endif %}

- name: Run tests
shell: bash
working-directory: ${{ "{{ github.workspace }}" }}/build
run: ctest
run: ctest --preset test

- name: Collect coverage report
shell: bash
Expand All @@ -140,3 +138,4 @@ jobs:
fail_ci_if_error: true
files: ${{ "{{github.workspace}}" }}/coverage.info{% if cookiecutter.python_bindings != "None" %},coverage.xml{% endif %}
{% endif %}

7 changes: 6 additions & 1 deletion {{cookiecutter.project_slug}}/.github/workflows/pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ on:
jobs:
build-wheels:
name: Build wheels on {% raw %}${{ matrix.os }}{% endraw %}

runs-on: {% raw %}${{ matrix.os }}{% endraw %}

strategy:
Expand All @@ -31,12 +32,13 @@ jobs:
submodules: 'recursive'

- name: Set up Python 3.14
uses: actions/setup-python@v6
uses: actions/setup-python@v7
with:
python-version: "3.14"

- name: Verify release tag matches package version
if: {% raw %}${{ github.event_name == 'push' }}{% endraw %}

shell: python
run: |
import os
Expand All @@ -62,6 +64,7 @@ jobs:
- uses: actions/upload-artifact@v7
with:
name: wheels-{% raw %}${{ matrix.os }}{% endraw %}

path: ./wheelhouse/*.whl
if-no-files-found: error

Expand All @@ -86,6 +89,7 @@ jobs:
upload-testpypi:
name: Publish on TestPyPI
if: {% raw %}${{ github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.publish_target == 'testpypi') }}{% endraw %}

needs: [build-wheels, build-sdist]
runs-on: ubuntu-latest
permissions:
Expand Down Expand Up @@ -114,6 +118,7 @@ jobs:
upload-pypi:
name: Publish on PyPI
if: {% raw %}${{ github.event_name == 'push' }}{% endraw %}

needs: [build-wheels, build-sdist, upload-testpypi]
runs-on: ubuntu-latest
permissions:
Expand Down
46 changes: 25 additions & 21 deletions {{cookiecutter.project_slug}}/.gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,37 @@
variables:
{%- if cookiecutter.use_submodules == "Yes" %}
{% if cookiecutter.use_submodules == "Yes" %}
GIT_SUBMODULE_STRATEGY: recursive
{%- endif %}
{% endif %}

.base:
image: ubuntu:24.04

.template: &template
before_script:
- echo "Installing required dependencies..."
- apt update
- apt install -y cmake git
- echo "Installing potential dependencies..."
- apt-get update
- apt-get install -y cmake git $COMPILER_PACKAGES
{% if cookiecutter.python_bindings != "None" %}
- apt install -y python3-dev
{%- endif %}
- apt-get install -y python3-dev
{% endif %}
{% if cookiecutter.doxygen == "Yes" %}
- apt install -y doxygen
- apt-get install -y doxygen
{% endif %}
- cmake --version
- $CXX --version
script:
- cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -D{{ cookiecutter.project_slug }}_BUILD_DOCS=OFF -D{{ cookiecutter.project_slug }}_BUILD_PYTHON=OFF
- cmake --build build
- ctest --test-dir build

# Note: You can use your own Docker images here that e.g. include relevant
# dependencies and development tools. We choose well-maintained images
# providing up-to-date compiler toolchains.
- cmake --preset test
- cmake --build --preset test
- ctest --preset test

build-and-test:gcc:
image: gcc:14
<<: *template
extends: .base
variables:
COMPILER_PACKAGES: "gcc-14 g++-14"
CC: gcc-14
CXX: g++-14

build-and-test:clang:
image: silkeh/clang:18
<<: *template
extends: .base
variables:
COMPILER_PACKAGES: "clang-18"
CC: clang-18
CXX: clang++-18
39 changes: 23 additions & 16 deletions {{cookiecutter.project_slug}}/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
repos:
{%- if cookiecutter.python_bindings != "None" %}
# Run Black - the uncompromising Python code formatter
- repo: https://github.com/psf/black
rev: 26.5.1
# Run Ruff - an extremely fast Python linter and code formatter
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.16.3
hooks:
- id: black-jupyter
# Run the linter
- id: ruff-check
types_or: [ python, pyi, jupyter, pyproject ]
args: [ --fix, --show-fixes ]
# Run the formatter
- id: ruff-format
{% endif %}

# Format C++ code with Clang-Format - automatically applying the changes
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v22.1.5
rev: v22.1.8
hooks:
- id: clang-format
args:
Expand All @@ -19,24 +25,25 @@ repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
# Make sure that contained YAML files are well-formed
- id: check-yaml
# Trim trailing whitespace of all sorts
- id: trailing-whitespace
# Unify file endings
- id: end-of-file-fixer
{% if cookiecutter.python_bindings != "None" %}
# Apply a file size limit of 500kB
- id: check-added-large-files
{%- if cookiecutter.python_bindings != "None" %}
# Check json files for syntax errors
- id: check-json
# Simple parser validation of e.g. pyproject.toml
- id: check-toml
{%- endif %}
# Unify file endings
- id: end-of-file-fixer

{%- if cookiecutter.github_actions_ci == "Yes" %}
{% endif %}
# Make sure that contained YAML files are well-formed
- id: check-yaml
# Trim trailing whitespace of all sorts
- id: trailing-whitespace
{% if cookiecutter.github_actions_ci == "Yes" %}

# GitHub Actions Workflow linter
- repo: https://github.com/rhysd/actionlint
rev: v1.7.12
hooks:
- id: actionlint
{%- endif %}
{% endif %}
34 changes: 23 additions & 11 deletions {{cookiecutter.project_slug}}/.readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,31 @@
version: 2

sphinx:
configuration: doc/conf.py

formats: all

submodules:
include: all
recursive: true

build:
os: ubuntu-24.04
os: ubuntu-26.04
tools:
python: "3.12"
python: "3.14"
apt_packages:
- cmake
- doxygen
jobs:
pre_build:
- cmake --preset documentation
- cmake --build --preset documentation
build:
html:
- sphinx-build -T -j auto -b html -d $READTHEDOCS_OUTPUT/doctrees -D language=en doc $READTHEDOCS_OUTPUT/html

python:
{% if cookiecutter.python_bindings == "pybind11" or cookiecutter.python_bindings == "nanobind" %}
install:
- method: uv
command: sync
path: python/{{ cookiecutter.__python_module }}
extras:
- docs
{% else %}
install:
- requirements: doc/requirements-rtd.txt
{% endif %}
sphinx:
configuration: doc/conf.py
8 changes: 4 additions & 4 deletions {{cookiecutter.project_slug}}/CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ identifiers:
- description: This is a collection of archived snapshots of this project.
type: doi
value: "10.5281/zenodo.123456"
{%- if cookiecutter.license != "None" %}
{% if cookiecutter.license != "None" %}
license: {{cookiecutter.license}}
{%- endif %}
{%- if cookiecutter.remote_url != 'None' %}
{% endif %}
{% if cookiecutter.remote_url != 'None' %}
repository-code: {{cookiecutter.remote_url}}
{%- endif %}
{% endif %}
Loading