Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add black lint workflow * black . * add pre-commit for black/flake8 * configure black and flake8 * add make fmt and clean up makefile * use basic flake8 config from black docs fix unused imports ignore unused import in manage.py as its used to trigger an ImportError * add isort to pre-commit * run isort on all .py files * sort requirements-test.txt * add isort github action * master -> main branch refs
- Loading branch information
1 parent
f65fd84
commit e747401
Showing
27 changed files
with
609 additions
and
490 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[flake8] | ||
max-line-length = 88 | ||
select = C,E,F,W,B,B950 | ||
extend-ignore = E203, E501 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
name: Lint | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: psf/black@stable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name: Run isort | ||
on: | ||
- push | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.9 | ||
- uses: jamescurtin/isort-action@master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
repos: | ||
- repo: https://github.com/ambv/black | ||
rev: 21.12b0 | ||
hooks: | ||
- id: black | ||
language_version: python3.9 | ||
- repo: https://gitlab.com/pycqa/flake8 | ||
rev: 4.0.1 | ||
hooks: | ||
- id: flake8 | ||
- repo: https://github.com/pycqa/isort | ||
rev: 5.10.1 | ||
hooks: | ||
- id: isort | ||
name: isort (python) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,48 @@ | ||
.PHONY: help clean clean-build clean-pyc lint test docs release dist run | ||
.PHONY: help clean clean-build clean-pyc lint fmt test docs release dist run | ||
|
||
help: | ||
@echo "clean-build - remove build artifacts" | ||
@echo "clean-pyc - remove Python file artifacts" | ||
@echo "lint - check PEP8 style with flake8, and rst with rst-lint" | ||
@echo "test - run tests quickly with the default Python" | ||
@echo "coverage - check code coverage quickly with the default Python" | ||
@echo "docs - generate Sphinx HTML documentation, including API docs" | ||
@echo "release - package and upload a release" | ||
@echo "dist - package a release" | ||
@echo "run - build and run sample project with docker" | ||
|
||
clean: clean-build clean-pyc | ||
|
||
clean-build: | ||
@grep -E -h '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' | ||
|
||
clean: clean-build clean-pyc ## Clean all | ||
|
||
clean-build: ## Clean build artifacts | ||
rm -fr build/ | ||
rm -fr dist/ | ||
rm -fr *.egg-info | ||
|
||
clean-pyc: | ||
clean-pyc: ## Clean compiled python files | ||
find . -name '*.pyc' -exec rm -f {} + | ||
find . -name '*.pyo' -exec rm -f {} + | ||
find . -name '*~' -exec rm -f {} + | ||
|
||
lint: | ||
lint: ## Check PEP8 style with flake8, and rst with rst-lint | ||
flake8 watchman tests --ignore=E501 | ||
rst-lint *.rst | ||
|
||
test: | ||
fmt: ## Format python code with black | ||
black . | ||
|
||
test: ## Run tests using GHA workflows with act | ||
act --job build | ||
|
||
docs: | ||
docs: ## Generate Sphinx HTML documentation, including API docs | ||
rm -f docs/watchman.rst | ||
rm -f docs/modules.rst | ||
sphinx-apidoc -o docs/ watchman | ||
$(MAKE) -C docs clean | ||
$(MAKE) -C docs html | ||
open docs/_build/html/index.html | ||
|
||
release: clean lint test | ||
release: clean lint test ## Package and upload a release | ||
python setup.py sdist | ||
python setup.py bdist_wheel | ||
twine upload dist/* | ||
|
||
dist: clean lint test | ||
dist: clean lint test ## Package a release | ||
python setup.py sdist | ||
python setup.py bdist_wheel | ||
ls -l dist | ||
|
||
run: | ||
run: ## Build and run sample project with docker | ||
docker build -t watchman . | ||
docker run -it -p 8000:8000 watchman |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.