Skip to content

Commit af4a313

Browse files
committed
Merge branch 'main' into 469-zenodo
2 parents b144b4b + 33f92a3 commit af4a313

10 files changed

Lines changed: 47 additions & 11 deletions

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### Added
66
* Make zenodo next step instructions optional [#520](https://github.com/NLeSC/python-template/pull/520)
7+
* Make SonarCloud optional [#515](https://github.com/NLeSC/python-template/pull/515)
78
* Make citation optional [#471](https://github.com/NLeSC/python-template/pull/471)
89
* Make online documentation optional [#476](https://github.com/NLeSC/python-template/pull/476)
910
* Added Python 3.12 support [#356](https://github.com/NLeSC/python-template/issues/356)

copier.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ version:
2323
github_organization:
2424
type: str
2525
default: "<my-github-organization>"
26+
help: Enter the name of your GitHub username or organization
2627
full_name:
2728
type: str
2829
default: Jane Smith
@@ -113,6 +114,12 @@ AddZenodo:
113114
default: "{{ template_profile != 'minimum' }}"
114115
help: Create a GitHub issue on how to enable Zenodo integration?
115116

117+
AddSonarCloud:
118+
when: "{{ template_profile == 'ask' }}"
119+
type: bool
120+
default: "{{ template_profile != 'minimum' }}"
121+
help: Add SonarCloud (code analysis service) integration?
122+
116123
# internal fields
117124
_subdirectory: template
118125

profiles.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
- project_setup.md
2323

2424
- code quality:
25-
- sonarcloud
25+
- sonarcloud #515
2626
- ruff and lint workflow
2727
- github action to build (exist) #451
2828
- pre-commit

template/.github/workflows/next_steps.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,6 @@ jobs:
88
runs-on: ubuntu-latest
99
steps:
1010
- uses: actions/checkout@v4
11-
- name: Create Sonarcloud integration issue
12-
uses: JasonEtco/create-an-issue@v2
13-
env:
14-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
15-
with:
16-
filename: .github/next_steps/01_sonarcloud_integration.md
17-
id: sonarcloud
1811
- name: Create linting issue
1912
uses: JasonEtco/create-an-issue@v2
2013
env:
@@ -25,7 +18,6 @@ jobs:
2518
- name: List created issues
2619
run: |
2720
echo 'Created issues that must be completed to have fully working Python package:
28-
* Sonarcloud integration ${{ steps.sonarcloud.outputs.url }}
2921
* Linting fixes ${{ steps.linting.outputs.url }}'
3022
- name: Cleanup files needed to create next steps issues
3123
run: |
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
on: [push]
2+
permissions:
3+
contents: write
4+
issues: write
5+
name: Create an issue for Sonarcloud
6+
jobs:
7+
next_steps:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
- name: Create Sonarcloud issue
12+
uses: JasonEtco/create-an-issue@v2
13+
env:
14+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
15+
with:
16+
filename: .github/workflows/next_steps_sonarcloud_issue.md
17+
id: sonarcloud
18+
- name: List created issues
19+
run: |
20+
echo 'Created issues that must be completed to have fully working Python package:
21+
* Sonarcloud integration ${{ steps.sonarcloud.outputs.url }}'
22+
- name: Cleanup files needed to create next steps issues
23+
run: |
24+
git config --global user.name 'NLeSC Python template'
25+
git config --global user.email 'nlesc-python-template@users.noreply.github.com'
26+
git pull # other next step workflows may push changes before
27+
git rm .github/workflows/next_steps_sonarcloud.yml
28+
git rm .github/workflows/next_steps_sonarcloud_issue.md
29+
git commit -am "Cleanup automated next steps issue generator for sonarcloud"
30+
git push

template/.github/next_steps/01_sonarcloud_integration.md.jinja renamed to template/.github/workflows/{% if AddSonarCloud %}next_steps_sonarcloud_issue.md{% endif %}.jinja

File renamed without changes.

template/.github/workflows/sonarcloud.yml renamed to template/.github/workflows/{% if AddSonarCloud %}sonarcloud.yml{% endif %}

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,5 @@ jobs:
3636
- name: SonarCloud Scan
3737
uses: SonarSource/sonarcloud-github-action@master
3838
env:
39-
GITHUB_TOKEN: ${{ '{{' -}} secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
40-
SONAR_TOKEN: ${{ '{{' -}} secrets.SONAR_TOKEN }}
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
40+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

template/README.md.jinja

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
| (5/5) checklist | [![workflow cii badge](https://bestpractices.coreinfrastructure.org/projects/<replace-with-created-project-identifier>/badge)](https://bestpractices.coreinfrastructure.org/projects/<replace-with-created-project-identifier>) |
1212
| howfairis | [![fair-software badge](https://img.shields.io/badge/fair--software.eu-%E2%97%8F%20%20%E2%97%8F%20%20%E2%97%8F%20%20%E2%97%8F%20%20%E2%97%8B-yellow)](https://fair-software.eu) |
1313
| **Other best practices** | &nbsp; |
14+
{% if AddSonarCloud -%}
1415
| Static analysis | [![workflow scq badge](https://sonarcloud.io/api/project_badges/measure?project={{github_organization}}_{{package_name}}&metric=alert_status)](https://sonarcloud.io/dashboard?id={{github_organization}}_{{package_name}}) |
1516
| Coverage | [![workflow scc badge](https://sonarcloud.io/api/project_badges/measure?project={{github_organization}}_{{package_name}}&metric=coverage)](https://sonarcloud.io/dashboard?id={{github_organization}}_{{package_name}}) |
17+
{%- endif -%}
1618
{% if AddOnlineDocumentation -%}
1719
| Documentation | [![Documentation Status](https://readthedocs.org/projects/{{package_name}}/badge/?version=latest)](https://{{package_name}}.readthedocs.io/en/latest/?badge=latest) |
1820
{%- endif -%}
@@ -21,7 +23,9 @@
2123
{% if AddCitation -%}
2224
| Citation data consistency | [![cffconvert]({{repository_url}}/actions/workflows/cffconvert.yml/badge.svg)]({{repository_url}}/actions/workflows/cffconvert.yml) |
2325
{%- endif -%}
26+
{% if AddSonarCloud -%}
2427
| SonarCloud | [![sonarcloud]({{repository_url}}/actions/workflows/sonarcloud.yml/badge.svg)]({{repository_url}}/actions/workflows/sonarcloud.yml) |
28+
{%- endif -%}
2529
| MarkDown link checker | [![markdown-link-check]({{repository_url}}/actions/workflows/markdown-link-check.yml/badge.svg)]({{repository_url}}/actions/workflows/markdown-link-check.yml) |
2630

2731
## How to use {{ package_name }}

template/project_setup.md.jinja

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,14 @@ help you decide which tool to use for packaging.
6666

6767
- [Relevant section in the NLeSC guide](https://guide.esciencecenter.nl/#/best_practices/language_guides/python?id=coding-style-conventions) and [README.dev.md](README.dev.md).
6868

69+
{% if AddSonarCloud -%}
6970
## Continuous code quality
7071

7172
[Sonarcloud](https://sonarcloud.io/) is used to perform quality analysis and code coverage report
7273

7374
- `sonar-project.properties` is the SonarCloud [configuration](https://docs.sonarqube.org/latest/analysis/analysis-parameters/) file
7475
- `.github/workflows/sonarcloud.yml` is the GitHub action workflow which performs the SonarCloud analysis
76+
{%- endif -%}
7577

7678
## Package version number
7779

template/sonar-project.properties.jinja renamed to template/{% if AddSonarCloud %}sonar-project.properties{% endif %}.jinja

File renamed without changes.

0 commit comments

Comments
 (0)