Skip to content

Commit

Permalink
Merge pull request #120 from ssciwr/remove-sonarcloud
Browse files Browse the repository at this point in the history
Remove sonarcloud integration
  • Loading branch information
dokempf authored Jan 8, 2025
2 parents e5583af + 7dcc4fc commit 98353cd
Show file tree
Hide file tree
Showing 11 changed files with 1 addition and 172 deletions.
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ The core features of our C++ Cookiecutter in a nutshell:
* CI-based deployment of Python wheels to PyPI
* Generated [pre-commit](https://pre-commit.com/) configuration is added if you have `pre-commit` installed
* Integration with coverage testing from [codecov.io](https://codecov.io)
* Integration with code quality analysis from [sonarcloud.io](https://sonarcloud.io/)
* Based on an established tool: [Cookiecutter](https://github.com/cookiecutter/cookiecutter) has >15k stars on Github!

# Prerequisites
Expand Down Expand Up @@ -84,11 +83,6 @@ This cookiecutter accepts the following configuration options:
generated in the Github UI.
* `codecovio`: Whether an automatic integration with coverage checking from [codecov.io](https://codecov.io)
should be set up. This requires an Open Source license in order to be free to use.
* `sonarcloud`: Whether an automatic integration with code quality analysis from [sonarcloud.io](https://sonarcloud.io/)
should be set up. Sonarcloud requires an Open Source license in order to be free to use.
This feature requires a bit of setup, but will give you access to a very powerful code
analysis tool. Currently, we only support SonarCloud analysis in combination with Github
Actions CI and a Github remote repository.

If you are using `cookiecutter-cpp-project` a lot, you can customize your default values
by providing a `.cookiecutterrc` file in your home directory, for more details see the
Expand Down
4 changes: 1 addition & 3 deletions cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"python_bindings": ["No", "Yes"],
"pypi_release": "{{ cookiecutter.python_bindings }}",
"codecovio": ["Yes", "No"],
"sonarcloud": ["No", "Yes"],
"_extensions": [
"local_extensions.PrecommitExtension",
"local_extensions.ShortcutExtension",
Expand All @@ -24,6 +23,5 @@
"__python_module": "{{ cookiecutter|modname }}",
"_catch_version": "2.13.10",
"_cibuildwheel_version": "2.13.1",
"_pybind_version": "2.10.4",
"_sonarscanner_version": "4.7.0.2747"
"_pybind_version": "2.10.4"
}
2 changes: 0 additions & 2 deletions hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ def conditional_remove(condition, path):
conditional_remove("{{ cookiecutter.python_bindings }}" == "No", "tests/python")
conditional_remove("{{ cookiecutter.pypi_release }}" != "Yes", ".github/workflows/pypi.yml")
conditional_remove("{{ cookiecutter.codecovio }}" == "No", "codecov.yml")
conditional_remove("{{ cookiecutter.sonarcloud }}" == "No", "sonar-project.properties")
conditional_remove("{{ cookiecutter.sonarcloud }}" == "No", ".github/workflows/sonarcloud.yml")
conditional_remove("{{ cookiecutter.github_actions_ci }}" == "No", ".github")
conditional_remove("{{ cookiecutter.external_dependency }}" == "None", "{{ cookiecutter.project_slug }}Config.cmake.in")
conditional_remove(not {{ have_precommit }}, ".pre-commit-config.yaml")
Expand Down
15 changes: 0 additions & 15 deletions hooks/pre_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,3 @@ def fail_if(condition, message):
"{{ cookiecutter.codecovio }}" == "Yes" and "{{ cookiecutter.license }}" == "None",
"Coverage reports for codecov.io require an open source license for your project"
)

fail_if(
"{{ cookiecutter.sonarcloud }}" == "Yes" and "{{ cookiecutter.license }}" == "None",
"Code quality analysis from sonarcloud.io requires an open source license for your project"
)

fail_if(
"{{ cookiecutter.sonarcloud }}" == "Yes" and "{{ cookiecutter.github_actions_ci }}" == "No",
"Code quality analysis from sonarcloud.io is currently only supported in combination with Github Actions CI"
)

fail_if(
"{{ cookiecutter.sonarcloud }}" == "Yes" and "github.com" not in "{{ cookiecutter.remote_url }}",
"Code quality analysis from sonarcloud.io is currently only supported in combination with a Github remote repository"
)
22 changes: 0 additions & 22 deletions tests/test_bake_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ def test_ctest_run(cookies, submodules, header_only):
'project_slug': 'test_project',
'use_submodules': submodules,
'header_only': header_only,
'sonarcloud': 'No',
}
)
check_bake(bake)
Expand All @@ -67,14 +66,12 @@ def test_cmake_installation(cookies, header_only):
extra_context={
'project_slug': 'downstream',
'header_only': 'No',
'sonarcloud': 'No',
}
)
upstream_bake = cookies.bake(
extra_context={
'project_slug': 'upstream',
'header_only': header_only,
'sonarcloud': 'No',
}
)
with inside_bake(upstream_bake):
Expand Down Expand Up @@ -122,7 +119,6 @@ def test_readthedocs(cookies):
bake = cookies.bake(
extra_context={
'readthedocs': 'Yes',
'sonarcloud': 'No',
}
)
check_bake(bake)
Expand All @@ -136,7 +132,6 @@ def test_doxygen(cookies):
bake = cookies.bake(
extra_context={
'doxygen': 'Yes',
'sonarcloud': 'No',
}
)
check_bake(bake)
Expand All @@ -153,22 +148,19 @@ def test_github_actions_ci(cookies):
'github_actions_ci': 'Yes',
'python_bindings': 'Yes',
'pypi_release': 'Yes',
'sonarcloud': 'Yes',
}
)
check_bake(bake)
with inside_bake(bake):
check_file_against_schemastore(".github/workflows/ci.yml", "https://json.schemastore.org/github-workflow")
check_file_against_schemastore(".github/workflows/pypi.yml", "https://json.schemastore.org/github-workflow")
check_file_against_schemastore(".github/workflows/sonarcloud.yml", "https://json.schemastore.org/github-workflow")


