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
17 changes: 17 additions & 0 deletions .github/cpp-project-template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
default_context:
project_name: "Your Project"
remote_url: "None"
project_slug: "your-project"
full_name: "Your Name"
license: "MIT"
use_submodules: "No"
header_only: "No"
external_dependency: "None"
github_actions_ci: "Yes"
gitlab_ci: "No"
readthedocs: "Yes"
doxygen: "Yes"
cxx_minimum_standard: "20"
python_bindings: "No"
pypi_release: "No"
codecovio: "Yes"
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
workflow_dispatch:
# Additionally, we run Monday morning 6AM, so that we can react quickly if things break
schedule:
- cron: "0 5 * * 1"
- cron: "0 5 * * 1"

jobs:
test:
Expand All @@ -37,7 +37,7 @@ jobs:
run: |
python -m pip install -r requirements-dev.txt

- uses: ssciwr/doxygen-install@v1
- uses: ssciwr/doxygen-install@v2

- name: Set up git identity
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

steps:
- name: Checking out the cookie cutter repository
uses: actions/checkout@v5
uses: actions/checkout@v6

- uses: actions/setup-python@v6
with:
Expand Down
55 changes: 55 additions & 0 deletions .github/workflows/sync-template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Sync template repository

on:
push:
branches:
- main
workflow_dispatch:

jobs:
sync:
runs-on: ubuntu-latest

steps:
- name: Checkout the cookiecutter repository
uses: actions/checkout@v6
with:
path: cookiecutter-repository

- name: Install cookiecutter
run: pip install cookiecutter

- name: Set up git identity
run: |
git config --global user.email "ssc@sync-template.com"
git config --global user.name "SSC Template Sync"

- name: Bake template using config
run: |
cookiecutter \
--no-input \
--config-file cookiecutter-repository/.github/cpp-project-template.yml \
cookiecutter-repository/

- name: Checkout target repository
uses: actions/checkout@v6
with:
repository: ssciwr/cpp-project-template
ref: main
path: target-repository
ssh-key: ${{ secrets.SSCIWR_CPP_PROJECT_TEMPLATE_DEPLOY_KEY }}

- name: Sync generated files
run: |
rsync -av --delete \
--exclude '.git/' \
your-project/ target-repository/

- name: Commit and push
working-directory: target-repository
run: |
git add .
git commit -m "Sync from ssciwr/cookiecutter-cpp-project" || echo "No changes"

echo "Pushing changes to target repository..."
git push origin main
20 changes: 10 additions & 10 deletions {{cookiecutter.project_slug}}/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@ jobs:
os: [ubuntu-latest, macos-latest, windows-latest]

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
{% if cookiecutter.use_submodules == "Yes" %}
with:
submodules: 'recursive'
{%- endif %}
{% if cookiecutter.doxygen == "Yes" %}
- name: Install Doxygen
uses: ssciwr/doxygen-install@v1
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_DOCS=OFF -D{{ cookiecutter.project_slug }}_BUILD_PYTHON=OFF
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

- name: Build
shell: bash
Expand All @@ -56,19 +56,19 @@ jobs:
os: [ubuntu-latest, macos-latest, windows-latest]

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
{% if cookiecutter.use_submodules == "Yes" %}
with:
submodules: 'recursive'
{%- endif %}

- name: Set up Python
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: "3.14"
{% if cookiecutter.doxygen == "Yes" %}
- name: Install Doxygen
uses: ssciwr/doxygen-install@v1
uses: ssciwr/doxygen-install@v2
{% endif %}
- name: Run Python tests
shell: bash
Expand All @@ -84,7 +84,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
{% if cookiecutter.use_submodules == "Yes" %}
with:
submodules: 'recursive'
Expand All @@ -95,7 +95,7 @@ jobs:
sudo apt-get install -y lcov
{% if cookiecutter.doxygen == "Yes" %}
- name: Install Doxygen
uses: ssciwr/doxygen-install@v1
uses: ssciwr/doxygen-install@v2
{% endif %}
{% if cookiecutter.python_bindings == "Yes" %}
- name: Install Python package editable
Expand All @@ -115,7 +115,7 @@ jobs:
shell: bash
working-directory: ${{ "{{ github.workspace }}" }}/build
run: |
cmake $GITHUB_WORKSPACE -DCMAKE_CXX_FLAGS="--coverage" -D{{ cookiecutter.project_slug }}_BUILD_DOCS=OFF
cmake $GITHUB_WORKSPACE -DCMAKE_CXX_FLAGS="--coverage" -D{{ cookiecutter.project_slug }}_BUILD_TESTING=ON -D{{ cookiecutter.project_slug }}_BUILD_DOCS=OFF

