Skip to content

Commit

Permalink
Merge 9318083 into b739ae1
Browse files Browse the repository at this point in the history
  • Loading branch information
jacebrowning committed Jun 3, 2021
2 parents b739ae1 + 9318083 commit 012425c
Show file tree
Hide file tree
Showing 7 changed files with 231 additions and 45 deletions.
4 changes: 0 additions & 4 deletions .isort.cfg
Expand Up @@ -2,10 +2,6 @@

multi_line_output = 3

known_standard_library = dataclasses,typing_extensions
known_third_party = click,log
known_first_party = log

combine_as_imports = true
force_grid_wrap = false
include_trailing_comma = true
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Expand Up @@ -78,7 +78,7 @@ $ make run
Launch an IPython session:

```text
$ make ipython
$ make shell
```

# Release Tasks
Expand Down
66 changes: 32 additions & 34 deletions Makefile
@@ -1,34 +1,24 @@
# Project settings
PROJECT := minilog
PACKAGE := log
REPOSITORY := jacebrowning/minilog

# Project paths
PACKAGES := $(PACKAGE) tests
CONFIG := $(wildcard *.py)
MODULES := $(wildcard $(PACKAGE)/*.py)

# Virtual environment paths
VIRTUAL_ENV ?= .venv

# MAIN TASKS ##################################################################

.PHONY: all
all: install

.PHONY: ci
ci: format check test-repeat mkdocs ## Run all tasks that determine CI status
ci: format check test mkdocs ## Run all tasks that determine CI status

.PHONY: watch
watch: install .clean-test ## Continuously run all CI tasks when files chanage
poetry run sniffer

.PHONY: run ## Start the program
run: install
.PHONY: run
run: install ## Start the program
poetry run python $(PACKAGE)/__main__.py

.PHONY: ipython ## Launch an IPython session
ipython: install
.PHONY: shell
shell: install ## Launch an IPython session
poetry run ipython --ipython-dir=notebooks

# SYSTEM DEPENDENCIES #########################################################
Expand All @@ -39,19 +29,21 @@ doctor: ## Confirm system dependencies are available

# PROJECT DEPENDENCIES ########################################################

VIRTUAL_ENV ?= .venv
DEPENDENCIES := $(VIRTUAL_ENV)/.poetry-$(shell bin/checksum pyproject.toml poetry.lock)

.PHONY: install
install: $(DEPENDENCIES) .cache

$(DEPENDENCIES): poetry.lock
@ rm -rf $(VIRTUAL_ENV)/.poetry-*
@ poetry config virtualenvs.in-project true
poetry install
@ touch $@

ifndef CI
poetry.lock: pyproject.toml
poetry lock
poetry lock --no-update
@ touch $@
endif

Expand All @@ -62,18 +54,18 @@ endif

.PHONY: format
format: install
poetry run isort $(PACKAGES) notebooks
poetry run black $(PACKAGES) notebooks
poetry run isort $(PACKAGE) tests notebooks
poetry run black $(PACKAGE) tests notebooks
@ echo

.PHONY: check
check: install format ## Run formaters, linters, and static analysis
ifdef CI
git diff --exit-code
endif
poetry run mypy $(PACKAGES) --config-file=.mypy.ini
poetry run pylint $(PACKAGES) --rcfile=.pylint.ini
poetry run pydocstyle $(PACKAGES) $(CONFIG)
poetry run mypy $(PACKAGE) tests --config-file=.mypy.ini
poetry run pylint $(PACKAGE) tests --rcfile=.pylint.ini
poetry run pydocstyle $(PACKAGE) tests

# TESTS #######################################################################

Expand All @@ -94,25 +86,30 @@ test-unit: install
@ ( mv $(FAILURES) $(FAILURES).bak || true ) > /dev/null 2>&1
poetry run pytest $(PACKAGE) $(PYTEST_OPTIONS)
@ ( mv $(FAILURES).bak $(FAILURES) || true ) > /dev/null 2>&1
poetry run coveragespace $(REPOSITORY) unit
ifndef DISABLE_COVERAGE
poetry run coveragespace update unit
endif

.PHONY: test-int
test-int: install
@ if test -e $(FAILURES); then poetry run pytest tests $(PYTEST_RERUN_OPTIONS); fi
@ rm -rf $(FAILURES)
poetry run pytest tests $(PYTEST_OPTIONS)
poetry run coveragespace $(REPOSITORY) integration
ifndef DISABLE_COVERAGE
poetry run coveragespace update integration
endif

.PHONY: test-all
test-all: install
@ if test -e $(FAILURES); then poetry run pytest $(PACKAGES) $(PYTEST_RERUN_OPTIONS); fi
@ if test -e $(FAILURES); then poetry run pytest $(PACKAGE) tests $(PYTEST_RERUN_OPTIONS); fi
@ rm -rf $(FAILURES)
poetry run pytest $(PACKAGES) $(PYTEST_OPTIONS)
poetry run coveragespace $(REPOSITORY) overall
poetry run pytest $(PACKAGE) tests $(PYTEST_OPTIONS)
ifndef DISABLE_COVERAGE
poetry run coveragespace update overall
endif

.PHONY: test-repeat
test-repeat: install
@ rm -rf $(FAILURES)
poetry run pytest $(PACKAGES) $(PYTEST_OPTIONS) --count=5 --exitfirst

.PHONY: test-profile
Expand All @@ -134,6 +131,7 @@ docs: mkdocs uml ## Generate documentation and UML
mkdocs: install $(MKDOCS_INDEX)
$(MKDOCS_INDEX): docs/requirements.txt mkdocs.yml docs/*.md
@ mkdir -p docs/about
@ cd docs && ln -sf ../README.md index.md
@ cd docs/about && ln -sf ../../CHANGELOG.md changelog.md
@ cd docs/about && ln -sf ../../CONTRIBUTING.md contributing.md
@ cd docs/about && ln -sf ../../LICENSE.md license.md
Expand All @@ -158,7 +156,7 @@ mkdocs-serve: mkdocs
# BUILD #######################################################################

DIST_FILES := dist/*.tar.gz dist/*.whl
EXE_FILES := dist/$(PROJECT).*
EXE_FILES := dist/$(PACKAGE).*

.PHONY: dist
dist: install $(DIST_FILES)
Expand All @@ -168,20 +166,20 @@ $(DIST_FILES): $(MODULES) pyproject.toml

.PHONY: exe
exe: install $(EXE_FILES)
$(EXE_FILES): $(MODULES) $(PROJECT).spec
$(EXE_FILES): $(MODULES) $(PACKAGE).spec
# For framework/shared support: https://github.com/yyuu/pyenv/wiki
poetry run pyinstaller $(PROJECT).spec --noconfirm --clean
poetry run pyinstaller $(PACKAGE).spec --noconfirm --clean

$(PROJECT).spec:
poetry run pyi-makespec $(PACKAGE)/__main__.py --onefile --windowed --name=$(PROJECT)
$(PACKAGE).spec:
poetry run pyi-makespec $(PACKAGE)/__main__.py --onefile --windowed --name=$(PACKAGE)

# RELEASE #####################################################################

.PHONY: upload
upload: dist ## Upload the current version to PyPI
git diff --name-only --exit-code
poetry publish
bin/open https://pypi.org/project/$(PROJECT)
bin/open https://pypi.org/project/$(PACKAGE)

# CLEANUP #####################################################################

Expand All @@ -194,7 +192,7 @@ clean-all: clean

.PHONY: .clean-install
.clean-install:
find $(PACKAGES) -name '__pycache__' -delete
find $(PACKAGE) tests -name '__pycache__' -delete
rm -rf *.egg-info

.PHONY: .clean-test
Expand Down
2 changes: 0 additions & 2 deletions bin/update
Expand Up @@ -48,7 +48,6 @@ def run():

def copy():
for filename in [
'.appveyor.yml',
'.coveragerc',
'.gitattributes',
'.gitignore',
Expand All @@ -57,7 +56,6 @@ def copy():
'.pydocstyle.ini',
'.pylint.ini',
'.scrutinizer.yml',
'.travis.yml',
'.verchew.ini',
'CONTRIBUTING.md',
'Makefile',
Expand Down

0 comments on commit 012425c

Please sign in to comment.