forked from psyb0t/piraterf
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile.servicepack
More file actions
100 lines (73 loc) · 3.53 KB
/
Makefile.servicepack
File metadata and controls
100 lines (73 loc) · 3.53 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
# Servicepack Framework Makefile
# This file contains all framework commands and gets included in the main Makefile
# Users can override any of these commands in their main Makefile
# Framework variables (can be overridden by user)
MIN_TEST_COVERAGE ?= 85
# Framework constants (do not override)
SCRIPTS_DIR := scripts
APP_NAME := $(shell head -n 1 go.mod | awk '{print $$2}' | awk -F'/' '{print $$NF}')
# Function to find script: check user scripts first, then fall back to servicepack
define find_script
$(shell if [ -f "./$(SCRIPTS_DIR)/make/$(1)" ]; then \
echo "./$(SCRIPTS_DIR)/make/$(1)"; \
else \
echo "./$(SCRIPTS_DIR)/make/servicepack/$(1)"; \
fi)
endef
# Framework PHONY targets
.PHONY: all dep lint lint-fix test test-coverage build clean \
service service-remove service-registration servicepack-update \
servicepack-update-review servicepack-update-merge servicepack-update-revert \
own backup backup-restore backup-clear docker-build docker-build-dev run-dev help
# Default target
all: dep lint-fix test-coverage build ## Run dep, lint-fix, test-coverage and build
# Core build commands
dep: ## Get project dependencies
@$(call find_script,dep.sh)
lint: ## Lint all Golang files
@$(call find_script,lint.sh)
lint-fix: ## Lint all Golang files and fix
@$(call find_script,lint_fix.sh)
test: ## Run all tests
@$(call find_script,test.sh)
test-coverage: ## Run tests with coverage check. Fails if coverage is below the threshold.
@MIN_TEST_COVERAGE=$(MIN_TEST_COVERAGE) $(call find_script,test_coverage.sh)
build: ## Build the app binary using Docker
@$(call find_script,build.sh)
clean: ## Clean build artifacts and coverage files
@$(call find_script,clean.sh)
# Docker commands
docker-build: ## Build the production Docker image
@$(call find_script,docker_build.sh)
docker-build-dev: ## Build the development Docker image
@$(call find_script,docker_build_dev.sh)
run-dev: ## Run in the development Docker image
@$(call find_script,run_dev.sh)
# Service management
service: ## Create a new service skeleton. Usage: make service NAME=myservice
@$(call find_script,service.sh) $(NAME)
service-remove: ## Remove a service. Usage: make service-remove NAME=myservice
@$(call find_script,service_remove.sh) $(NAME)
service-registration: ## Regenerate service registration file
@$(call find_script,service_registration.sh)
# Framework management
servicepack-update: ## Update servicepack framework to latest version
@$(call find_script,servicepack_update.sh)
servicepack-update-review: ## Review pending servicepack update changes
@$(call find_script,servicepack_update_review.sh)
servicepack-update-merge: ## Merge pending servicepack update
@$(call find_script,servicepack_update_merge.sh)
servicepack-update-revert: ## Revert pending servicepack update
@$(call find_script,servicepack_update_revert.sh)
own: ## Make this project your own. Usage: make own MODNAME=github.com/foo/bar
@$(call find_script,own.sh) $(MODNAME)
# Backup management
backup: ## Create backup of the current project
@$(call find_script,backup.sh)
backup-restore: ## Restore from backup. Usage: make backup-restore [BACKUP=filename.tar.gz] (defaults to latest)
@$(call find_script,backup_restore.sh) $(BACKUP)
backup-clear: ## Delete all backup files
@$(call find_script,backup_clear.sh)
# Help
help: ## Display this help message
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":"}; {filename=$$1; sub(/.*\//, "", filename); rule=$$2; desc=$$3; gsub(/.*?## /, "", desc); printf "\033[36m%-30s\033[0m \033[90m[%s]\033[0m %s\n", rule, filename, desc}' | sort