- name: Build
shell: bash
Expand All @@ -139,4 +139,4 @@ jobs:
with:
fail_ci_if_error: true
files: ${{ "{{github.workspace}}" }}/coverage.info{% if cookiecutter.python_bindings == "Yes" %},coverage.xml{% endif %}
{% endif %}
{% endif %}
8 changes: 4 additions & 4 deletions {{cookiecutter.project_slug}}/.github/workflows/pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
submodules: 'recursive'

- name: Build wheels
uses: pypa/cibuildwheel@v{{ cookiecutter._cibuildwheel_version }}

- uses: actions/upload-artifact@v4
- uses: actions/upload-artifact@v5
with:
path: ./wheelhouse/*.whl

Expand All @@ -34,7 +34,7 @@ jobs:
id-token: write
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v4
- uses: actions/download-artifact@v6
with:
name: artifact
path: dist
Expand All @@ -50,7 +50,7 @@ jobs:
id-token: write
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v4
- uses: actions/download-artifact@v6
with:
name: artifact
path: dist
Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.project_slug}}/LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -851,4 +851,4 @@ whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
{%- endif -%}
{%- endif -%}
5 changes: 5 additions & 0 deletions {{cookiecutter.project_slug}}/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,8 @@ The web documentation can then be browsed by opening `build/doc/html/index.html`
{% else %}
{{ cookiecutter.project_name }} *should* provide a documentation.
{% endif -%}


## Acknowledgments

This repository was set up using the [SSC Cookiecutter for C++ Packages](https://github.com/ssciwr/cookiecutter-cpp-project).
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#include "{{ cookiecutter.project_slug }}/{{ cookiecutter.project_slug }}.hpp"
#include <iostream>

int main(){
int main()
{
int result = {{ cookiecutter.project_slug.replace("-", "") }}::add_one(1);
std::cout << "1 + 1 = " << result << std::endl;
}
}
2 changes: 1 addition & 1 deletion {{cookiecutter.project_slug}}/doc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ add_custom_target({{ cookiecutter.project_slug }}-sphinx-doc
)
add_dependencies({{ cookiecutter.project_slug }}-sphinx-doc {{ cookiecutter.project_slug }}-doxygen)
{%- endif %}
{%- endif -%}
{%- endif -%}
5 changes: 2 additions & 3 deletions {{cookiecutter.project_slug}}/doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'
html_theme = "sphinx_rtd_theme"

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
Expand All @@ -60,7 +59,7 @@
breathe_default_project = "{{ cookiecutter.project_slug }}"

# Check if we're running on Read the Docs' servers
read_the_docs_build = os.environ.get('READTHEDOCS', None) == 'True'
read_the_docs_build = os.environ.get('READTHEDOCS', None) == "True"

# Implement build logic on RTD servers
if read_the_docs_build:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ namespace {{ cookiecutter.project_slug.replace("-", "") }} {
* @returns the successor of x
*/
{%- endif %}
{% if cookiecutter.header_only == "Yes" %}inline {% endif %}int add_one(int x){% if cookiecutter.header_only == "No" %};{%- else %}{
{% if cookiecutter.header_only == "Yes" %}inline {% endif %}int
add_one(int x){% if cookiecutter.header_only == "No" %};{%- else %}
{
return x + 1;
}
{%- endif %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# Export the version given in project metadata
from importlib import metadata

__version__ = metadata.version(__package__)
del metadata

Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.project_slug}}/requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pytest
{% if cookiecutter.codecovio == "Yes" %}
pytest-cov
{% endif %}
{% endif %}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

namespace {{ cookiecutter.project_slug.replace("-", "") }} {

int add_one(int x){
int add_one(int x)
{
return x + 1;
}

} // namespace {{ cookiecutter.project_slug.replace("-", "") }}
} // namespace {{ cookiecutter.project_slug.replace("-", "") }}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ TEST_CASE( "add_one", "[adder]" ){
REQUIRE(add_one(0) == 1);
REQUIRE(add_one(123) == 124);
REQUIRE(add_one(-1) == 0);
}
}