-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
175 lines (148 loc) · 4.54 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
# 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 -p bileto -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
ifndef COVERAGE
COVERAGE = --coverage-html ./coverage
endif
ifdef FILE
PHPUNIT_FILE = $(FILE)
else
PHPUNIT_FILE = ./tests
endif
ifdef FILTER
PHPUNIT_FILTER = --filter=$(FILTER)
else
PHPUNIT_FILTER =
endif
.PHONY: docker-start
docker-start: ## Start a development server with Docker
@echo "Running webserver on http://localhost:8000"
$(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: ## Install the dependencies
$(COMPOSER) install
$(NPM) install
.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: ## Migrate the database
$(CONSOLE) doctrine:migrations:migrate --no-interaction
.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
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: ## Run the test suite
$(PHP) ./vendor/bin/phpunit \
-c .phpunit.xml.dist \
--testdox \
$(COVERAGE) \
$(PHPUNIT_FILTER) \
$(PHPUNIT_FILE)
.PHONY: lint
lint: ## Execute the linter (PHPStan and PHP_CodeSniffer)
$(PHP) vendor/bin/phpstan analyse --memory-limit 1G -c .phpstan.neon
$(PHP) vendor/bin/rector process --dry-run --config .rector.php
$(PHP) vendor/bin/phpcs
$(CONSOLE) lint:container
$(CONSOLE) lint:twig
$(CONSOLE) lint:yaml translations/*
$(NPM) run lint-js
$(NPM) run lint-css
.PHONY: lint-fix
lint-fix: ## Fix the errors detected by the linters (PHP_CodeSniffer)
$(PHP) vendor/bin/rector process --config .rector.php
$(PHP) vendor/bin/phpcbf
$(NPM) run lint-js-fix
$(NPM) run lint-css-fix
.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
$(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' --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}'