-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
119 lines (93 loc) · 3.54 KB
/
Makefile
File metadata and controls
119 lines (93 loc) · 3.54 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
### 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`
# Python checks
UV?=uv
# installed?
ifeq (, $(shell which $(UV) ))
$(error "UV=$(UV) not found in $(PATH)")
endif
PLONE_SITE_ID=Plone
BACKEND_FOLDER=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
ifdef PLONE_VERSION
PLONE_VERSION := $(PLONE_VERSION)
else
PLONE_VERSION := 6.1-dev
endif
GIT_FOLDER=$(BACKEND_FOLDER)/.git
VENV_FOLDER=$(BACKEND_FOLDER)/.venv
BIN_FOLDER=$(VENV_FOLDER)/bin
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}'
requirements-mxdev.txt: ## Generate constraints file
@echo "$(GREEN)==> Generate constraints file$(RESET)"
@echo '-c https://dist.plone.org/release/$(PLONE_VERSION)/constraints.txt' > requirements.txt
@uvx mxdev -c mx.ini
$(BIN_FOLDER)/runwsgi: requirements-mxdev.txt ## Install dependencies
@echo "$(GREEN)==> Install environment$(RESET)"
@uv venv $(VENV_FOLDER)
@uv pip install --requirement requirements-mxdev.txt
$(BIN_FOLDER)/ruff: $(BIN_FOLDER)/runwsgi
$(BIN_FOLDER)/pytest: $(BIN_FOLDER)/runwsgi
instance/etc/zope.ini: ## Create instance configuration
@echo "$(GREEN)==> Create instance configuration$(RESET)"
@uvx cookiecutter -f --no-input --config-file instance.yaml gh:plone/cookiecutter-zope-instance
.PHONY: config
config: instance/etc/zope.ini
.PHONY: install
install: $(BIN_FOLDER)/runwsgi config ## Install Plone development instance
.PHONY: clean
clean: ## Clean environment
@echo "$(RED)==> Cleaning environment and build$(RESET)"
rm -rf $(VENV_FOLDER) .python-version .venv .ruff_cache .pytest_cache requirements.txt requirements-mxdev.txt constraints-mxdev.txt uv.lock instance
.PHONY: start
start: ## Start a Plone instance on localhost:8080
PYTHONWARNINGS=ignore uv run runwsgi instance/etc/zope.ini
.PHONY: console
console: instance/etc/zope.ini ## Start a console into a Plone instance
PYTHONWARNINGS=ignore uv run zconsole debug instance/etc/zope.conf
.PHONY: lint-zpretty
lint-zpretty: ## Check and fix zcml and xml files
@find src -name '*.xml'|xargs uvx zpretty@latest -x --check
@find src -name '*.zcml'|xargs uvx zpretty@latest -z --check
.PHONY: lint
lint: $(BIN_FOLDER)/ruff ## Check and fix code base according to Plone standards
@echo "$(GREEN)==> Lint codebase$(RESET)"
@uvx ruff@latest check --fix
@make lint-zpretty
@uvx mypy@latest src
@uvx pyroma@latest -d .
@uvx check-python-versions@latest .
.PHONY: format-zpretty
format-zpretty: ## Check and fix zcml and xml files
@find src -name '*.xml'|xargs uvx zpretty@latest -x -i
@find src -name '*.zcml'|xargs uvx zpretty@latest -z -i
.PHONY: format
format: $(BIN_FOLDER)/ruff ## Check and fix code base according to Plone standards
@echo "$(GREEN)==> Format codebase$(RESET)"
@uvx ruff@latest check --select I --fix
@uvx ruff@latest format
@make format-zpretty
# Tests
.PHONY: test
test: $(BIN_FOLDER)/pytest ## run tests
@uv run pytest
.PHONY: test-cov
test-cov: $(BIN_FOLDER)/pytest ## run tests
@uv run pytest --cov=sc.sentry --cov-report term-missing