Skip to content

Commit

Permalink
feat(pkge): Add pre-commit badge to README #163 (#164)
Browse files Browse the repository at this point in the history
Pre-commit badge communicates to potential users.
Updated README with pre-commit information.
Add pre-commit information to reference-project-inputs.

closes #163
  • Loading branch information
imAsparky committed Nov 13, 2021
1 parent e2a6e03 commit a8f6bd7
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 2 deletions.
3 changes: 3 additions & 0 deletions README.rst
Expand Up @@ -68,6 +68,8 @@ Features
you choose to version and publish your package manually.
#. An optional GitHub action to run your `Tox`_ package test suite when a
pull request to the main branch starts.
#. Optional to use to use `pre-commit`_ to identuify simple coding issues
before submission, with a badge to communicate quickly.
#. `Tox`_ configuration for your package includes an OS and Python test matrix.
OS includes Linux, macOS and Windows. Python 3.6 - 3.9. (Uses GitHub actions.)
#. An optional suite of custom GitHub issue templates. The four custom issue
Expand Down Expand Up @@ -165,6 +167,7 @@ make my own packaging experience better.
.. _Diataxis: https://diataxis.fr/
.. _Mkdocs: https://pypi.org/project/mkdocs/
.. _Poetry: https://python-poetry.org/
.. _pre-commit: https://pre-commit.com/
.. _Projects: https://github.com/imAsparky/cookiecutter-py3-package/projects
.. _PyPi: https://pypi.python.org/pypi
.. _pyup.io: https://pyup.io/
Expand Down
2 changes: 1 addition & 1 deletion cookiecutter.json
Expand Up @@ -11,14 +11,14 @@
"use_repo_status_badge": ["no", "concept", "wip", "active"],
"add_pyup_badge": "n",
"use_readthedocs": ["y", "n"],
"use_pre_commit": "y",
"command_line_interface": ["Click", "Argparse", "No command-line interface"],
"create_author_file": "y",
"create_conventional_commits_edit_message": "y",
"create_repo_auto_test_workflow": "y",
"create_auto_CHANGELOG": "n",
"github_CHANGELOG_access_token": ["secrets.GITHUB_TOKEN", "secrets.CHANGELOG_UPDATE"],
"use_GH_action_semantic_version": "y",
"use_pre_commit": "y",
"use_GH_custom_issue_templates": "y",
"automatic_set_up_git_and_initial_commit": "y",
"use_release_to_test_pypi_with_tags": "n",
Expand Down
6 changes: 6 additions & 0 deletions docs/source/reference/reference-project-inputs.rst
Expand Up @@ -94,6 +94,12 @@ project.

Requires a free Read the Docs account.

**use_pre_commit**
*default = y*

Pre-commit is useful for identifying simple issues before submission
to code review.


**command_line_interface**
*default = Click*
Expand Down
4 changes: 4 additions & 0 deletions tests/test_bake_project.py
Expand Up @@ -577,6 +577,8 @@ def test_bake_with_pre_commit(cookies):

pre_commit_with_files = [f.basename for f in result.project.listdir()]
assert ".pre-commit-config.yaml" in pre_commit_with_files
assert "pre--commit-enabled" in result.project.join("README.rst").read()
assert "pre-commit==" in result.project.join("requirements_dev.txt").read()


def test_bake_without_pre_commit(cookies):
Expand All @@ -587,6 +589,8 @@ def test_bake_without_pre_commit(cookies):

pre_commit_without_files = [f.basename for f in result.project.listdir()]
assert ".pre-commit-config.yaml" not in pre_commit_without_files
assert "pre--commit-enabled" not in result.project.join("README.rst").read()
assert "pre-commit==" not in result.project.join("requirements_dev.txt").read()


def test_bake_with_git_init_success(cookies):
Expand Down
6 changes: 6 additions & 0 deletions {{cookiecutter.git_project_name}}/README.rst
Expand Up @@ -15,6 +15,12 @@
:alt: Updates
{%- endif %}

{%- if cookiecutter.use_pre_commit == "y" %}
.. image:: https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white
:target: https://github.com/pre-commit/pre-commit
:alt: pre-commit
{%- endif %}

{%- if cookiecutter.use_readthedocs == "y" %}
.. image:: https://readthedocs.org/projects/{{cookiecutter.git_project_name}}/badge/?version=latest
:target: https://{{cookiecutter.git_project_name}}.readthedocs.io/en/latest/?badge=latest
Expand Down
4 changes: 3 additions & 1 deletion {{cookiecutter.git_project_name}}/requirements_dev.txt
Expand Up @@ -2,7 +2,6 @@ cookiecutter==1.4.0
flake8==3.7.8
furo==2021.8.11b42
myst-parser==0.15.2
pre-commit==2.14.1
pytest==6.2.4
python-semantic-release==7.19.2
Sphinx==4.1.2
Expand All @@ -12,5 +11,8 @@ wheel==0.37.0
watchdog==2.1.5


{% if cookiecutter.use_pre_commit == 'y' -%}
pre-commit==2.14.1{% endif %}

{% if cookiecutter.command_line_interface|lower == 'click' -%}
Click==8.0.1{% endif %}

0 comments on commit a8f6bd7

Please sign in to comment.