From c7d9662652a48f10afa54f0e938da2ca5599d42b Mon Sep 17 00:00:00 2001 From: Lukas Holecek Date: Oct 25 2019 04:36:17 +0000 Subject: Add Makefile to simplify executing some actions Signed-off-by: Lukas Holecek --- diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..b3a7b19 --- /dev/null +++ b/Makefile @@ -0,0 +1,65 @@ +COMPOSE := docker-compose +BROWSER := xdg-open + +all: help + +help: + @echo 'Usage:' + @echo + @echo ' make up - starts containers in docker-compose environment' + @echo + @echo ' make down - stops containers in docker-compose environment' + @echo + @echo ' make build - builds container images for docker-compose environment' + @echo + @echo ' make recreate - recreates containers for docker-compose environment' + @echo + @echo ' make exec [CMD=".."] - executes command in dev container' + @echo + @echo ' make sudo [CMD=".."] - executes command in dev container under root user' + @echo + @echo ' make pytest [ARGS=".."] - executes pytest with given arguments in dev container' + @echo + @echo ' make flake8 - executes flake8 in dev container' + @echo + @echo ' make pylint - executes pylint in dev container' + @echo + @echo ' make test - alias for "make pytest flake8 pylint"' + @echo + @echo ' make coverage [ARGS=".."] - generates and shows test code coverage' + +up: + $(COMPOSE) up -d + +down: + $(COMPOSE) down + +build: + $(COMPOSE) build + +recreate: + $(COMPOSE) up -d --force-recreate + +# Executes CMD in dev container. +# Usage: make exec CMD="python3 -m pytest -x" +exec: up + $(COMPOSE) exec dev bash -c '$(CMD)' + +sudo: up + $(COMPOSE) exec -u root dev bash -c '$(CMD)' + +test: pytest flake8 pylint + +pytest: + $(MAKE) exec \ + CMD="pip3 install --user -r dev-requirements.txt && COVERAGE_FILE=/home/dev/.coverage python3 -m pytest $(ARGS)" + +flake8: + python -m flake8 + +pylint: + python -m pylint greenwave/ + +coverage: + $(MAKE) pytest ARGS="--cov-config .coveragerc --cov=greenwave --cov-report html:/home/dev/htmlcov $(ARGS)" + $(BROWSER) docker/home/htmlcov/index.html diff --git a/docs/docker-compose.rst b/docs/docker-compose.rst index 9e2ef38..37e861b 100644 --- a/docs/docker-compose.rst +++ b/docs/docker-compose.rst @@ -4,6 +4,8 @@ Docker-compose for Greenwave Quickstart ---------- +**Quick Tip:** Use `make` to run frequent commands mentioned below. + Start local development containers of ResultsDB and WaiverDB using ``docker-compose``. If you want the containers to run in the foreground, omit the ``-d`` flag. If you want to create the containers again (after some code