Skip to content

Commit

Permalink
Merge pull request #10 from brainelectronics/feature/add-precommit-hook
Browse files Browse the repository at this point in the history
Add precommit hook
  • Loading branch information
brainelectronics committed Jul 5, 2023
2 parents d74b9fd + 1275da2 commit 0a30f34
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 5 deletions.
13 changes: 13 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
args: ["--markdown-linebreak-ext=md"]
- id: check-yaml
- repo: https://github.com/PyCQA/flake8
rev: 5.0.4
hooks:
- id: flake8
16 changes: 16 additions & 0 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---

- id: upy-package
name: upy-package
description: >
Validate package.json file against changelog.md and setup.py for
MicroPython mip installation
entry: upy-package
args:
- "--setup_file=setup.py"
- "--package_changelog_file=changelog.md"
- "--package_file=package.json"
- "--validate"
language: python
pass_filenames: false
require_serial: true
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ MicroPython Package Validation for mip package.json files
- [Create package JSON file from changelog](#create-package-json-file-from-changelog)
- [Contributing](#contributing)
- [Unittests](#unittests)
- [Precommit hooks](#precommit-hooks)
- [Credits](#credits)

<!-- /MarkdownTOC -->
Expand Down Expand Up @@ -175,6 +176,24 @@ coverage html

The coverage report is placed at `reports/coverage/html/index.html`

### Precommit hooks

This repo is equipped with a `.pre-commit-hooks.yaml` file to be usable in
other repos.

In order to run this repo's pre commit hooks, perform the following steps

```bash
pip install pre-commit
# for older systems without colored output support, last supported version is
# 1.18.3 (7c3404ef1f7593094c854f99bcd3b3eec75fbb2f, 1.19.0 broke it)
# test it with:
# from os import openpty
# r,w = openpty()

pre-commit run --all-files
```

## Credits

Based on the [PyPa sample project][ref-pypa-sample].
Expand Down
10 changes: 9 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ r"^\#\# \[\d{1,}[.]\d{1,}[.]\d{1,}\] \- \d{4}\-\d{2}-\d{2}$"
-->

## Released
## [0.5.0] - 2023-07-05
### Added
- pre-commit hook and config files

### Fixed
- Added missing empty line in several files

## [0.4.0] - 2023-06-10
### Added
- `*/boot.py` and `*/main.py` can be ignored during the check with `--ignore-boot-main`, see #8
Expand Down Expand Up @@ -46,8 +53,9 @@ r"^\#\# \[\d{1,}[.]\d{1,}[.]\d{1,}\] \- \d{4}\-\d{2}-\d{2}$"
- Not used files provided with [template repo](https://github.com/brainelectronics/micropython-i2c-lcd)

<!-- Links -->
[Unreleased]: https://github.com/brainelectronics/micropython-package-validation/compare/0.4.0...main
[Unreleased]: https://github.com/brainelectronics/micropython-package-validation/compare/0.5.0...main

[0.5.0]: https://github.com/brainelectronics/micropython-package-validation/tree/0.5.0
[0.4.0]: https://github.com/brainelectronics/micropython-package-validation/tree/0.4.0
[0.3.0]: https://github.com/brainelectronics/micropython-package-validation/tree/0.3.0
[0.2.0]: https://github.com/brainelectronics/micropython-package-validation/tree/0.2.0
Expand Down
2 changes: 1 addition & 1 deletion docs/changelog_link.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@

.. include:: ../changelog.md
:parser: myst_parser.sphinx_
:parser: myst_parser.sphinx_
2 changes: 1 addition & 1 deletion docs/readme_link.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@

.. include:: ../README.md
:parser: myst_parser.sphinx_
:parser: myst_parser.sphinx_
2 changes: 1 addition & 1 deletion requirements-deploy.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# Avoid fixed versions
# # to upload package to PyPi or other package hosts
twine>=4.0.1,<5
changelog2version>=0.5.0,<1
changelog2version>=0.5.0,<1
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# List external packages here
# Avoid fixed versions
# # to upload package to PyPi or other package hosts
# # to upload package to PyPi or other package hosts

0 comments on commit 0a30f34

Please sign in to comment.