-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
193 lines (169 loc) · 5.4 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
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
# This file is part of Bileto.
# Copyright 2022-2024 Probesys
# SPDX-License-Identifier: AGPL-3.0-or-later
.DEFAULT_GOAL := help
USER = $(shell id -u):$(shell id -g)
DOCKER_COMPOSE = docker compose -f docker/development/docker-compose.yml
ifdef NO_DOCKER
PHP = php
COMPOSER = composer
CONSOLE = php bin/console
NPM = npm
else
PHP = ./docker/bin/php
COMPOSER = ./docker/bin/composer
CONSOLE = ./docker/bin/console
NPM = ./docker/bin/npm
endif
ifdef DATABASE
DOCKER_COMPOSE_PROFILE = --profile $(DATABASE)
else
DOCKER_COMPOSE_PROFILE = --profile pgsql
endif
.PHONY: docker-start
docker-start: PORT ?= 8000
docker-start: ## Start a development server with Docker (can take a PORT argument)
@echo "Running webserver on http://localhost:$(PORT)"
$(DOCKER_COMPOSE) $(DOCKER_COMPOSE_PROFILE) up
.PHONY: docker-build
docker-build: ## Rebuild Docker containers
$(DOCKER_COMPOSE) build --pull
.PHONY: docker-pull
docker-pull: ## Pull the Docker images from the Docker Hub
$(DOCKER_COMPOSE) pull --ignore-buildable
.PHONY: docker-clean
docker-clean: ## Clean the Docker stuff
$(DOCKER_COMPOSE) --profile pgsql --profile mariadb down -v
.PHONY: docker-image
docker-image: ## Build the Docker image for production (take a VERSION argument)
ifndef VERSION
$(error You need to provide a "VERSION" argument)
endif
docker build \
--pull \
--build-arg VERSION="$(VERSION)" \
--build-arg SOURCE_COMMIT="$(shell git describe --match '' --always --abbrev=42 --dirty)" \
-t ghcr.io/probesys/bileto:$(VERSION) \
-f docker/production/Dockerfile \
.
.PHONY: install
install: INSTALLER ?= all
install: ## Install the dependencies (can take an INSTALLER argument)
ifeq ($(INSTALLER), $(filter $(INSTALLER), all composer))
$(COMPOSER) install
endif
ifeq ($(INSTALLER), $(filter $(INSTALLER), all npm))
$(NPM) install
endif
.PHONY: db-setup
db-setup: ## Setup the database
$(CONSOLE) doctrine:database:create
$(CONSOLE) doctrine:migrations:migrate --no-interaction
ifndef NO_SEED
$(CONSOLE) db:seeds:load
endif
.PHONY: db-migrate
db-migrate: VERSION ?= latest
db-migrate: ## Migrate the database (can take a VERSION argument)
$(CONSOLE) doctrine:migrations:migrate --no-interaction $(VERSION)
.PHONY: db-rollback
db-rollback: ## Rollback the database to the previous version
$(CONSOLE) doctrine:migrations:migrate --no-interaction prev
.PHONY: db-reset
db-reset: ## Reset the database (take a FORCE argument)
ifndef FORCE
$(error Please run the operation with FORCE=true)
endif
ifndef NO_DOCKER
$(DOCKER_COMPOSE) stop worker
endif
$(CONSOLE) doctrine:database:drop --force --if-exists
$(CONSOLE) doctrine:database:create
$(CONSOLE) doctrine:migrations:migrate --no-interaction
$(CONSOLE) cache:clear
ifndef NO_SEED
$(CONSOLE) db:seeds:load
endif
ifndef NO_DOCKER
$(DOCKER_COMPOSE) start worker
endif
.PHONY: translations
translations: ## Update the translations from the code
$(CONSOLE) translation:extract --format=yaml --force --clean en_GB
$(CONSOLE) translation:extract --format=yaml --force --clean fr_FR
# Restore these files as keys are removed from them whereas they should not.
git restore translations/security+intl-icu.* translations/validators+intl-icu.*
.PHONY: migration
migration: ## Generate a database migration from entities changes
$(CONSOLE) make:migration
.PHONY: icons
icons: ## Build the icons asset
$(NPM) run build:icons
.PHONY: test
test: FILE ?= ./tests
ifdef FILTER
test: override FILTER := --filter=$(FILTER)
endif
test: COVERAGE ?= --coverage-html ./coverage
test: ## Run the test suite (can take FILE, FILTER and COVERAGE arguments)
$(PHP) ./vendor/bin/phpunit \
-c .phpunit.xml.dist \
--testdox \
$(COVERAGE) \
$(FILTER) \
$(FILE)
.PHONY: lint
lint: LINTER ?= all
lint: ## Execute the linter (can take a LINTER argument)
ifeq ($(LINTER), $(filter $(LINTER), all phpstan))
$(PHP) vendor/bin/phpstan analyse --memory-limit 1G -v -c .phpstan.neon
endif
ifeq ($(LINTER), $(filter $(LINTER), all rector))
$(PHP) vendor/bin/rector process --dry-run --config .rector.php
endif
ifeq ($(LINTER), $(filter $(LINTER), all phpcs))
$(PHP) vendor/bin/phpcs
endif
ifeq ($(LINTER), $(filter $(LINTER), all symfony))
$(CONSOLE) lint:container
$(CONSOLE) lint:twig
$(CONSOLE) lint:yaml translations/*
endif
ifeq ($(LINTER), $(filter $(LINTER), all js))
$(NPM) run lint-js
endif
ifeq ($(LINTER), $(filter $(LINTER), all css))
$(NPM) run lint-css
endif
.PHONY: lint-fix
lint-fix: ## Fix the errors detected by the linters (can take a LINTER argument)
ifeq ($(LINTER), $(filter $(LINTER), all rector))
$(PHP) vendor/bin/rector process --config .rector.php
endif
ifeq ($(LINTER), $(filter $(LINTER), all phpcs))
$(PHP) vendor/bin/phpcbf
endif
ifeq ($(LINTER), $(filter $(LINTER), all js))
$(NPM) run lint-js-fix
endif
ifeq ($(LINTER), $(filter $(LINTER), all css))
$(NPM) run lint-css-fix
endif
.PHONY: release
release: ## Release a new version (take a VERSION argument)
ifndef VERSION
$(error You need to provide a "VERSION" argument)
endif
echo $(VERSION) > VERSION.txt
rm -rf public/assets
$(NPM) run build
$(EDITOR) CHANGELOG.md
git add .
git commit -m "release: Publish version $(VERSION)"
git tag -a $(VERSION) -m "Release version $(VERSION)"
.PHONY: tree
tree: ## Display the structure of the application
tree -I 'vendor|node_modules|var|coverage|uploads' --dirsfirst -CA
.PHONY: help
help:
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'