Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic setup/cleanup in Makefile. #183

Merged
merged 1 commit into from
Nov 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ celerybeat-schedule
*.sage.py

# Environments
.setup_complete
.env
.venv
env/
Expand Down
36 changes: 31 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,52 @@ help: ## Print this help menu
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | \
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

.PHONY: require
require: ## Check that prerequisites are installed.
@if ! command -v python3 > /dev/null; then \
printf "\033[1m\033[31mERROR\033[0m: python3 not installed\n" >&2 ; \
exit 1; \
fi
@if ! python3 -c "import sys; sys.exit(sys.version_info < (3,6))"; then \
printf "\033[1m\033[31mERROR\033[0m: python 3.6+ required\n" >&2 ; \
exit 1; \
fi
@if ! command -v poetry > /dev/null; then \
printf "\033[1m\033[31mERROR\033[0m: poetry not installed.\n" >&2 ; \
printf "Please install with 'python3 -mpip install --user poetry'\n" >&2 ; \
exit 1; \
fi

.PHONY: setup
setup: ## Set up the local development environment
setup: require .setup_complete ## Set up the local development environment

.setup_complete: poetry.lock ## Internal helper to run the setup.
poetry install
poetry run pre-commit install
touch .setup_complete

.PHONY: test
test: ## Run the tests, but only for current Python version
test: setup ## Run the tests, but only for current Python version
poetry run tox -e py

.PHONY: test-all
test-all: ## Run the tests for all relevant Python version
test-all: setup ## Run the tests for all relevant Python version
poetry run tox

.PHONY: publish
publish: ## Build & publish the new version
publish: setup ## Build & publish the new version
poetry build
poetry publish

.PHONY: format
format: ## Autoformat all files in the repo. WARNING: changes files in-place
format: setup ## Autoformat all files in the repo. WARNING: changes files in-place
poetry run black jedi_language_server tests
poetry run isort jedi_language_server tests
poetry run docformatter --recursive --in-place jedi_language_server tests

.PHONY: clean
clean: ## Remove local development environment
if poetry env list | grep -q Activated; then \
poetry env remove python3; \
fi
rm -f .setup_complete