-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
151 lines (121 loc) · 4.63 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
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
# Yeoman Volto App development
### Defensive settings for make:
# https://tech.davis-hansson.com/p/make/
SHELL:=bash
.ONESHELL:
.SHELLFLAGS:=-eu -o pipefail -c
.SILENT:
.DELETE_ON_ERROR:
MAKEFLAGS+=--warn-undefined-variables
MAKEFLAGS+=--no-builtin-rules
CURRENT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
# Recipe snippets for reuse
# 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`
PLONE_VERSION=6
VOLTO_VERSION=17.0.0
ADDON_NAME='volto-subnavigation'
ADDON_PATH='volto-subnavigation'
COMPOSE_FILE=dockerfiles/docker-compose.yml
ACCEPTANCE_COMPOSE=acceptance/docker-compose.yml
CMD=CURRENT_DIR=${CURRENT_DIR} ADDON_NAME=${ADDON_NAME} ADDON_PATH=${ADDON_PATH} VOLTO_VERSION=${VOLTO_VERSION} PLONE_VERSION=${PLONE_VERSION} docker compose
DOCKER_COMPOSE=${CMD} -p ${ADDON_PATH} -f ${COMPOSE_FILE}
DEV_COMPOSE=COMPOSE_PROFILES=dev ${DOCKER_COMPOSE}
LIVE_COMPOSE=COMPOSE_PROFILES=dev ${DOCKER_COMPOSE}
ACCEPTANCE=${CMD} -p ${ADDON_PATH}-acceptance -f ${ACCEPTANCE_COMPOSE}
.PHONY: build-backend
build-backend: ## Build
@echo "$(GREEN)==> Build Backend Container $(RESET)"
${DEV_COMPOSE} build backend
.PHONY: start-backend
start-backend: ## Starts Docker backend
@echo "$(GREEN)==> Start Docker-based Plone Backend $(RESET)"
${DEV_COMPOSE} up backend -d
.PHONY: stop-backend
stop-backend: ## Stop Docker backend
@echo "$(GREEN)==> Stop Docker-based Plone Backend $(RESET)"
${DEV_COMPOSE} stop backend
.PHONY: build-live
build-live: ## Build Addon live
@echo "$(GREEN)==> Build Addon development container $(RESET)"
${LIVE_COMPOSE} build addon-live
.PHONY: build-addon
build-addon: ## Build Addon dev
@echo "$(GREEN)==> Build Addon development container $(RESET)"
${DEV_COMPOSE} build addon-dev
.PHONY: start-dev
start-dev: ## Starts Dev container
@echo "$(GREEN)==> Start Addon Development container $(RESET)"
${DEV_COMPOSE} up addon-dev backend
.PHONY: dev
dev: ## Develop the addon
@echo "$(GREEN)==> Start Development Environment $(RESET)"
make build-backend
make start-backend
make build-addon
make start-dev
.PHONY: help
help: ## Show this help.
@echo -e "$$(grep -hE '^\S+:.*##' $(MAKEFILE_LIST) | sed -e 's/:.*##\s*/:/' -e 's/^\(.\+\):\(.*\)/\\x1b[36m\1\\x1b[m:\2/' | column -c2 -t -s :)"
## Setup the local environment
.PHONY: install
install: ## Install the local environment, Cypress, build acceptance containers
yarn
make install-acceptance
# Dev Helpers
.PHONY: i18n
i18n: ## Sync i18n
@echo "$(YELLOW)==> Do not forget to setup the local environment (make install) $(RESET)"
yarn i18n
.PHONY: format
format: ## Format codebase
${DEV_COMPOSE} run --rm addon-dev lint:fix
${DEV_COMPOSE} run --rm addon-dev prettier:fix
${DEV_COMPOSE} run --rm addon-dev stylelint:fix
.PHONY: lint
lint: ## Lint Codebase
${DEV_COMPOSE} run --rm addon-dev lint
${DEV_COMPOSE} run --rm addon-dev prettier
${DEV_COMPOSE} run --rm addon-dev stylelint --allow-empty-input
.PHONY: test
test: ## Run unit tests
${DEV_COMPOSE} run --rm addon-dev test --watchAll
.PHONY: test-ci
test-ci: ## Run unit tests in CI
${DEV_COMPOSE} run -e CI=1 addon-dev test
## Acceptance
.PHONY: install-acceptance
install-acceptance: ## Install Cypress, build acceptance containers
(cd acceptance && yarn)
${ACCEPTANCE} --profile dev --profile prod build
.PHONY: start-test-acceptance-server
start-test-acceptance-server: ## Start acceptance server (for use it in while developing)
${ACCEPTANCE} --profile dev up
.PHONY: start-test-acceptance-server-prod
start-test-acceptance-server-prod: ## Start acceptance server in prod (used by CI)
${ACCEPTANCE} --profile prod up -d
.PHONY: test-acceptance
test-acceptance: ## Start Cypress (for use it while developing)
(cd acceptance && ./node_modules/.bin/cypress open)
.PHONY: test-acceptance-headless
test-acceptance-headless: ## Run cypress tests in CI
(cd acceptance && ./node_modules/.bin/cypress run)
.PHONY: stop-test-acceptance-server
stop-test-acceptance-server: ## Stop acceptance server (for use it while finished developing)
${ACCEPTANCE} --profile dev down
.PHONY: status-test-acceptance-server
status-test-acceptance-server: ## Status of Acceptance Server (for use it while developing)
${ACCEPTANCE} ps
.PHONY: debug-frontend
debug-frontend: ## Run bash in the Frontend container (for debug infrastructure purposes)
${DEV_COMPOSE} run --entrypoint bash addon-dev
.PHONY: pull-backend-image
pull-backend-image: ## Pulls and updates the backend image (for use it while developing)
docker pull ghcr.io/voltosubnavigation:latest
.PHONY: release
release: ## Release a version of the add-on
yarn release