Skip to content

Commit

Permalink
Merge branch 'main' into main-github
Browse files Browse the repository at this point in the history
  • Loading branch information
jannismain committed Sep 21, 2023
2 parents c987e54 + f786359 commit a36dd03
Show file tree
Hide file tree
Showing 26 changed files with 382 additions and 298 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "template/{% if docs_template == 'sphinx-fhg-iis' %}docs{% endif %}"]
path = "template/{% if docs_template == 'sphinx-fhg-iis' %}docs{% endif %}"
url = https://git01.iis.fhg.de/mkj/sphinx_template
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ repos:
hooks:
- id: prettier
types_or: [json, yaml, css, javascript]
pass_filenames: false
# black should have the final say on python formatting, so it comes last
- repo: https://github.com/psf/black
rev: 23.9.1
Expand All @@ -22,7 +23,7 @@ repos:
hooks:
- id: pytest
name: pytest
entry: pytest -n auto -m "not slow"
entry: make test
language: system
pass_filenames: false
files: "^template/"
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [unreleased]

### Added

- github ci now runs tests, collects coverage and creates maintainability and coverage badges
- add [sphinx_template](https://git01.iis.fhg.de/sch/sphinx_template/) as an option when choosing sphinx for documentation

### Changed

- template now uses a static documentation badge provided by shields.io

### Fixed

- link to pipeline in README now correctly links to github actions
- when bumpversion is selected, add `bump2version` to dev dependencies

## [0.0.2] - 2023-09-19

### Added
Expand Down
10 changes: 6 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ DOC_EXAMPLES = docs/examples/mkdocs docs/examples/sphinx docs/examples/default d
examples: ## build all published examples
examples: $(PUBLISHED_EXAMPLES)

COPIER_ARGS?=--trust
COPIER_ARGS?=--trust --vcs-ref=HEAD
COPIER_DEFAULT_VALUES=-d "project_name=Sample Project" -d "package_name=sample_project"
build/examples/%: COPIER_DEFAULT_VALUES += --defaults
build/examples/%: EXAMPLE_DIR:=$@
Expand Down Expand Up @@ -99,10 +99,12 @@ spellcheck-dump: ## save all flagged words to project terms dictionary


.PHONY: test
PYTEST_ARGS=-n auto
test: ## run tests quickly
PYTEST_ARGS?=
test: ## run some tests
test: build-clean copy-template
pytest ${PYTEST_ARGS} -m "not slow"
test-all: ## run all tests
test-all: build-clean copy-template
pytest ${PYTEST_ARGS}


Expand All @@ -123,7 +125,7 @@ copy-template:
@cp -r ${TEMPLATE_SRC} ${TEMPLATE_DEST}
@cp copier.yaml ${PKGDIR}/.
build-clean: ## remove build artifacts
rm -rf ${BUILDDIR} ${PKGDIR}/template ${PKGDIR}/copier.yaml
@rm -rf ${BUILDDIR} ${PKGDIR}/template ${PKGDIR}/copier.yaml

.PHONY: release release-test release-tag release-pypi release-github
release: release-test release-tag build release-pypi release-github
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div align=center>
<h1>Python Project Template</h1>

[![](https://img.shields.io/badge/python-3.11-blue)][sample project]
[![](https://img.shields.io/badge/Documentation-main-blue)][docs]
[![](https://img.shields.io/badge/Example-Sample_Project-blue)][sample project]
[![PyPI - Version](https://img.shields.io/pypi/v/init-python-project)][pypi]

Expand Down Expand Up @@ -63,6 +63,7 @@ init-python-project <name of project>

The first part of the user guide consists of tutorials on how to answer the template questions for [Your First Project][], what [Next Steps][] there are after your project is created and why the [Project Structure][] looks like it does.

[docs]: https://jannismain.github.io/python-project-template/
[your first project]: https://jannismain.github.io/python-project-template/user-guide/first-project
[next steps]: https://jannismain.github.io/python-project-template/user-guide/first-project
[project structure]: https://jannismain.github.io/python-project-template/user-guide/project-structure
Expand Down
11 changes: 11 additions & 0 deletions copier.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,17 @@ docs:
If you are not sure which one to use, simply go with the default 😉.
docs_template:
type: str
choices:
Fraunhofer IIS Sphinx Template: sphinx-fhg-iis
None: none
default: "none"
when: "{{ docs == 'sphinx' }}"
help: Which documentation template do you want to use?
explanation: |
See [Fraunhofer IIS Sphinx Template](https://git01.iis.fhg.de/sch/sphinx_template/).
remote:
choices:
GitHub: github
Expand Down
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "init-python-project"
description = "A python project generator based on copier."
description = "A python project generator."
readme = "README.md"
requires-python = ">=3.11"
authors = [{ name = "Jannis Mainczyk", email = "jmainczyk@gmail.com" }]
Expand Down Expand Up @@ -50,9 +50,10 @@ init-python-project = "init_python_project.cli:app"

[tool.pytest.ini_options]
minversion = "6.0"
addopts = "-ra -q"
addopts = "-ra -q -n auto --exitfirst"
testpaths = ["tests"]
markers = ["slow"]
filterwarnings = ["ignore::copier.vcs.DirtyLocalWarning"]

[tool.black]
line-length = 100
Expand Down
170 changes: 0 additions & 170 deletions src/init_python_project/copier.yaml

This file was deleted.

5 changes: 3 additions & 2 deletions template/Makefile.jinja
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.PHONY: install-dev
install-dev: ## install project including all development dependencies
pip install -e .[test,doc,dev]
pip install -e .[test,dev]
pip install -r docs/requirements.txt

.PHONY: maintainability
maintainability: ## run maintainability checks
Expand Down Expand Up @@ -35,7 +36,7 @@ docs-live: ## serve documentation
{%- if docs == 'mkdocs' %}
mkdocs serve
{%- elif docs == 'sphinx' %}
sphinx-autobuild docs ${DOCS_TARGET}/livehtml
cd docs && $(MAKE) serve
{% endif %}

{% endif %}
Expand Down
13 changes: 8 additions & 5 deletions template/README.md.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

{%- import 'template/context' as ctx with context %}

[![documentation][badge_documentation]]({{ctx.remote_url_pages}}) [![badge_pipeline][]]({{ctx.remote_url_https}}/-/pipelines) [![badge_coverage][]]({{ctx.remote_url_pages}}/coverage) [![badge_maintainability][]]()

[badge_documentation]: {{ctx.remote_url_pages}}/badges/documentation.svg
[badge_coverage]: {{ctx.remote_url_https}}/badges/{{default_branch}}/coverage.svg
[badge_pipeline]: {{ctx.remote_url_https}}/badges/{{default_branch}}/pipeline.svg
[![badge_documentation][]][documentation] [![badge_pipeline][]][pipeline] [![badge_coverage][]][coverage] [![badge_maintainability][]]()

[documentation]: {{ctx.remote_url_pages}}
[badge_documentation]: https://img.shields.io/badge/Documentation-{{default_branch}}-blue
[coverage]: {{ctx.remote_url_pages}}/coverage
[badge_coverage]: {{ctx.remote_url_coverage_badge}}
[badge_pipeline]: {{ctx.remote_url_pipeline_badge}}
[pipeline]: {{ctx.remote_url_pipeline}}
[badge_maintainability]: {{ctx.remote_url_pages}}/badges/maintainability.svg

<!-- TODO: extend readme template -->
Expand Down
19 changes: 19 additions & 0 deletions template/context
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,30 @@

{% if remote == 'github' %}
{% set domain_pages = 'github.io' %}
{% set path_pipeline = '/actions?query=branch%3A' + default_branch %}
{% elif remote == 'gitlab-iis' %}
{% set domain_pages = domain %}
{% elif remote == 'gitlab-fhg' %}
{% set domain_pages = 'pages.fraunhofer.de' %}
{% endif %}

{% if remote.startswith('gitlab') %}
{% set path_pipeline = '/-/pipelines' %}
{% endif %}

{% set remote_url_pages = "https://" + group + "." + domain_pages + "/" + pages_path %}
{% set remote_url_pipeline = remote_url_https + path_pipeline %}

{% if remote == 'github' %}
{# coverage badge is provided by gitlab #}
## coverage badge is generated by github action and published on github pages
{% set remote_url_coverage_badge = remote_url_pages + '/badges/coverage.svg' %}
## pipeline badge is provided by github
{% set remote_url_pipeline_badge = remote_url_https + '/actions/workflows/ci.yaml/badge.svg' %}
{% else %}
## coverage and pipeline badges are provided by gitlab
{% set remote_url_coverage_badge = remote_url_https + '/badges/' + default_branch + 'coverage.svg' %}
{% set remote_url_pipeline_badge = remote_url_https + '/badges/' + default_branch + 'pipeline.svg' %}
{% endif %}

{% set cli_command = package_name | replace("_", "-") %}
18 changes: 1 addition & 17 deletions template/pyproject.toml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -70,24 +70,8 @@ dependencies = ["click"]
# Similar to `dependencies` above, these must be valid existing
# projects.
[project.optional-dependencies]
dev = ["black", "radon", "ruff"]
dev = ["black", "radon", "ruff"{% if use_bumpversion %}, "bump2version"{% endif %}]
test = ["pytest", "pytest-cov", "coverage[toml]"]
{% if docs!="none" -%}
doc = [
{%- if docs=="mkdocs" %}
"mkdocs-material",
"mkdocstrings[python]",
"mkdocs-git-revision-date-localized-plugin",
"mkdocs-macros-plugin",
{%- elif docs=="sphinx" %}
"sphinx",
"furo",
"myst_parser",
"sphinx-autodoc2",
"sphinx-autobuild",
{%- endif %}
]
{%- endif %}

# The following would provide a command line executable which executes
# the function `main` from this package's cli module when invoked.
Expand Down
Loading

0 comments on commit a36dd03

Please sign in to comment.