Skip to content

Commit

Permalink
migrate from bump2version to bump-my-version, small documentation adj…
Browse files Browse the repository at this point in the history
…ustments, move flake8 configuration to .flake8, remove setup.cfg
  • Loading branch information
Zeitsperre committed Nov 22, 2023
1 parent 31d78c6 commit 4e85d42
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 79 deletions.
6 changes: 3 additions & 3 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,11 @@ Pull Request Guidelines

Before you submit a pull request, check that it meets these guidelines:

1. The pull request should include tests.
#. The pull request should include tests.

2. If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in README.rst.
#. If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in README.rst.

3. The pull request should work for Python 3.8, 3.9, 3.10, 3.11, and for PyPy. Check https://github.com/Ouranosinc/cookiecutter-pypackage/actions/workflows/main.yml and make sure that the tests pass for all supported Python versions.
#. The pull request should work for Python 3.8, 3.9, 3.10, 3.11, and for PyPy. Check https://github.com/Ouranosinc/cookiecutter-pypackage/actions/workflows/main.yml and make sure that the tests pass for all supported Python versions.

Add a New Test
--------------
Expand Down
30 changes: 30 additions & 0 deletions {{cookiecutter.project_slug}}/.flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[flake8]
exclude =
.eggs,
.git,
build,
docs,
tests
ignore =
AZ100,
AZ200,
AZ300,
C,
D,
E,
F,
W503
per-file-ignores =
rst-roles =
doc,
mod,
py:attr,
py:attribute,
py:class,
py:const,
py:data,
py:func,
py:meth,
py:mod,
py:obj,
py:ref
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ jobs:
run: echo "current_version=$(grep -E '__version__' {{ cookiecutter.project_slug }}/__init__.py | cut -d ' ' -f3)"
- name: Bump Patch Version
run: |
pip install bump2version
pip install bump-my-version
echo "Bumping version"
bump2version patch
bump-my-version bump patch
echo "new_version=$(grep -E '__version__' {{ cookiecutter.project_slug }}/__init__.py | cut -d ' ' -f3)"
- name: Push Changes
uses: ad-m/github-push-action@master
Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.project_slug}}/.github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ jobs:
python -m pip check || true
- name: Test with pytest
run: |
python -m pytest tests
python -m pytest --cov {{ cookiecutter.project_slug }}
- name: Report coverage
run: |
python -m coveralls
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ jobs:
release:
name: Create Release from tag
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v') && endsWith(github.ref, '.0')
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down
8 changes: 3 additions & 5 deletions {{cookiecutter.project_slug}}/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,14 @@ repos:
hooks:
- id: rst-inline-touching-normal
- repo: https://github.com/psf/black
rev: 23.10.1
rev: 23.11.0
hooks:
- id: black
exclude: ^docs/
args: [ '--target-version=py38' ]
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
args: ['--settings-file=setup.cfg']
exclude: ^docs/
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.4
Expand All @@ -51,12 +49,12 @@ repos:
hooks:
- id: flake8
additional_dependencies: [ 'flake8-alphabetize', 'flake8-rst-docstrings' ]
args: [ '--config=setup.cfg' ]
args: [ '--config=.flake8' ]
- repo: https://github.com/keewis/blackdoc
rev: v0.3.8
hooks:
- id: blackdoc
additional_dependencies: [ 'black==23.10.1' ]
additional_dependencies: [ 'black==23.11.0' ]
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.32.0
hooks:
Expand Down
38 changes: 21 additions & 17 deletions {{cookiecutter.project_slug}}/CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
Contributing
============

Contributions are welcome, and they are greatly appreciated! Every little bit
helps, and credit will always be given.
Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.

You can contribute in many ways:

Expand All @@ -26,21 +25,17 @@ If you are reporting a bug, please include:
Fix Bugs
~~~~~~~~

Look through the GitHub issues for bugs. Anything tagged with "bug" and "help
wanted" is open to whoever wants to implement it.
Look through the GitHub issues for bugs. Anything tagged with "bug" and "help wanted" is open to whoever wants to implement it.

Implement Features
~~~~~~~~~~~~~~~~~~

Look through the GitHub issues for features. Anything tagged with "enhancement"
and "help wanted" is open to whoever wants to implement it.
Look through the GitHub issues for features. Anything tagged with "enhancement" and "help wanted" is open to whoever wants to implement it.

Write Documentation
~~~~~~~~~~~~~~~~~~~

