-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
130 lines (104 loc) · 3.81 KB
/
Makefile
File metadata and controls
130 lines (104 loc) · 3.81 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
### Defensive settings for make:
# https://tech.davis-hansson.com/p/make/
SHELL:=bash
.ONESHELL:
.SHELLFLAGS:=-xeu -o pipefail -O inherit_errexit -c
.SILENT:
.DELETE_ON_ERROR:
MAKEFLAGS+=--warn-undefined-variables
MAKEFLAGS+=--no-builtin-rules
# We like colors
# From: https://coderwall.com/p/izxssa/colored-makefile-for-golang-projects
RED=`tput setaf 1`
GREEN=`tput setaf 2`
RESET=`tput sgr0`
YELLOW=`tput setaf 3`
PLONE5=5.2-latest
PLONE6=6.0-latest
ifndef LOG_LEVEL
LOG_LEVEL=INFO
endif
CODE_QUALITY_VERSION=2.0.0
CURRENT_USER=$$(whoami)
USER_INFO=$$(id -u ${CURRENT_USER}):$$(getent group ${CURRENT_USER}|cut -d: -f3)
BASE_FOLDER=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
LINT=docker run -e LOG_LEVEL="${LOG_LEVEL}" --rm -v "${BASE_FOLDER}":/github/workspace plone/code-quality:${CODE_QUALITY_VERSION} check
FORMAT=docker run --user="${USER_INFO}" -e LOG_LEVEL="${LOG_LEVEL}" --rm -v "${BASE_FOLDER}":/github/workspace plone/code-quality:${CODE_QUALITY_VERSION} format
PACKAGE_NAME=kitconcept.api
PACKAGE_PATH=src/
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)==> Setup Virtual Env$(RESET)"
python3 -m venv .
bin/pip install -U pip wheel
.PHONY: build-plone-5.2
build-plone-5.2: bin/pip bin/black ## Build Plone 5.2
@echo "$(GREEN)==> Build with Plone 5.2$(RESET)"
bin/pip install Plone plone.app.testing -c https://dist.plone.org/release/$(PLONE5)/constraints.txt
bin/pip install -e ".[test]"
bin/mkwsgiinstance -d . -u admin:admin
.PHONY: build-plone-6.0
build-plone-6.0: bin/pip bin/black ## Build Plone 6.0
@echo "$(GREEN)==> Build with Plone 6.0$(RESET)"
bin/pip install Plone plone.app.testing -c https://dist.plone.org/release/$(PLONE6)/constraints.txt
bin/pip install -e ".[test]"
bin/mkwsgiinstance -d . -u admin:admin
.PHONY: build
build: build-plone-6.0 ## Build Plone 6.0
.PHONY: clean
clean: ## Remove old virtualenv and creates a new one
@echo "$(RED)==> Cleaning environment and build$(RESET)"
rm -rf bin lib lib64 include share etc var inituser pyvenv.cfg .installed.cfg
.PHONY: format
format: ## Format the codebase according to our standards
@echo "$(GREEN)==> Format codebase$(RESET)"
$(FORMAT)
.PHONY: format-black
format-black: ## Format the codebase with black
@echo "$(GREEN)==> Format codebase with black$(RESET)"
$(FORMAT) black ${CODEPATH}
.PHONY: format-isort
format-isort: ## Format the codebase with isort
@echo "$(GREEN)==> Format codebase with isort$(RESET)"
$(FORMAT) isort ${CODEPATH}
.PHONY: format-zpretty
format-zpretty: ## Format the codebase with zpretty
@echo "$(GREEN)==> Format codebase with zpretty$(RESET)"
$(FORMAT) zpretty ${CODEPATH}
.PHONY: lint
lint: ## check code style
$(LINT)
.PHONY: lint-black
lint-black: ## validate black formating
$(LINT) black ${CODEPATH}
.PHONY: lint-flake8
lint-flake8: ## validate black formating
$(LINT) flake8 ${CODEPATH}
.PHONY: lint-isort
lint-isort: ## validate using isort
$(LINT) isort ${CODEPATH}
.PHONY: lint-pyroma
lint-pyroma: ## validate using pyroma
$(LINT) pyroma ${CODEPATH}
.PHONY: lint-zpretty
lint-zpretty: ## validate ZCML/XML using zpretty
$(LINT) zpretty ${CODEPATH}
# i18n
bin/i18ndude: bin/pip
@echo "$(GREEN)==> Install translation tools$(RESET)"
bin/pip install i18ndude
.PHONY: i18n
i18n: bin/i18ndude ## Update locales
@echo "$(GREEN)==> Updating locales$(RESET)"
bin/update_locale
.PHONY: test
test: ## run tests
PYTHONWARNINGS=ignore ./bin/zope-testrunner --auto-color --auto-progress --test-path $(PACKAGE_PATH)
.PHONY: start
start: ## Start a Plone instance on localhost:8080
PYTHONWARNINGS=ignore ./bin/runwsgi etc/zope.ini