| 1 |
# Shoutrrr Makefile |
| 2 |
# Comprehensive build, test, and deployment targets for the Shoutrrr project |
| 3 |
|
| 4 |
# Variables |
| 5 |
BINARY_NAME=shoutrrr |
| 6 |
GO=go |
| 7 |
DOCKER=docker |
| 8 |
GORELEASER=goreleaser |
| 9 |
GOLANGCI_LINT=golangci-lint |
| 10 |
MOCKERY=mockery |
| 11 |
|
| 12 |
# Default target |
| 13 |
help: ## Show this help message |
| 14 |
@echo "Shoutrrr Project Makefile" |
| 15 |
@echo "" |
| 16 |
@echo "Available targets:" |
| 17 |
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " %-15s %s\n", $$1, $$2}' $(MAKEFILE_LIST) |
| 18 |
@echo "" |
| 19 |
@echo "Parameterized test targets:" |
| 20 |
@echo " test-unit Run unit tests for a specific service (usage: make test-unit <service>)" |
| 21 |
@echo " test-integration Run integration tests for a specific service (usage: make test-integration <service>)" |
| 22 |
@echo " test-e2e Run e2e tests for a specific service (usage: make test-e2e <service>)" |
| 23 |
|
| 24 |
# ============================================================================= |
| 25 |
# Development Targets |
| 26 |
# ============================================================================= |
| 27 |
|
| 28 |
.PHONY: build test test-unit test-integration test-e2e test-wasm test-playground lint vet run setup install |
| 29 |
|
| 30 |
build: ## Build the application binary |
| 31 |
bash ./scripts/build.sh |
| 32 |
|
| 33 |
mocks: ## Generate mocks |
| 34 |
$(MOCKERY) --config build/mockery/mockery.yaml |
| 35 |
|
| 36 |
test: ## Run unit tests only |
| 37 |
$(GO) test -timeout 30s -v -coverprofile coverage.out -covermode atomic $(shell go list ./... | grep -v testing/...) |
| 38 |
|
| 39 |
test-unit: ## Run unit tests for a specific service (usage: make test-unit <service>) |
| 40 |
@SVC=`echo $(MAKECMDGOALS) | cut -d' ' -f2`; \ |
| 41 |
if [ -z "$$SVC" ]; then echo "Usage: make test-unit <service>"; exit 1; fi; \ |
| 42 |
SERVICE_DIR=`find ./pkg/services -name "$$SVC" -type d`; \ |
| 43 |
$(GO) test -timeout 30s -v $$SERVICE_DIR |
| 44 |
|
| 45 |
test-integration: ## Run integration tests for a specific service (usage: make test-integration <service>) |
| 46 |
@SVC=`echo $(MAKECMDGOALS) | cut -d' ' -f2`; \ |
| 47 |
if [ -z "$$SVC" ]; then echo "Usage: make test-integration <service>"; exit 1; fi; \ |
| 48 |
$(GO) test -timeout 30s -v ./testing/integration/$$SVC |
| 49 |
|
| 50 |
test-e2e: ## Run e2e tests for a specific service (usage: make test-e2e <service>) |
| 51 |
@SVC=`echo $(MAKECMDGOALS) | cut -d' ' -f2`; \ |
| 52 |
if [ -z "$$SVC" ]; then echo "Usage: make test-e2e <service>"; exit 1; fi; \ |
| 53 |
$(GO) test -timeout 30s -v ./testing/e2e/$$SVC |
| 54 |
|
| 55 |
test-wasm: ## Compile WASM playground tests (coverage requires native WASI runtime) |
| 56 |
GOOS=js GOARCH=wasm $(GO) test -c -o /dev/null ./docs/playground/wasm/ |
| 57 |
|
| 58 |
test-playground: ## Run playground tests with coverage (excludes JS/WASM-specific tests) |
| 59 |
$(GO) test -timeout 30s -v -coverprofile coverage-playground.out -covermode atomic ./docs/playground/wasm/ |
| 60 |
|
| 61 |
lint: ## Run linter and fix issues |
| 62 |
$(GOLANGCI_LINT) run --fix --config build/golangci-lint/golangci.yaml ./... |
| 63 |
|
| 64 |
vet: ## Run Go vet |
| 65 |
$(GO) vet ./... |
| 66 |
|
| 67 |
fmt: ## Run formatter |
| 68 |
$(GOLANGCI_LINT) fmt --config build/golangci-lint/golangci.yaml ./... |
| 69 |
|
| 70 |
run: ## Run the application |
| 71 |
$(GO) run ./... |
| 72 |
|
| 73 |
install: ## Install the application |
| 74 |
$(GO) install ./... |
| 75 |
|
| 76 |
# ============================================================================= |
| 77 |
# Dependency Management |
| 78 |
# ============================================================================= |
| 79 |
|
| 80 |
.PHONY: mod-tidy mod-download |
| 81 |
|
| 82 |
mod-tidy: ## Tidy and clean up Go modules |
| 83 |
$(GO) mod tidy |
| 84 |
|
| 85 |
mod-download: ## Download Go module dependencies |
| 86 |
$(GO) mod download |
| 87 |
|
| 88 |
# ============================================================================= |
| 89 |
# Documentation Targets |
| 90 |
# ============================================================================= |
| 91 |
|
| 92 |
.PHONY: docs docs-setup docs-build docs-serve docs-activate docs-deactivate wasm |
| 93 |
|
| 94 |
docs: docs-setup docs-serve ## Build and serve documentation site for local development |
| 95 |
|
| 96 |
docs-setup: ## Create virtual environment and install Mkdocs dependencies |
| 97 |
python3 -m venv shoutrrr-docs && chmod +x shoutrrr-docs/bin/activate && . shoutrrr-docs/bin/activate && pip install -r build/mkdocs/docs-requirements.txt |
| 98 |
|
| 99 |
docs-gen: ## Generate service configuration documentation |
| 100 |
bash ./scripts/generate-service-config-docs.sh |
| 101 |
|
| 102 |
docs-build: docs-gen ## Build Mkdocs documentation site |
| 103 |
. shoutrrr-docs/bin/activate && mkdocs build --config-file build/mkdocs/mkdocs.yaml |
| 104 |
|
| 105 |
docs-serve: ## Serve Mkdocs documentation site locally |
| 106 |
. shoutrrr-docs/bin/activate && mkdocs serve --config-file build/mkdocs/mkdocs.yaml --livereload |
| 107 |
|
| 108 |
docs-activate: ## Activate the virtual environment for documentation |
| 109 |
@echo "Run '. shoutrrr-docs/bin/activate' to activate the virtual environment." |
| 110 |
|
| 111 |
docs-deactivate: ## Show instructions to deactivate the virtual environment |
| 112 |
@echo "Run 'deactivate' to exit the virtual environment." |
| 113 |
|
| 114 |
wasm: ## Build WASM module for the Playground |
| 115 |
@mkdir -p docs/playground/assets |
| 116 |
GOOS=js GOARCH=wasm $(GO) build \ |
| 117 |
-trimpath \ |
| 118 |
-o docs/playground/assets/shoutrrr.wasm \ |
| 119 |
-ldflags="-s -w" \ |
| 120 |
./docs/playground/wasm/ |
| 121 |
@cp "$$(go env GOROOT)/lib/wasm/wasm_exec.js" docs/playground/assets/ |
| 122 |
|
| 123 |
# ============================================================================= |
| 124 |
# Release Targets |
| 125 |
# ============================================================================= |
| 126 |
|
| 127 |
.PHONY: release |
| 128 |
|
| 129 |
release: ## Create a new release using GoReleaser |
| 130 |
$(GORELEASER) release --clean |
| 131 |
|
| 132 |
# ============================================================================= |
| 133 |
# Docker Targets |
| 134 |
# ============================================================================= |
| 135 |
|
| 136 |
.PHONY: docker-build docker-run docker-push |
| 137 |
|
| 138 |
docker-build: ## Build Docker image |
| 139 |
$(DOCKER) build -t $(BINARY_NAME) . |
| 140 |
|
| 141 |
docker-run: ## Run Docker container |
| 142 |
$(DOCKER) run -p 8080:8080 $(BINARY_NAME) |
| 143 |
|
| 144 |
docker-push: ## Push Docker image (requires proper tagging) |
| 145 |
$(DOCKER) push $(BINARY_NAME) |
| 146 |
|
| 147 |
# ============================================================================= |
| 148 |
# Utility Targets |
| 149 |
# ============================================================================= |
| 150 |
|
| 151 |
.PHONY: clean |
| 152 |
|
| 153 |
clean: ## Clean build artifacts |
| 154 |
rm -rf bin/ |
| 155 |
|
| 156 |
.PHONY: % |
| 157 |
%: |
| 158 |
@: |