Skip to content

Commit

Permalink
Drop annoying git hooks (#1184)
Browse files Browse the repository at this point in the history
  • Loading branch information
asvetlov authored Nov 21, 2019
1 parent d6767dc commit d8347c2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 141 deletions.
6 changes: 0 additions & 6 deletions .hooks/post-checkout

This file was deleted.

28 changes: 0 additions & 28 deletions .hooks/pre-push

This file was deleted.

120 changes: 14 additions & 106 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,9 @@
DEVPI_URL ?= "https://$(DEVPI_USER):$(DEVPI_PASS)@$(DEVPI_HOST)/$(DEVPI_USER)"

SHELL := /bin/bash
BRANCH := $(shell git branch | grep \* | cut -d ' ' -f2)

MYPY_CACHE_DIR=.mypy_cache/$(shell md5sum setup.py | awk '{print $$1}')-$(shell find requirements -type f -exec md5sum {} \; | sort -k 2 | md5sum | awk '{print $$1}')

ISORT_DIRS := neuromation tests build-tools setup.py
ISORT_REGEXP := ^((neuromation|tests|build-tools)/.+|setup)\\.py$
BLACK_DIRS := $(ISORT_DIRS)
BLACK_REGEXP := $(ISORT_REGEXP)
MYPY_DIRS := neuromation tests
MYPY_REGEXP := ^(neuromation|tests)/.+\\.py$
FLAKE8_DIRS := $(ISORT_DIRS)
FLAKE8_REGEXP := $(ISORT_REGEXP)

DEPS_REGEXP := ^(requirements/.+|setup.py+)

README_PATTERN := README.XXXXXXXX.md

Expand All @@ -28,38 +17,22 @@ help:
- help: this help \n\
- init: initialize project for development \n\
- update-deps: install.update all development dependencies \n\
- release: Generate changelog and tag new version \n\
example: make release VERSION=0.5 \n\
- dist-clean: remove files generated during publish \n\
- clean: remove generated files \n\
- update-deps-fast: update deps only if requirements changed betwwen two points(hook)\
\n\
* Modifications and generations: \n\
- format: format python code(isort + black) \n\
- fmt: format python code(isort + black) \n\
- docs: generate docs \n\
- changelog: generate and commit changelog \n\
example: make changelog VERSION=0.5 \n\
\n\
* Lint (static analysis) \n\
- lint: run linters(isort, black, flake8, mypy, lint-docs) \n\
- lint-docs: validate generated docs \n\
- lint-diff: lint only modified files, between two points(hook) \n\
- publish-lint: lint distribution \n\
\n\
* Tests \n\
- test: run usual(not e2e) tests \n\
- e2e: run e2e tests \n\
- test-all: run all tests \n\
- test-fast: run usual test for modified from latest execution files \n\
example: make lint diff FROM=e2d9e591f6d413588b4d4a0af0a3aa066a0ae8eb TO=a0a5b84e31c7d36d2c440d3707d25fc0ef567a61 \n\
\n\
* Distribution \n\
- dist: generate python distribution(wheel) \n\
- publish: publish distribution to pypi index \n\
\n\
* CI \n\
- coverage: upload coverage information to codecov.io \n\
- ci: run CI related targets \n\
\n\
* API-DOC \n\
- api-doc: generate sphinx html docs \n\
Expand All @@ -75,8 +48,17 @@ init: _init-readme update-deps
_init-readme:
cp -n README.in.md README.md

.PHONY: update-deps
update-deps:
pip install -r requirements/dev.txt
touch .update-deps

.update-deps: $(shell find requirements -type f)
pip install -r requirements/dev.txt
touch .update-deps

.PHONY: e2e
e2e:
e2e: .update-deps
pytest \
-n ${PYTEST_XDIST_NUM_THREADS} \
-m "e2e" \
Expand All @@ -89,24 +71,16 @@ e2e:


.PHONY: test
test:
test: .update-deps
pytest \
-m "not e2e" \
--cov=neuromation \
--cov-report term-missing:skip-covered \
--cov-report xml:coverage.xml \
tests

.PHONY: test-fast
test-fast:
pytest \
--quiet \
--testmon --tlf \
-m "not e2e" \
tests || test $$? -eq 5

.PHONY: test-all
test-all:
test-all: .update-deps
pytest \
--cov=neuromation \
--cov-report term-missing:skip-covered \
Expand All @@ -117,74 +91,26 @@ test-all:
lint: lint-docs
isort -c -rc ${ISORT_DIRS}
black --check $(BLACK_DIRS)
mypy --cache-dir $(MYPY_CACHE_DIR) $(MYPY_DIRS)
mypy $(MYPY_DIRS)
flake8 $(FLAKE8_DIRS)

.PHONY: lint-diff
lint-diff: ISORT_TARGETS:=$(shell git diff --name-status --diff-filter=d $(FROM) $(TO) . | awk '{if ($$NF ~ "$(ISORT_REGEXP)") print $$NF}')
lint-diff: BLACK_TARGETS:=$(shell git diff --name-status --diff-filter=d $(FROM) $(TO) . | awk '{if ($$NF ~ "$(BLACK_REGEXP)") print $$NF}')
lint-diff: MYPY_TARGETS:=$(shell git diff --name-status --diff-filter=d $(FROM) $(TO) . | awk '{if ($$NF ~ "$(MYPY_REGEXP)") print $$NF}')
lint-diff: FLAKE8_TARGETS:=$(shell git diff --name-status --diff-filter=d $(FROM) $(TO) . | awk '{if ($$NF ~ "$(FLAKE8_REGEXP)") print $$NF}')
lint-diff:
@ [ -z "${ISORT_TARGETS}" ] || (echo "Lint isort:"; echo " ${ISORT_TARGETS}" && isort -c -rc ${ISORT_TARGETS})
@ [ -z "${BLACK_TARGETS}" ] || (echo "Lint black:"; echo " ${BLACK_TARGETS}" && black -q --check ${BLACK_TARGETS})
@ [ -z "${MYPY_TARGETS}" ] || (echo "Lint mypy:"; echo " ${MYPY_TARGETS}" && mypy --cache-dir $(MYPY_CACHE_DIR) ${MYPY_TARGETS})
@ [ -z "${FLAKE8_TARGETS}" ] || (echo "Lint flake8:"; echo " ${FLAKE8_TARGETS}" && flake8 ${FLAKE8_TARGETS})


.PHONY: dist-clean
dist-clean:
rm -rf dist || true
rm -rf build || true

.PHONY: dist
dist: dist-clean
python setup.py sdist bdist_wheel

.PHONY: publish-lint
publish-lint:
twine check dist/*


.PHONY: publish
publish: dist publish-lint
twine upload dist/*

.PHONY: coverage
coverage:
pip install codecov
codecov -f coverage.xml -X gcov

.PHONY: format fmt
format fmt:
isort -rc $(ISORT_DIRS)
black $(BLACK_DIRS)
# generate docs as the last stage to allow reformat code first
make docs

# TODO (artyom, 07/16/2018): swap e2e and test once coverage output
# of both is combined. Otherwise e2e will override unit tests with
# lower coverage
.PHONY: ci
ci: lint test _e2e coverage

.PHONY: clean
clean:
find . -name '*.egg-info' -exec rm -rf {} +
find . -name '__pycache__' -exec rm -rf {} +
rm README.md
rm -rf .testmondata .tmontmp .mypy_cache .pytest_cache

devpi_setup:
pip install devpi-client
pip install wheel
@devpi use $(DEVPI_URL)/$(DEVPI_INDEX)

devpi_login:
@devpi login $(DEVPI_USER) --password=$(DEVPI_PASS)

devpi_upload: devpi_login
devpi upload --formats bdist_wheel

.PHONY: docs
docs:
Expand All @@ -199,24 +125,6 @@ lint-docs:
markdown-toc -t github -h 6 ${TMP}
diff -q ${TMP} README.md

.PHONY: update-deps
update-deps:
pip install --disable-pip-version-check -r requirements/dev.txt

.PHONY: changelog
changelog:
echo "Read RELEASE.md for release process instructions"

.PHONY: release
release:
echo "Read RELEASE.md for release process instructions"

.PHONY: update-deps-fast
update-deps-fast: REQUIREMENTS_CHANGED:=$(shell git diff --name-status --diff-filter=d $(FROM) $(TO) . | awk '{if ($$NF ~ "$(DEPS_REGEXP)") print substr($$NF, 8)}')
update-deps-fast:
@ [ -z "${REQUIREMENTS_CHANGED}" ] || (make update-deps)


.PHONY: api-doc
api-doc:
make -C docs html SPHINXOPTS="-W -E"
Expand Down
1 change: 0 additions & 1 deletion requirements/ci.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ pytest-cov==2.8.1
pytest-aiohttp==0.3.0
pytest-xdist==1.30.0
pytest-timeout==1.3.3
pytest-testmon==1.0.0
flake8==3.7.9
isort==4.3.21
black==19.10b0
Expand Down

0 comments on commit d8347c2

Please sign in to comment.