Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
275 lines (227 loc) · 9.03 KB
/
Copy pathMakefile
File metadata and controls
275 lines (227 loc) · 9.03 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
### 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
CURRENT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
GIT_FOLDER=$(CURRENT_DIR)/.git
# repoplone needs Python 3.11 or later, and calls uv itself. Drop UV_PYTHON,
# the version under test in CI, so it decides neither the Python that runs
# repoplone nor the environment its uv looks for.
REPOSITORY_SETTINGS := $(shell env -u UV_PYTHON uvx --python 3.12 repoplone settings dump)
PROJECT_NAME=$(shell echo '$(REPOSITORY_SETTINGS)' | jq -r '.name')
STACK_NAME=${PROJECT_NAME}
IMAGE_NAME_PREFIX := $(shell echo '$(REPOSITORY_SETTINGS)' | jq -r '.container_images_prefix')
IMAGE_NAME_SEPARATOR := -
IMAGE_NAME_PREFIX_WITH_SEPARATOR := $(IMAGE_NAME_PREFIX)$(IMAGE_NAME_SEPARATOR)
# Environment variables to be exported
export VOLTO_VERSION := $(shell echo '$(REPOSITORY_SETTINGS)' | jq -r '.frontend.volto_version')
export PLONE_VERSION := $(shell echo '$(REPOSITORY_SETTINGS)' | jq -r '.backend.base_package_version')
# 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`
.PHONY: all
all: install
# 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}'
.PHONY: debug-settings
debug-settings: ## Debug settings
@echo "Debug settings"
@echo "PROJECT_NAME: $(PROJECT_NAME)"
@echo "VOLTO_VERSION: $(VOLTO_VERSION)"
@echo "PLONE_VERSION: $(PLONE_VERSION)"
@echo "IMAGE_NAME_PREFIX: $(IMAGE_NAME_PREFIX)"
@echo "IMAGE_NAME_PREFIX_WITH_SEPARATOR: $(IMAGE_NAME_PREFIX_WITH_SEPARATOR)"
###########################################
# Docs
###########################################
.PHONY: docs-install
docs-install: ## Install the documentation toolchain
@echo "$(GREEN)==> Install documentation requirements$(RESET)"
$(MAKE) -C "./docs/" install
.PHONY: docs-build
docs-build: ## Build the documentation, warnings as errors
$(MAKE) -C "./docs/" html SPHINXOPTS="-W"
.PHONY: docs-livehtml
docs-livehtml: ## Build the documentation with live-reload in the browser
$(MAKE) -C "./docs/" livehtml
.PHONY: docs-clean
docs-clean: ## Remove the documentation build
$(MAKE) -C "./docs/" clean
###########################################
# Frontend
###########################################
.PHONY: frontend-install
frontend-install: ## Install React Frontend
$(MAKE) -C "./frontend/" install
.PHONY: frontend-build
frontend-build: ## Build React Frontend
$(MAKE) -C "./frontend/" build
.PHONY: frontend-start
frontend-start: ## Start React Frontend
$(MAKE) -C "./frontend/" start
.PHONY: frontend-test
frontend-test: ## Test frontend codebase
@echo "Test frontend"
$(MAKE) -C "./frontend/" test
###########################################
# Backend
###########################################
.PHONY: backend-install
backend-install: ## Create virtualenv and install Plone
$(MAKE) -C "./backend/" install
$(MAKE) backend-create-site
.PHONY: backend-build
backend-build: ## Build Backend
$(MAKE) -C "./backend/" install
.PHONY: backend-create-site
backend-create-site: ## Create a Plone site with default content
$(MAKE) -C "./backend/" create-site
.PHONY: backend-update-example-content
backend-update-example-content: ## Export example content inside package
$(MAKE) -C "./backend/" update-example-content
.PHONY: backend-start
backend-start: ## Start Plone Backend
$(MAKE) -C "./backend/" start
.PHONY: backend-test
backend-test: ## Test backend codebase
@echo "Test backend"
$(MAKE) -C "./backend/" test
###########################################
# Environment
###########################################
.PHONY: install
install: ## Install
@echo "Install Backend & Frontend"
$(MAKE) backend-install
$(MAKE) frontend-install
.PHONY: clean
clean: ## Clean installation
@echo "Clean installation"
$(MAKE) -C "./backend/" clean
$(MAKE) -C "./frontend/" clean
###########################################
# QA
###########################################
.PHONY: format
format: ## Format codebase
@echo "Format the codebase"
$(MAKE) -C "./backend/" format
$(MAKE) -C "./frontend/" format
.PHONY: lint
lint: ## Format codebase
@echo "Lint the codebase"
$(MAKE) -C "./backend/" lint
$(MAKE) -C "./frontend/" lint
.PHONY: check
check: format lint ## Lint and Format codebase
###########################################
# i18n
###########################################
.PHONY: i18n
i18n: ## Update locales
@echo "Update locales"
$(MAKE) -C "./backend/" i18n
$(MAKE) -C "./frontend/" i18n
###########################################
# Testing
###########################################
.PHONY: test
test: backend-test frontend-test ## Test codebase
###########################################
# Container images
###########################################
.PHONY: build-images
build-images: ## Build container images
@echo "Build"
$(MAKE) -C "./backend/" build-image
$(MAKE) -C "./frontend/" build-image
###########################################
# Local Stack
###########################################
.PHONY: stack-create-site
stack-create-site: ## Local Stack: Create a new site
@echo "Create a new site in the local Docker stack"
@echo "(Stack must not be running already.)"
@docker compose -f docker-compose.yml run --build backend ./docker-entrypoint.sh create-site
.PHONY: stack-start
stack-start: ## Local Stack: Start Services
@echo "Start local Docker stack"
@docker compose -f docker-compose.yml up -d --build
@echo "Now visit: http://$(PROJECT_NAME).localhost"
.PHONY: stack-status
stack-status: ## Local Stack: Check Status
@echo "Check the status of the local Docker stack"
@docker compose -f docker-compose.yml ps
.PHONY: stack-stop
stack-stop: ## Local Stack: Stop Services
@echo "Stop local Docker stack"
@docker compose -f docker-compose.yml stop
.PHONY: stack-rm
stack-rm: ## Local Stack: Remove Services and Volumes
@echo "Remove local Docker stack"
@docker compose -f docker-compose.yml down
@echo "Remove local volume data"
@docker volume rm $(PROJECT_NAME)_vol-site-data
###########################################
# Acceptance
###########################################
.PHONY: acceptance-backend-start
acceptance-backend-start:
@echo "Start acceptance backend"
$(MAKE) -C "./backend/" acceptance-backend-start
.PHONY: acceptance-frontend-dev-start
acceptance-frontend-dev-start:
@echo "Start acceptance frontend"
$(MAKE) -C "./frontend/" acceptance-frontend-dev-start
.PHONY: acceptance-test
acceptance-test:
@echo "Start acceptance tests in interactive mode"
$(MAKE) -C "./frontend/" acceptance-test
# Build Docker images
.PHONY: acceptance-frontend-image-build
acceptance-frontend-image-build:
@echo "Build acceptance frontend image"
@docker build frontend -t $(IMAGE_NAME_PREFIX_WITH_SEPARATOR)frontend:acceptance -f frontend/Dockerfile --build-arg VOLTO_VERSION=$(VOLTO_VERSION)
.PHONY: acceptance-backend-image-build
acceptance-backend-image-build:
@echo "Build acceptance backend image"
@docker build backend -t $(IMAGE_NAME_PREFIX_WITH_SEPARATOR)backend:acceptance -f backend/Dockerfile.acceptance --build-arg PLONE_VERSION=$(PLONE_VERSION)
.PHONY: acceptance-images-build
acceptance-images-build: ## Build Acceptance frontend/backend images
$(MAKE) acceptance-backend-image-build
$(MAKE) acceptance-frontend-image-build
.PHONY: acceptance-frontend-container-start
acceptance-frontend-container-start:
@echo "Start acceptance frontend"
@docker run --rm -p 3000:3000 --name $(IMAGE_NAME_PREFIX_WITH_SEPARATOR)frontend-acceptance --link $(IMAGE_NAME_PREFIX_WITH_SEPARATOR)backend-acceptance:backend -e RAZZLE_API_PATH=http://localhost:55001/plone -e RAZZLE_INTERNAL_API_PATH=http://backend:55001/plone -d $(IMAGE_NAME_PREFIX_WITH_SEPARATOR)frontend:acceptance
.PHONY: acceptance-backend-container-start
acceptance-backend-container-start:
@echo "Start acceptance backend"
@docker run --rm -p 55001:55001 --name $(IMAGE_NAME_PREFIX_WITH_SEPARATOR)backend-acceptance -d $(IMAGE_NAME_PREFIX_WITH_SEPARATOR)backend:acceptance
.PHONY: acceptance-containers-start
acceptance-containers-start: ## Start Acceptance containers
$(MAKE) acceptance-backend-container-start
$(MAKE) acceptance-frontend-container-start
.PHONY: acceptance-containers-stop
acceptance-containers-stop: ## Stop Acceptance containers
@echo "Stop acceptance containers"
@docker stop $(IMAGE_NAME_PREFIX_WITH_SEPARATOR)frontend-acceptance
@docker stop $(IMAGE_NAME_PREFIX_WITH_SEPARATOR)backend-acceptance
.PHONY: ci-acceptance-test
ci-acceptance-test:
@echo "Run acceptance tests in CI mode"
$(MAKE) acceptance-containers-start
pnpm dlx wait-on --httpTimeout 20000 http-get://localhost:55001/plone http://localhost:3000
$(MAKE) -C "./frontend/" ci-acceptance-test
$(MAKE) acceptance-containers-stop