forked from David-Crty/databasement
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
157 lines (119 loc) · 5.12 KB
/
Copy pathMakefile
File metadata and controls
157 lines (119 loc) · 5.12 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
.PHONY: help install start test test-sequential test-mysql test-postgres test-filter test-filter-mysql test-filter-postgres test-coverage test-coverage-filter backup-test lint-check lint-fix lint migrate migrate-fresh migrate-fresh-seed db-seed setup clean import-db docs docs-build release
# Colors for output
GREEN := \033[0;32m
YELLOW := \033[0;33m
NC := \033[0m # No Color
# Docker / PHP helpers
DOCKER_COMPOSE := docker compose
PHP_SERVICE := app
PHP_EXEC := $(DOCKER_COMPOSE) exec --user application -T $(PHP_SERVICE)
PHP_COMPOSER := $(PHP_EXEC) composer
PHP_ARTISAN := $(PHP_EXEC) php artisan
NPM_EXEC := npm
##@ Help
help: ## Display this help message
@echo "$(GREEN)Available commands:$(NC)"
@awk 'BEGIN {FS = ":.*##"; printf "\n"} /^[a-zA-Z_-]+:.*?##/ { printf " $(YELLOW)%-15s$(NC) %s\n", $$1, $$2 } /^##@/ { printf "\n$(GREEN)%s$(NC)\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
##@ Development
install: ## Install dependencies (composer + npm)
$(PHP_COMPOSER) install
$(NPM_EXEC) install
setup: start install build migrate
docker compose restart app worker
start: ## Start development server (all services: php, queue, mysql, postgres)
docker compose up -d
migrate:
$(PHP_ARTISAN) migrate
logs:
$(DOCKER_COMPOSE) logs -f php
create-bucket: ## Create S3 bucket in rustfs (usage: make create-bucket BUCKET=my-bucket)
docker run --rm --network=$$(docker network ls --filter name=databasement -q | head -1) \
-e AWS_ACCESS_KEY_ID=rustfsadmin \
-e AWS_SECRET_ACCESS_KEY=rustfsadmin \
amazon/aws-cli \
--endpoint-url=http://rustfs:9000 \
s3 mb s3://$(or $(BUCKET),test-bucket) 2>/dev/null || true
##@ Testing
test: ## Run all tests in parallel (default)
$(PHP_ARTISAN) test --parallel
test-filter: ## Run tests with filter (usage: make test-filter FILTER=DatabaseServer)
$(PHP_ARTISAN) test --parallel --filter="$(FILTER)"
test-coverage: ## Run tests with coverage
$(PHP_ARTISAN) test --parallel --coverage
test-coverage-filter: ## Run tests with coverage and filter (usage: make test-coverage-filter FILTER=FailureNotification)
$(PHP_ARTISAN) test --parallel --coverage --filter="$(FILTER)"
test-sequential: ## Run all tests sequentially (for debugging)
$(PHP_ARTISAN) test
##@ Code Quality
lint-check: ## Check code style with Laravel Pint
$(PHP_EXEC) vendor/bin/pint --test
lint-fix: ## Fix code style with Laravel Pint
$(PHP_EXEC) vendor/bin/pint
lint: lint-fix ## Alias for lint-fix
phpstan: ## Run PHPStan static analysis
$(PHP_EXEC) vendor/bin/phpstan analyse --memory-limit=1G
pre-commit: lint-fix phpstan test ## Run all pre-commit checks (lint, phpstan, tests)
##@ Assets
build: ## Build production assets
$(NPM_EXEC) run build
dev-assets: ## Start Vite dev server only
$(NPM_EXEC) run dev
##@ Documentation
docs: ## Start documentation dev server (Docusaurus)
cd docs && $(NPM_EXEC) install && $(NPM_EXEC) run start
docs-build: ## Build documentation for production (Docusaurus)
cd docs && $(NPM_EXEC) install && $(NPM_EXEC) run build
##@ Database
migrate-fresh: ## Drop all tables and re-migrate
$(PHP_ARTISAN) migrate:fresh
migrate-fresh-seed: ## Drop all tables, re-migrate and seed
$(PHP_ARTISAN) migrate:fresh --seed
db-seed: ## Run database seeders
$(PHP_ARTISAN) db:seed
import-db: ## Import a gzipped SQL dump into local MySQL (usage: make import-db FILE=/path/to/dump.sql.gz)
@if [ -z "$(FILE)" ]; then \
echo "$(YELLOW)Usage: make import-db FILE=/path/to/dump.sql.gz$(NC)"; \
exit 1; \
fi
@if [ ! -f "$(FILE)" ]; then \
echo "$(YELLOW)Error: File '$(FILE)' not found$(NC)"; \
exit 1; \
fi
@echo "$(GREEN)Dropping and recreating 'databasement' database...$(NC)"
$(DOCKER_COMPOSE) exec -T mysql mysql -uroot -proot -e "DROP DATABASE IF EXISTS databasement; CREATE DATABASE databasement;"
@echo "$(GREEN)Importing $(FILE)...$(NC)"
gunzip -c "$(FILE)" | $(DOCKER_COMPOSE) exec -T mysql mysql -uroot -proot databasement
@echo "$(GREEN)Import complete!$(NC)"
##@ Maintenance
clean: ## Clear all caches
$(PHP_ARTISAN) cache:clear
$(PHP_ARTISAN) config:clear
$(PHP_ARTISAN) route:clear
$(PHP_ARTISAN) view:clear
optimize: ## Optimize the application for production
$(PHP_ARTISAN) config:cache
$(PHP_ARTISAN) route:cache
$(PHP_ARTISAN) view:cache
##@ Release
release: ## Create a new release (usage: make release VERSION=1.0.1)
@if [ -z "$(VERSION)" ]; then \
echo "$(YELLOW)Usage: make release VERSION=1.0.1$(NC)"; \
exit 1; \
fi
@if [ "$$(git branch --show-current)" != "main" ]; then \
echo "$(YELLOW)Error: You must be on the main branch to create a release.$(NC)"; \
exit 1; \
fi
@git fetch origin main --quiet
@if [ "$$(git rev-parse HEAD)" != "$$(git rev-parse origin/main)" ]; then \
echo "$(YELLOW)Error: Local main is not up to date with origin/main. Run 'git pull' first.$(NC)"; \
exit 1; \
fi
@if [ -n "$$(git status --porcelain)" ]; then \
echo "$(YELLOW)Error: Working directory is not clean. Commit or stash changes first.$(NC)"; \
exit 1; \
fi
@echo "$(GREEN)Creating release v$(VERSION)...$(NC)"
git tag v$(VERSION)
git push origin v$(VERSION)
@echo "$(GREEN)Release v$(VERSION) created! Workflows will build Docker images, Helm chart, and GitHub Release.$(NC)"