Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #112

Merged
merged 4 commits into from
Dec 16, 2023
Merged

Dev #112

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
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ max_line_length = 119
indent_style = tab
insert_final_newline = false

[*.yml]
[{*.yaml,*.yml}]
indent_size = 2
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ __pycache__
!.editorconfig
!.flake8
!.gitignore
!.pre-commit-config.yaml
!.gitkeep
12 changes: 12 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# pre-commit plugin configuration
# See https://pre-commit.com for more information
default_install_hook_types:
- pre-commit
- post-rewrite
- pre-push

repos:
- repo: https://github.com/jedie/cli-base-utilities
rev: v0.7.0rc2
hooks:
- id: update-readme-history
22 changes: 19 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,11 @@ Usage: ./dev-cli.py [OPTIONS] COMMAND [ARGS]...
│ check-code-style Check code style by calling darker + flake8 │
│ coverage Run tests and show coverage report. │
│ fix-code-style Fix code style of all manageprojects source code files via darker │
│ git-hooks Setup our "pre-commit" git hooks │
│ install Run pip-sync and install 'manageprojects' via pip as editable. │
│ mypy Run Mypy (configured in pyproject.toml) │
│ publish Build and upload this project to PyPi │
│ run-git-hooks Run the installed "pre-commit" git hooks │
│ safety Run safety check against current requirements files │
│ test Run unittests │
│ tox Run tox │
Expand All @@ -315,12 +317,26 @@ Usage: ./dev-cli.py [OPTIONS] COMMAND [ARGS]...
```
[comment]: <> (✂✂✂ auto generated dev help end ✂✂✂)

## development git hooks

To install the git hooks, run:

```bash
~/manageprojects$ ./dev-cli.py git-hooks
```


## History

See also git tags: https://github.com/jedie/manageprojects/tags

[comment]: <> (✂✂✂ auto generated history start ✂✂✂)

* [**dev**](https://github.com/jedie/manageprojects/compare/v0.16.1...main)
* 2023-12-16 - Skip test_readme_history() on CI
* 2023-12-16 - Add git hook "update-readme-history"
* 2023-12-16 - Apply cookiecutter updates
* 2023-12-16 - Update requirements
* [v0.16.1](https://github.com/jedie/manageprojects/compare/v0.16.0...v0.16.1)
* 2023-12-05 - Fix "format file" and very verbose error output
* [v0.16.0](https://github.com/jedie/manageprojects/compare/v0.15.4...v0.16.0)
Expand All @@ -329,12 +345,12 @@ See also git tags: https://github.com/jedie/manageprojects/tags
* 2023-12-01 - Use: cli_base.cli_tools.test_utils.logs.AssertLogs
* [v0.15.4](https://github.com/jedie/manageprojects/compare/v0.15.3...v0.15.4)
* 2023-11-27 - Use "flake8-bugbear", too.
* [v0.15.3](https://github.com/jedie/manageprojects/compare/v0.15.2...v0.15.3)
* 2023-11-09 - Bugfix "reverse" if context contains a list
* 2023-11-07 - Update requirements

<details><summary>Expand older history entries ...</summary>

* [v0.15.3](https://github.com/jedie/manageprojects/compare/v0.15.2...v0.15.3)
* 2023-11-09 - Bugfix "reverse" if context contains a list
* 2023-11-07 - Update requirements
* [v0.15.2](https://github.com/jedie/manageprojects/compare/v0.15.1...v0.15.2)
* 2023-11-01 - Update requirements
* [v0.15.1](https://github.com/jedie/manageprojects/compare/v0.15.0...v0.15.1)
Expand Down
26 changes: 22 additions & 4 deletions manageprojects/cli/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@

import rich_click as click
from bx_py_utils.path import assert_is_file
from cli_base.cli_tools import code_style
from cli_base.cli_tools.dev_tools import run_coverage, run_tox, run_unittest_cli
from cli_base.cli_tools.subprocess_utils import verbose_check_call
from cli_base.cli_tools.subprocess_utils import ToolsExecutor, verbose_check_call
from cli_base.cli_tools.test_utils.snapshot import UpdateTestSnapshotFiles
from cli_base.cli_tools.verbosity import OPTION_KWARGS_VERBOSE
from cli_base.cli_tools.version_info import print_version
Expand All @@ -18,7 +19,6 @@

import manageprojects
from manageprojects import constants
from manageprojects.utilities import code_style
from manageprojects.utilities.publish import publish_package


Expand Down Expand Up @@ -62,6 +62,24 @@ def cli():
pass


@cli.command()
def git_hooks():
"""
Setup our "pre-commit" git hooks
"""
executor = ToolsExecutor(cwd=PACKAGE_ROOT)
executor.verbose_check_call('pre-commit', 'install')


@cli.command()
def run_git_hooks():
"""
Run the installed "pre-commit" git hooks
"""
executor = ToolsExecutor(cwd=PACKAGE_ROOT)
executor.verbose_check_call('pre-commit', 'run', '--verbose', exit_on_error=True)


@click.command()
@click.option('-v', '--verbosity', **OPTION_KWARGS_VERBOSE)
def mypy(verbosity: int):
Expand Down Expand Up @@ -170,7 +188,7 @@ def fix_code_style(color: bool, verbosity: int):
"""
Fix code style of all manageprojects source code files via darker
"""
code_style.fix(package_root=PACKAGE_ROOT, color=color, verbose=verbosity > 0)
code_style.fix(package_root=PACKAGE_ROOT, darker_color=color, darker_verbose=verbosity > 0)


cli.add_command(fix_code_style)
Expand All @@ -183,7 +201,7 @@ def check_code_style(color: bool, verbosity: int):
"""
Check code style by calling darker + flake8
"""
code_style.check(package_root=PACKAGE_ROOT, color=color, verbose=verbosity > 0)
code_style.check(package_root=PACKAGE_ROOT, darker_color=color, darker_verbose=verbosity > 0)


cli.add_command(check_code_style)
Expand Down
9 changes: 8 additions & 1 deletion manageprojects/tests/test_readme_history.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from unittest import TestCase
import os
from unittest import TestCase, skipIf

from bx_py_utils.auto_doc import assert_readme_block
from cli_base.cli_tools.git_history import get_git_history
Expand All @@ -8,6 +9,12 @@


class ReadmeHistoryTestCase(TestCase):
@skipIf(
# After a release the history may be "changed" because of version bump
# and we should not block merge requests because of this.
'GITHUB_ACTION' in os.environ,
reason='Skip on github actions',
)
def test_readme_history(self):
git_history = get_git_history(
current_version=manageprojects.__version__,
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ dependencies = [
"codespell", # https://github.com/codespell-project/codespell
"mypy", # https://github.com/python/mypy

"cli-base-utilities>=0.6.0", # https://github.com/jedie/cli-base-utilities
"cli-base-utilities>=0.7.0rc2", # https://github.com/jedie/cli-base-utilities
"click", # https://github.com/pallets/click/
"rich-click", # https://github.com/ewels/rich-click
"rich", # https://github.com/Textualize/rich
Expand All @@ -40,6 +40,7 @@ dev = [
"coverage", # https://github.com/nedbat/coveragepy
"safety", # https://github.com/pyupio/safety
"twine", # https://github.com/pypa/twine
"pre-commit", # https://github.com/pre-commit/pre-commit

"tomli", # https://github.com/hukkin/tomli
#
Expand Down
Loading