@pytest.mark.local
def test_gitlabci(cookies):
bake = cookies.bake(
extra_context={
'gitlab_ci': 'Yes',
'sonarcloud': 'No',
}
)
check_bake(bake)
Expand All @@ -184,7 +176,6 @@ def test_python(cookies, virtualenv, submodules):
'project_slug': 'my-project',
'python_bindings': 'Yes',
'submodules': submodules,
'sonarcloud': 'No',
}
)
check_bake(bake)
Expand Down Expand Up @@ -214,18 +205,6 @@ def test_codecov_without_license(cookies):
assert bake.exit_code != 0


@pytest.mark.local
def test_sonarcloud_without_license(cookies):
bake = cookies.bake(extra_context={'license': 'None', 'sonarcloud': 'Yes'})
assert bake.exit_code != 0


@pytest.mark.local
def test_sonarcloud_without_github(cookies):
bake = cookies.bake(extra_context={'github_actions_ci': 'No', 'sonarcloud': 'Yes'})
assert bake.exit_code != 0


@pytest.mark.local
@pytest.mark.parametrize(
"remote_url",
Expand All @@ -243,7 +222,6 @@ def test_remote_urls(cookies, remote_url):
"github_actions_ci": "Yes",
"gitlab_ci": "Yes",
"remote_url": remote_url,
"sonarcloud": "No",
}
)
check_bake(bake)
2 changes: 0 additions & 2 deletions tests/test_deploy_bake.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ def test_push_remote(cookies):
'pypi_release': 'Yes',
'use_submodules': 'No',
'codecovio': 'Yes',
'sonarcloud': 'Yes',
}
)
with inside_bake(bake):
Expand Down Expand Up @@ -59,7 +58,6 @@ def check_workflow(name):
assert workflow.conclusion == 'success'

check_workflow("ci.yml")
check_workflow("sonarcloud.yml")


@pytest.mark.integrations
Expand Down
84 changes: 0 additions & 84 deletions {{cookiecutter.project_slug}}/.github/workflows/sonarcloud.yml

This file was deleted.

8 changes: 0 additions & 8 deletions {{cookiecutter.project_slug}}/FILESTRUCTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,6 @@ generated for you:
provided file is the default configuration plus suitable exclusions. For more options, check
their [configuration reference](https://docs.codecov.io/docs/codecov-yaml).
{%- endif %}
{%- if cookiecutter.sonarcloud == "Yes" %}
* `sonar-project.properties` configures the code analysis on SonarCloud. The provided
default parameters should be sufficient for most users. If they are not for you,
you should have a look at the [Analysis Parameters Reference](https://docs.sonarqube.org/latest/analysis/analysis-parameters/)
and at the [Documentation for C/C++/Objective-C](https://docs.sonarqube.org/latest/analysis/languages/cfamily/).
* `.github/workflows/sonarcloud.yml` is the Github workflow that triggers the SonarCloud
analysis. The provided default should be sufficient for most users.
{%- endif %}
* Markdown files with meta information on the project. [Markdown](https://www.markdownguide.org/basic-syntax/) is
a good language for these files, as it is easy to write and rendered into something beautiful by your git repository
hosting provider.
Expand Down
3 changes: 0 additions & 3 deletions {{cookiecutter.project_slug}}/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@
{% if cookiecutter.codecovio == "Yes" -%}
[![codecov](https://codecov.io/{{ cookiecutter|provider_acronym }}/{{ cookiecutter|username }}/{{ cookiecutter|remote_slug }}/branch/main/graph/badge.svg)](https://codecov.io/{{ cookiecutter|provider_acronym }}/{{ cookiecutter|username }}/{{ cookiecutter|remote_slug }})
{%- endif %}
{% if cookiecutter.sonarcloud == "Yes" -%}
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project={{ cookiecutter|username }}_{{ cookiecutter|remote_slug }}&metric=alert_status)](https://sonarcloud.io/dashboard?id={{ cookiecutter|username }}_{{ cookiecutter|remote_slug }})
{%- endif %}
{{ "\n" -}}
# Prerequisites

Expand Down
8 changes: 0 additions & 8 deletions {{cookiecutter.project_slug}}/TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,3 @@ The following tasks need to be done to get a fully working project:
to the Settings Tab. Within setting, get your token for this repository and put store it as a secret
called `CODECOV_TOKEN` for GitHub Actions.
{%- endif %}
{%- if cookiecutter.sonarcloud == "Yes" %}
* Enable the integration with `sonarcloud.io` by heading to the [Sonarcloud.io Website](https://sonarcloud.io),
log in (e.g. with your Github credentials), add the repository and select *Github Actions* as the
preferred method of integration. Follow step 1 and set up the secret variable `SONAR_TOKEN`. Step 2
and 3 are already taken care of by this cookiecutter. In order to have the SonarCloud badge in the
README show something meaningful, a *New Code Definition* needs to be configured in Sonarcloud under
*Administration/New Code*.
{%- endif %}
19 changes: 0 additions & 19 deletions {{cookiecutter.project_slug}}/sonar-project.properties

This file was deleted.

0 comments on commit 98353cd

Please sign in to comment.