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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* Make SonarCloud optional [#515](https://github.com/NLeSC/python-template/pull/515)
* Make citation optional [#471](https://github.com/NLeSC/python-template/pull/471)
* Make online documentation optional [#476](https://github.com/NLeSC/python-template/pull/476)
* Make local test optional [#594](https://github.com/NLeSC/python-template/pull/594)

### Changed
* Update the user documentation (README.md) of the template [#575](https://github.com/NLeSC/python-template/pull/623)
Expand Down
9 changes: 8 additions & 1 deletion copier/questions/features_code_quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@ SelectCodeQualityFeatures:
type: yaml
default: |-
{% if template_profile == 'recommended' %}
[SelectGitHubActions_flag, AddLinting_flag, AddSonarCloud_flag, AddEditorConfig_flag]
[AddLocalTests_flag, SelectGitHubActions_flag, AddLinting_flag, AddSonarCloud_flag, AddEditorConfig_flag]
{%- else -%}
[]
{%- endif %}
help: Select code quality features
multiselect: true
choices:
Local tests:
value: AddLocalTests_flag
# validator: "{% if something != 'AnotherThing' %}BlaBla{% endif %}"
GitHub Actions (selection on the next menu):
value: SelectGitHubActions_flag
# validator: "{% if something != 'AnotherThing' %}BlaBla{% endif %}"
Expand Down Expand Up @@ -56,6 +59,10 @@ SelectGitHubActions:


# computed features
AddLocalTests:
type: bool
default: "{{ 'AddLocalTests_flag' in SelectCodeQualityFeatures or 'AddGitHubActionBuild_flag' in SelectGitHubActions or 'AddSonarCloud_flag' in SelectCodeQualityFeatures }}"
when: false
AddGitHubActionBuild:
type: bool
default: "{{ 'AddGitHubActionBuild_flag' in SelectGitHubActions }}"
Expand Down
2 changes: 2 additions & 0 deletions template/project_setup.md.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ You can distribute your code using PyPI.
[The guide](https://guide.esciencecenter.nl/#/best_practices/language_guides/python?id=building-and-packaging-code) can
help you decide which tool to use for packaging.

{% if AddLocalTests -%}
## Testing and code coverage

- Tests should be put in the `tests` folder.
Expand All @@ -47,6 +48,7 @@ help you decide which tool to use for packaging.
- The project uses [GitHub action workflows](https://docs.github.com/en/actions) to automatically run tests on GitHub infrastructure against multiple Python versions
- Workflows can be found in [`.github/workflows`](.github/workflows/)
- [Relevant section in the guide](https://guide.esciencecenter.nl/#/best_practices/language_guides/python?id=testing)
{%- endif %}

## Documentation

Expand Down
8 changes: 8 additions & 0 deletions template/pyproject.toml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ version = "{{ version }}"
dev = [
"build", # build is not only used in publishing (below), but also in the template's test suite
"bump-my-version",
{%- if AddLocalTests %}
"coverage [toml]",
"pytest",
"pytest-cov",
{%- endif %}
"ruff",
"sphinx",
"sphinx_rtd_theme",
Expand Down Expand Up @@ -76,22 +78,28 @@ Changelog = "{{ repository_url }}/CHANGELOG.md"
{% if AddOnlineDocumentation -%}
ReadTheDocs = "https://{{ package_name }}.readthedocs.io"
{% endif %}
{% if AddLocalTests -%}
[tool.pytest.ini_options]
testpaths = ["tests"]
{% endif %}

{% if AddLocalTests -%}
[tool.coverage.run]
branch = true
source = ["src/{{ package_name }}"]
command_line = "-m pytest"
{%- endif %}

[tool.tox]
legacy_tox_ini = """
[tox]
envlist = py38,py39,py310,py311,py312
skip_missing_interpreters = true
{% if AddLocalTests -%}
[testenv]
commands = pytest
extras = dev
{%- endif %}
"""

[tool.ruff]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ The sections below outline the steps in each case.
{% if AddDevDoc -%}
1. install dependencies (see the [development documentation](README.dev.md#development_install));
{%- endif %}
{% if AddLocalTests -%}
1. make sure the existing tests still work by running ``pytest``;
1. add your own tests (if necessary);
{%- endif %}
1. update or expand the documentation;
{% if AddChangeLog -%}
1. update the `CHANGELOG.md` file with your change;
Expand Down