diff --git a/.github/cpp-project-template.yml b/.github/cpp-project-template.yml new file mode 100644 index 0000000..81e9f4f --- /dev/null +++ b/.github/cpp-project-template.yml @@ -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" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 16b68ef..a6356c9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: @@ -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: | diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index ee7b72a..7896388 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -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: diff --git a/.github/workflows/sync-template.yml b/.github/workflows/sync-template.yml new file mode 100644 index 0000000..43ba873 --- /dev/null +++ b/.github/workflows/sync-template.yml @@ -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 diff --git a/{{cookiecutter.project_slug}}/.github/workflows/ci.yml b/{{cookiecutter.project_slug}}/.github/workflows/ci.yml index 8aca8b5..f700cdc 100644 --- a/{{cookiecutter.project_slug}}/.github/workflows/ci.yml +++ b/{{cookiecutter.project_slug}}/.github/workflows/ci.yml @@ -21,14 +21,14 @@ 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 @@ -36,7 +36,7 @@ jobs: - 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 @@ -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 @@ -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' @@ -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 @@ -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 @@ -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 %} \ No newline at end of file diff --git a/{{cookiecutter.project_slug}}/.github/workflows/pypi.yml b/{{cookiecutter.project_slug}}/.github/workflows/pypi.yml index 85a6a20..84b758d 100644 --- a/{{cookiecutter.project_slug}}/.github/workflows/pypi.yml +++ b/{{cookiecutter.project_slug}}/.github/workflows/pypi.yml @@ -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 @@ -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 @@ -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 diff --git a/{{cookiecutter.project_slug}}/LICENSE.md b/{{cookiecutter.project_slug}}/LICENSE.md index 458f209..7418dc0 100644 --- a/{{cookiecutter.project_slug}}/LICENSE.md +++ b/{{cookiecutter.project_slug}}/LICENSE.md @@ -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 -%} \ No newline at end of file diff --git a/{{cookiecutter.project_slug}}/README.md b/{{cookiecutter.project_slug}}/README.md index 0c36fd0..f43d510 100644 --- a/{{cookiecutter.project_slug}}/README.md +++ b/{{cookiecutter.project_slug}}/README.md @@ -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). diff --git a/{{cookiecutter.project_slug}}/app/{{cookiecutter.project_slug}}_app.cpp b/{{cookiecutter.project_slug}}/app/{{cookiecutter.project_slug}}_app.cpp index ec9f7c2..94ca074 100644 --- a/{{cookiecutter.project_slug}}/app/{{cookiecutter.project_slug}}_app.cpp +++ b/{{cookiecutter.project_slug}}/app/{{cookiecutter.project_slug}}_app.cpp @@ -1,7 +1,8 @@ #include "{{ cookiecutter.project_slug }}/{{ cookiecutter.project_slug }}.hpp" #include -int main(){ +int main() +{ int result = {{ cookiecutter.project_slug.replace("-", "") }}::add_one(1); std::cout << "1 + 1 = " << result << std::endl; -} \ No newline at end of file +} diff --git a/{{cookiecutter.project_slug}}/doc/CMakeLists.txt b/{{cookiecutter.project_slug}}/doc/CMakeLists.txt index a28041e..b484f8f 100644 --- a/{{cookiecutter.project_slug}}/doc/CMakeLists.txt +++ b/{{cookiecutter.project_slug}}/doc/CMakeLists.txt @@ -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 -%} \ No newline at end of file +{%- endif -%} diff --git a/{{cookiecutter.project_slug}}/doc/conf.py b/{{cookiecutter.project_slug}}/doc/conf.py index 3a71811..5096e5d 100644 --- a/{{cookiecutter.project_slug}}/doc/conf.py +++ b/{{cookiecutter.project_slug}}/doc/conf.py @@ -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, @@ -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: diff --git a/{{cookiecutter.project_slug}}/include/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}.hpp b/{{cookiecutter.project_slug}}/include/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}.hpp index f5ffb89..694d442 100644 --- a/{{cookiecutter.project_slug}}/include/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}.hpp +++ b/{{cookiecutter.project_slug}}/include/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}.hpp @@ -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 %} diff --git a/{{cookiecutter.project_slug}}/python/{{cookiecutter.__python_module}}/__init__.py b/{{cookiecutter.project_slug}}/python/{{cookiecutter.__python_module}}/__init__.py index 65bff69..91246f4 100644 --- a/{{cookiecutter.project_slug}}/python/{{cookiecutter.__python_module}}/__init__.py +++ b/{{cookiecutter.project_slug}}/python/{{cookiecutter.__python_module}}/__init__.py @@ -2,6 +2,7 @@ # Export the version given in project metadata from importlib import metadata + __version__ = metadata.version(__package__) del metadata diff --git a/{{cookiecutter.project_slug}}/requirements-dev.txt b/{{cookiecutter.project_slug}}/requirements-dev.txt index 97c2a37..38d55b1 100644 --- a/{{cookiecutter.project_slug}}/requirements-dev.txt +++ b/{{cookiecutter.project_slug}}/requirements-dev.txt @@ -1,4 +1,4 @@ pytest {% if cookiecutter.codecovio == "Yes" %} pytest-cov -{% endif %} +{% endif %} \ No newline at end of file diff --git a/{{cookiecutter.project_slug}}/src/{{cookiecutter.project_slug}}.cpp b/{{cookiecutter.project_slug}}/src/{{cookiecutter.project_slug}}.cpp index 1272cc8..b7c9256 100644 --- a/{{cookiecutter.project_slug}}/src/{{cookiecutter.project_slug}}.cpp +++ b/{{cookiecutter.project_slug}}/src/{{cookiecutter.project_slug}}.cpp @@ -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("-", "") }} \ No newline at end of file +} // namespace {{ cookiecutter.project_slug.replace("-", "") }} diff --git a/{{cookiecutter.project_slug}}/tests/{{cookiecutter.project_slug}}_t.cpp b/{{cookiecutter.project_slug}}/tests/{{cookiecutter.project_slug}}_t.cpp index b43ee62..06444c0 100644 --- a/{{cookiecutter.project_slug}}/tests/{{cookiecutter.project_slug}}_t.cpp +++ b/{{cookiecutter.project_slug}}/tests/{{cookiecutter.project_slug}}_t.cpp @@ -7,4 +7,4 @@ TEST_CASE( "add_one", "[adder]" ){ REQUIRE(add_one(0) == 1); REQUIRE(add_one(123) == 124); REQUIRE(add_one(-1) == 0); -} \ No newline at end of file +}