mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Update Makefile (#2147)
* Problem: it's difficult to run/test/compile docs Solution: we already have a nice Makefile, but it's outdated. The idea is to revamp it and make it easy to use. * Problem: Makefile is not documented Solution: Add basic instructions on how to use it in the main README.md * Problem: can't connect to localhost:9984 Solution: make docker expose 9984 by default, so everyone can connect to localhost:9984. * Problem: make clean is TMI Solution: add `@` to remove commands so we don't output all the details about the cleaning * Problem: make clean is too shy Solution: print a message saying that cleaning went well.
This commit is contained in:
parent
5676a6e088
commit
7a718f78d2
124
Makefile
124
Makefile
@ -1,5 +1,11 @@
|
||||
.PHONY: clean clean-test clean-pyc clean-build docs help
|
||||
.PHONY: check-deps help run test test-all coverage clean clean-build clean-pyc clean-test docs servedocs release dist install
|
||||
|
||||
.DEFAULT_GOAL := help
|
||||
|
||||
|
||||
#############################
|
||||
# Open a URL in the browser #
|
||||
#############################
|
||||
define BROWSER_PYSCRIPT
|
||||
import os, webbrowser, sys
|
||||
try:
|
||||
@ -11,72 +17,102 @@ webbrowser.open("file://" + pathname2url(os.path.abspath(sys.argv[1])))
|
||||
endef
|
||||
export BROWSER_PYSCRIPT
|
||||
|
||||
|
||||
##################################
|
||||
# Display help for this makefile #
|
||||
##################################
|
||||
define PRINT_HELP_PYSCRIPT
|
||||
import re, sys
|
||||
|
||||
print("BigchainDB 2.0 developer toolbox")
|
||||
print("--------------------------------")
|
||||
print("Usage: make COMMAND")
|
||||
print("")
|
||||
print("Commands:")
|
||||
for line in sys.stdin:
|
||||
match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line)
|
||||
if match:
|
||||
target, help = match.groups()
|
||||
print("%-20s %s" % (target, help))
|
||||
print(" %-16s %s" % (target, help))
|
||||
endef
|
||||
export PRINT_HELP_PYSCRIPT
|
||||
|
||||
##################
|
||||
# Basic commands #
|
||||
##################
|
||||
DOCKER := docker
|
||||
DC := docker-compose
|
||||
BROWSER := python -c "$$BROWSER_PYSCRIPT"
|
||||
HELP := python -c "$$PRINT_HELP_PYSCRIPT"
|
||||
ECHO := /usr/bin/env echo
|
||||
|
||||
help:
|
||||
@python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)
|
||||
IS_DOCKER_COMPOSE_INSTALLED := $(shell command -v docker-compose 2> /dev/null)
|
||||
|
||||
clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts
|
||||
################
|
||||
# Main targets #
|
||||
################
|
||||
|
||||
help: ## Show this help
|
||||
@$(HELP) < $(MAKEFILE_LIST)
|
||||
|
||||
clean-build: ## remove build artifacts
|
||||
rm -fr build/
|
||||
rm -fr dist/
|
||||
rm -fr .eggs/
|
||||
find . -name '*.egg-info' -exec rm -fr {} +
|
||||
find . -name '*.egg' -exec rm -f {} +
|
||||
run: check-deps ## Run BigchainDB from source (stop it with ctrl+c)
|
||||
@$(DC) up bigchaindb
|
||||
|
||||
clean-pyc: ## remove Python file artifacts
|
||||
find . -name '*.pyc' -exec rm -f {} +
|
||||
find . -name '*.pyo' -exec rm -f {} +
|
||||
find . -name '*~' -exec rm -f {} +
|
||||
find . -name '__pycache__' -exec rm -fr {} +
|
||||
start: check-deps ## Run BigchainDB from source and daemonize it (stop with `make stop`)
|
||||
@$(DC) up -d bigchaindb
|
||||
|
||||
clean-test: ## remove test and coverage artifacts
|
||||
rm -fr .tox/
|
||||
rm -f .coverage
|
||||
rm -fr htmlcov/
|
||||
stop: check-deps ## Stop BigchainDB
|
||||
@$(DC) stop
|
||||
|
||||
lint: ## check style with flake8
|
||||
flake8 bigchaindb tests
|
||||
logs: check-deps ## Attach to the logs
|
||||
@$(DC) logs -f bigchaindb
|
||||
|
||||
test: ## run tests quickly with the default Python
|
||||
pytest -v -n auto
|
||||
test: check-deps ## Run all tests once
|
||||
@$(DC) run --rm bigchaindb pytest -v
|
||||
|
||||
test-all: ## run tests on every Python version with tox
|
||||
tox
|
||||
test-watch: check-deps ## Run all tests and wait. Every time you change code, tests will be run again
|
||||
@$(DC) run --rm bigchaindb pytest -f -v
|
||||
|
||||
coverage: ## check code coverage quickly with the default Python
|
||||
pytest -v -n auto --database-backend=localmongodb --cov=bigchaindb --cov-report term --cov-report html
|
||||
cov: check-deps ## Check code coverage and open the result in the browser
|
||||
@$(DC) run --rm bigchaindb pytest -v --cov=bigchaindb --cov-report html
|
||||
$(BROWSER) htmlcov/index.html
|
||||
|
||||
docs: ## generate Sphinx HTML documentation, including API docs
|
||||
$(MAKE) -C docs/root clean
|
||||
$(MAKE) -C docs/root html
|
||||
$(MAKE) -C docs/server clean
|
||||
$(MAKE) -C docs/server html
|
||||
$(BROWSER) docs/root/_build/html/index.html
|
||||
doc: ## Generate HTML documentation and open it in the browser
|
||||
@$(DC) run --rm --no-deps bdocs make -C docs/root html
|
||||
@$(DC) run --rm --no-deps bdocs make -C docs/server html
|
||||
$(BROWSER) docs/root/build/html/index.html
|
||||
|
||||
servedocs: docs ## compile the docs watching for changes
|
||||
watchmedo shell-command -p '*.rst' -c '$(MAKE) -C docs html' -R -D .
|
||||
clean: clean-build clean-pyc clean-test ## Remove all build, test, coverage and Python artifacts
|
||||
@$(ECHO) "Cleaning was successful."
|
||||
|
||||
release: dist ## package and upload a release
|
||||
twine upload dist/*
|
||||
###############
|
||||
# Sub targets #
|
||||
###############
|
||||
|
||||
dist: clean ## builds source (and not for now, wheel package)
|
||||
python setup.py sdist
|
||||
# python setup.py bdist_wheel
|
||||
ls -l dist
|
||||
check-deps:
|
||||
ifndef IS_DOCKER_COMPOSE_INSTALLED
|
||||
@$(ECHO) "Error: docker-compose is not installed"
|
||||
@$(ECHO)
|
||||
@$(ECHO) "You need docker-compose to run this command. Check out the official docs on how to install it in your system:"
|
||||
@$(ECHO) "- https://docs.docker.com/compose/install/"
|
||||
@$(ECHO)
|
||||
@$(DC) # docker-compose is not installed, so we call it to generate an error and exit
|
||||
endif
|
||||
|
||||
install: clean ## install the package to the active Python's site-packages
|
||||
python setup.py install
|
||||
clean-build: # Remove build artifacts
|
||||
@rm -fr build/
|
||||
@rm -fr dist/
|
||||
@rm -fr .eggs/
|
||||
@find . -name '*.egg-info' -exec rm -fr {} +
|
||||
@find . -name '*.egg' -exec rm -f {} +
|
||||
|
||||
clean-pyc: # Remove Python file artifacts
|
||||
@find . -name '*.pyc' -exec rm -f {} +
|
||||
@find . -name '*.pyo' -exec rm -f {} +
|
||||
@find . -name '*~' -exec rm -f {} +
|
||||
@find . -name '__pycache__' -exec rm -fr {} +
|
||||
|
||||
clean-test: # Remove test and coverage artifacts
|
||||
@rm -fr .tox/
|
||||
@rm -f .coverage
|
||||
@rm -fr htmlcov/
|
||||
|
23
README.md
23
README.md
@ -10,6 +10,29 @@
|
||||
|
||||
BigchainDB is a blockchain database.
|
||||
|
||||
## Run and test BigchainDB from the `master` branch
|
||||
Running and testing the latest version of BigchainDB is easy. Make sure you have a recent version of [Docker Compose installed](https://docs.docker.com/compose/install/) in your host.
|
||||
|
||||
Whenever you are ready, fire up a terminal and run:
|
||||
```
|
||||
git clone https://github.com/bigchaindb/bigchaindb.git
|
||||
cd bigchaindb
|
||||
make run
|
||||
```
|
||||
|
||||
To know the IP of the instance running, execute in a new terminal `make ip`.
|
||||
|
||||
There are also other commands you can execute:
|
||||
- `make start`: Run BigchainDB from source and daemonize it (stop it with `make stop`).
|
||||
- `make stop`: Stop BigchainDB.
|
||||
- `make logs`: Attach to the logs.
|
||||
- `make test`: Run all tests.
|
||||
- `make test-watch`: Run all tests and wait. Every time you change code, tests will be run again.
|
||||
- `make cov`: Check code coverage and open the result in the browser.
|
||||
- `make doc`: Generate HTML documentation and open it in the browser.
|
||||
|
||||
To view all commands available, run `make`.
|
||||
|
||||
## Get Started with BigchainDB Server
|
||||
|
||||
### [Quickstart](https://docs.bigchaindb.com/projects/server/en/latest/quickstart.html)
|
||||
|
@ -21,6 +21,7 @@ services:
|
||||
- ./bigchaindb:/usr/src/app/bigchaindb
|
||||
- ./tests:/usr/src/app/tests
|
||||
- ./docs:/usr/src/app/docs
|
||||
- ./htmlcov:/usr/src/app/htmlcov
|
||||
- ./setup.py:/usr/src/app/setup.py
|
||||
- ./setup.cfg:/usr/src/app/setup.cfg
|
||||
- ./pytest.ini:/usr/src/app/pytest.ini
|
||||
@ -34,15 +35,15 @@ services:
|
||||
BIGCHAINDB_TENDERMINT_HOST: tendermint
|
||||
BIGCHAINDB_TENDERMINT_PORT: 46657
|
||||
ports:
|
||||
- "9984"
|
||||
- "9985"
|
||||
- "9984:9984"
|
||||
- "9985:9985"
|
||||
- "46658"
|
||||
healthcheck:
|
||||
test: ["CMD", "bash", "-c", "curl http://bigchaindb:9984 && curl http://tendermint:46657/abci_query"]
|
||||
interval: 3s
|
||||
timeout: 5s
|
||||
retries: 3
|
||||
command: bigchaindb -l DEBUG start
|
||||
command: bigchaindb start
|
||||
tendermint:
|
||||
image: tendermint/tendermint:0.12
|
||||
volumes:
|
||||
|
Loading…
x
Reference in New Issue
Block a user