-
-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathMakefile
More file actions
129 lines (99 loc) · 3.99 KB
/
Makefile
File metadata and controls
129 lines (99 loc) · 3.99 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
# Variables
APP_NAME=authula
BINARY_PATH=./tmp/$(APP_NAME)
MIGRATE_CONFIG?=./config.toml
MIGRATE_ARGS?=
MIGRATE_CMD=CGO_ENABLED=1 go run ./cmd/migrate
.PHONY: help build build-exe run dev test clean install setup
.PHONY: test-coverage
.PHONY: lint fmt vet deps-update all check quick-check ci
.PHONY: migrate-core-up migrate-core-down migrate-plugins-up migrate-plugins-down migrate-status
# Help command
help: # Display this help screen
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
# Build commands`
build: # Build the package (library)
@echo "Building $(APP_NAME) package..."
@go build ./...
@echo "Build complete!"
build-exe: # Build the binary executable
@echo "Building $(APP_NAME) binary..."
@mkdir -p ./tmp
@rm -rf ./tmp/$(APP_NAME)
@go build -o $(BINARY_PATH) ./cmd/main.go
@echo "Binary built: $(BINARY_PATH)"
run: # Run the application
@rm -f ./tmp/$(APP_NAME)
@CGO_ENABLED=1 go run ./cmd/main.go
dev: # Run the application with live reloading using air
@rm -f ./tmp/$(APP_NAME)
@CGO_ENABLED=1 ./bin/air --build.cmd "go build -o ./tmp/$(APP_NAME) ./cmd/main.go" --build.entrypoint "./tmp/$(APP_NAME)"
# Test commands
test: # Run all tests
@echo "Running tests..."
@CGO_ENABLED=1 go test -race -v ./...
test-coverage: # Run tests with coverage report
@echo "Running tests with coverage..."
@CGO_ENABLED=1 go test -race -v -coverprofile=coverage.out ./...
@go tool cover -html=coverage.out -o coverage.html
@echo "Coverage report generated: coverage.html"
@go tool cover -func=coverage.out | grep total | awk '{print "Total coverage: " $$3}'
# Dependency management
install: # Install dependencies
@echo "Installing dependencies..."
@go mod download
@go mod tidy
deps-update: # Update dependencies
@echo "Updating dependencies..."
@go get -u ./...
@go mod tidy
# Library mode development
library-test: test # Run library mode tests
# Development setup
setup: install # Setup development environment
@echo "Setting up development environment..."
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
@go install github.com/air-verse/air@latest
@echo "Development environment setup complete!"
# Clean commands
clean: # Clean build artifacts
@echo "Cleaning..."
@rm -rf bin/
@rm -f coverage.out coverage.html
@go clean
# Code quality
lint: # Run linter
@echo "Running linter..."
@golangci-lint run
fmt: # Format code
@echo "Formatting code..."
@go fmt ./...
vet: # Run go vet
@echo "Running go vet..."
@go vet ./...
# All-in-one commands
all: clean install build check # Clean, install deps, build, and run all checks
check: fmt vet lint test # Run all checks (format, vet, lint, test)
quick-check: fmt vet test # Run quick checks (format, vet, fast tests)
ci: clean install check # CI pipeline (clean, install, check)
# Integration testing
integration-test: docker-down docker-up docker-test # Run integration tests with Docker
# Migration commands
migrate-help: # Show migration CLI help
@$(MIGRATE_CMD) --help
migrate-core-up: # Run core migrations (up)
@$(MIGRATE_CMD) core up --config $(MIGRATE_CONFIG) $(MIGRATE_ARGS)
migrate-core-down: # Roll back core migrations
@$(MIGRATE_CMD) core down --config $(MIGRATE_CONFIG) $(MIGRATE_ARGS)
migrate-plugins-up: # Run plugin migrations (up) - use MIGRATE_ARGS for filtering (e.g., --only email-password)
@$(MIGRATE_CMD) plugins up --config $(MIGRATE_CONFIG) $(MIGRATE_ARGS)
migrate-plugins-down: # Roll back plugin migrations - use MIGRATE_ARGS for filtering (e.g., --except email-password)
@$(MIGRATE_CMD) plugins down --config $(MIGRATE_CONFIG) $(MIGRATE_ARGS)
migrate-status: # Show migration status - use MIGRATE_ARGS to filter by plugin (e.g., --plugin jwt)
@$(MIGRATE_CMD) status --config $(MIGRATE_CONFIG) $(MIGRATE_ARGS)
# Run all migrations (core + plugins)
migrate-up: migrate-core-up migrate-plugins-up
# Roll back all migrations (core + plugins)
migrate-down: migrate-plugins-down migrate-core-down
# Default target
.DEFAULT_GOAL := help