{{ cookiecutter.project_name }} could always use more documentation, whether as part of the
official {{ cookiecutter.project_name }} docs, in docstrings, or even on the web in blog posts,
articles, and such.
{{ cookiecutter.project_name }} could always use more documentation, whether as part of the official {{ cookiecutter.project_name }} docs, in docstrings, or even on the web in blog posts, articles, and such.

Submit Feedback
~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -128,9 +123,11 @@ Pull Request Guidelines

Before you submit a pull request, check that it meets these guidelines:

1. The pull request should include tests.
2. If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in ``README.rst``.
3. The pull request should work for Python 3.8, 3.9, 3.10, and 3.11. Check that the tests pass for all supported Python versions.
#. The pull request should include tests.

#. If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in ``README.rst``.

#. The pull request should work for Python 3.8, 3.9, 3.10, and 3.11. Check that the tests pass for all supported Python versions.

Tips
----
Expand All @@ -148,13 +145,20 @@ Versioning/Tagging

A reminder for the maintainers on how to deploy. This section is only relevant for maintainers when they are producing a new point release for the package.

In a new branch, make sure all your release information has been committed (in ``CHANGES.rst``). Then run::
#. Create a new branch from `main` (e.g. `release-0.2.0`).
#. Update the `CHANGES.rst` file to change the `Unreleased` section to the current date.
#. Create a pull request from your branch to `main`.
#. Once the pull request is merged, create a new release on GitHub. On the main branch, run:

.. code-block:: shell
$ bump-my-version bump minor # In most cases, we will be releasing a minor version
$ git push
$ git push --tags
$ bumpversion patch # possible: major / minor / patch
$ git push
$ git push --tags
This will trigger the CI to build the package and upload it to TestPyPI. In order to upload to PyPI, this can be done by publishing a new version on GitHub. This will then trigger the workflow to build and upload the package to PyPI.

This will trigger the CI to build the package and upload it to TestPyPI. In order to upload to PyPI, this can be done by publishing a new version on GitHub. This will trigger the workflow to build and upload the package to PyPI.
#. Once the release is published, it will go into a `staging` mode on Github Actions. Once the tests pass, admins can approve the release (an e-mail will be sent) and it will be published on PyPI.

.. note::

Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.project_slug}}/environment-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ dependencies:
- python >=3.9,<3.12
# Dev tools and testing
- pip >=23.1.2
- bump2version >=1.0.1
- bump-my-version >=0.12.0
- watchdog >=3.0.0
- flake8 >=6.1.0
- flake8-rst-docstrings >=0.3.0
Expand Down
29 changes: 28 additions & 1 deletion {{cookiecutter.project_slug}}/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ dependencies = [
dev = [
# Dev tools and testing
"pip>=23.1.2",
"bump2version>=1.0.1",
"bump-my-version>=0.12.0",
"watchdog>=3.0.0",
"flake8>=6.1.0",
"flake8-rst-docstrings>=0.3.0",
Expand Down Expand Up @@ -108,6 +108,32 @@ target-version = [
]
{%- endif %}

[tool.bumpversion]
current_version = "{{ cookiecutter.version }}"
commit = true
tag = true
tag_name = "{new_version}"
allow_dirty = false
serialize = ["{major}.{minor}.{patch}"]
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"

[[tool.bumpversion.files]]
filename = "{{ cookiecutter.project_slug }}/__init__.py"
search = "__version__ = \"{current_version}\""
replace = "__version__ = \"{new_version}\""

[[tool.bumpversion.files]]
filename = "tests/test_{{ cookiecutter.project_slug }}.py"
search = "__version__ = \"{current_version}\""
replace = "__version__ = \"{new_version}\""
{%- if cookiecutter.generated_with_cruft == 'y' %}

[[tool.bumpversion.files]]
filename = ".cruft.json"
search = "\"version\": \"{current_version}\""
replace = "\"version\": \"{new_version}\""
{%- endif %}

[tool.coverage.run]
relative_files = true
include = ["{{ cookiecutter.project_slug }}/*"]
Expand Down Expand Up @@ -150,6 +176,7 @@ exclude = [
"**/__pycache__",
".coveralls.yml",
".editorconfig",
".flake8",
".gitignore",
".pre-commit-config.yaml",
{%- if cookiecutter.make_docs == 'y' %}
Expand Down
49 changes: 0 additions & 49 deletions {{cookiecutter.project_slug}}/setup.cfg

This file was deleted.

0 comments on commit 4e85d42

Please sign in to comment.