Skip to content

Commit

Permalink
ci: add Makefile and bumpversion
Browse files Browse the repository at this point in the history
  • Loading branch information
spumer committed Jun 22, 2021
1 parent 0a53676 commit db35665
Show file tree
Hide file tree
Showing 6 changed files with 600 additions and 240 deletions.
14 changes: 14 additions & 0 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[bumpversion]
current_version = 1.2.0
commit = True
tag = True

[bumpversion:file:pyproject.toml]
search = version = "{current_version}"
replace = version = "{new_version}"


[bumpversion:file:sqredirect/__init__.py]
search = __version__ = '{current_version}'
replace = __version__ = '{new_version}'

140 changes: 140 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,143 @@ dmypy.json
# Cython debug symbols
cython_debug/

### Python template
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

71 changes: 71 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
.PHONY: init test lint pretty precommit_install bump_major bump_minor bump_patch docs

# if BIN not provided, try to detect the binary from the environment
PYTHON_INSTALL := $(shell python3 -c 'import sys;print(sys.executable)')
BIN ?= $(shell [ -e .venv/bin ] && echo `pwd`/'.venv/bin' || dirname $(PYTHON_INSTALL))/

CODE = .

help: ## This help dialog.
@IFS=$$'\n' ; \
help_lines=(`fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##/:/'`); \
printf "%-15s %s\n" "target" "help" ; \
printf "%-15s %s\n" "------" "----" ; \
for help_line in $${help_lines[@]}; do \
IFS=$$':' ; \
help_split=($$help_line) ; \
help_command=`echo $${help_split[0]} | sed -e 's/^ *//' -e 's/ *$$//'` ; \
help_info=`echo $${help_split[2]} | sed -e 's/^ *//' -e 's/ *$$//'` ; \
printf '\033[36m'; \
printf "%-15s %s" $$help_command ; \
printf '\033[0m'; \
printf "%s\n" $$help_info; \
done


init:
python3 -m venv .venv
poetry install

test: ## Tests
$(BIN)python -m pytest $(CODE) $(args)

cov: ## Tests (with coverage)
$(BIN)python -m pytest --cov=$(CODE) $(args)

lint: ## QA (linting)
$(BIN)flake8 --jobs 4 --statistics --show-source $(CODE) tests
$(BIN)black --target-version=py37 --skip-string-normalization --line-length=120 --check $(CODE) tests
#$(BIN)python -m pytest --dead-fixtures --dup-fixtures # disabled due _old_style_conf_d_globals detected as unused

pretty: ## Autoformat respecting code-style
$(BIN)isort $(CODE) tests
$(BIN)black --target-version=py37 --skip-string-normalization --line-length=120 $(CODE) tests
$(BIN)unify --in-place --recursive $(CODE) tests

precommit_install: ## Установка pre-commit хука с проверками code-style и мелкими авто-справлениеями
echo '#!/bin/sh' > .git/hooks/pre-commit
echo "exec make lint test BIN=$(BIN)" >> .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit

bump_major: ## Bump major version
$(BIN)bumpversion major
dephell convert deps
git add setup.py
git commit --amend --no-edit

bump_minor: ## Bump minor version
$(BIN)bumpversion minor
dephell convert deps
git add setup.py
git commit --amend --no-edit

bump_patch: ## Bump patch version
$(BIN)bumpversion patch
dephell convert deps
git add setup.py
git commit --amend --no-edit


publish: ## Push to repo with tags
git push origin master --tags
Loading

0 comments on commit db35665

Please sign in to comment.