-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
60 lines (50 loc) · 1.93 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
IMAGE_NAME=plone/code-quality
DOCKERFILE=Dockerfile
ifndef LOG_LEVEL
LOG_LEVEL=INFO
endif
CURRENT_USER=$$(whoami)
USER_INFO=$$(id -u ${CURRENT_USER}):$$(getent group ${CURRENT_USER}|cut -d: -f3)
CODEBASE=docker-entrypoint.py src/setup.py src/plone_code_analysis tests/fixtures/packages/ok tests/package tests/conftest.py
LINT=docker run -e LOG_LEVEL="${LOG_LEVEL}" --rm -v "${PWD}":/github/workspace "${IMAGE_NAME}:latest" check
FORMAT=docker run --user="${USER_INFO}" -e LOG_LEVEL="${LOG_LEVEL}" --rm -v "${PWD}":/github/workspace "${IMAGE_NAME}:latest" format
all: build
# Add the following 'help' target to your Makefile
# And add help text after each target name starting with '\#\#'
.PHONY: help
help: ## This help message
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
bin/pip:
@echo "$(GREEN)==> Create virtualenv"
python3 -m venv .
bin/pip install -U pip
.PHONY: build
build: bin/pip ## Create virtualenv and install dependencies
bin/pip install -r requirements.txt
bin/pip install -r tests/requirements.txt
rm -rf src/build
.PHONY: clean
clean: ## remove virtual environment
rm -fr bin include lib lib64
.PHONY: test
test:
@echo "$(GREEN)==> Run tests $(RESET)"
bin/python -m pytest tests
.PHONY: build-image
build-image: ## Build Docker Image
@echo "Building $(IMAGE_NAME):latest"
@docker build . -t $(IMAGE_NAME):latest -f ${DOCKERFILE}
.PHONY: lint
lint: build-image ## Lint code with existing image
@echo "Linting ${CODEBASE} $(IMAGE_NAME):latest"
$(LINT) black "${CODEBASE}"
$(LINT) flake8 "${CODEBASE}"
$(LINT) isort "${CODEBASE}"
.PHONY: lint-all
lint-all: build-image ## Lint code with existing image using configurations from pyproject.toml
@echo "Linting ${CODEBASE} $(IMAGE_NAME):latest"
$(LINT)
.PHONY: format
format: build-image ## Format code with existing image
@echo "Formatting ${CODEBASE} $(IMAGE_NAME):latest"
$(FORMAT)