Files
whatshooked/Makefile
Hein a3eca09502
Some checks failed
CI / Lint (push) Has been cancelled
CI / Build (push) Has been cancelled
CI / Test (1.23) (push) Has been cancelled
CI / Test (1.22) (push) Has been cancelled
Lint fixes and testing workflow actions
2025-12-29 10:24:18 +02:00

114 lines
3.3 KiB
Makefile

.PHONY: build clean test lint lintfix run-server run-cli help
# Build both server and CLI
build:
@echo "Building WhatsHooked..."
@mkdir -p bin
@go build -o bin/whatshook-server ./cmd/server
@go build -o bin/whatshook-cli ./cmd/cli
@echo "Build complete! Binaries in bin/"
# Build server only
build-server:
@echo "Building server..."
@mkdir -p bin
@go build -o bin/whatshook-server ./cmd/server
@echo "Server built: bin/whatshook-server"
# Build CLI only
build-cli:
@echo "Building CLI..."
@mkdir -p bin
@go build -o bin/whatshook-cli ./cmd/cli
@echo "CLI built: bin/whatshook-cli"
# Clean build artifacts (preserves bin directory)
clean:
@echo "Cleaning..."
@mkdir -p bin
@rm -f bin/whatshook*
@echo "Clean complete!"
# Run tests with coverage
test:
@echo "Running tests..."
@go test -v -coverprofile=coverage.out -covermode=atomic ./...
@echo "Coverage report saved to coverage.out"
# Run server (requires config.json)
run-server:
@go run ./cmd/server -config config.json
# Run CLI
run-cli:
@go run ./cmd/cli $(ARGS)
# Install dependencies
deps:
@echo "Installing dependencies..."
@go mod download
@go mod tidy
@echo "Dependencies installed!"
release-version: ## Create and push a release with specific version (use: make release-version VERSION=v1.2.3)
@if [ -z "$(VERSION)" ]; then \
echo "Error: VERSION is required. Usage: make release-version VERSION=v1.2.3"; \
exit 1; \
fi
@version="$(VERSION)"; \
if ! echo "$$version" | grep -q "^v"; then \
version="v$$version"; \
fi; \
echo "Creating release: $$version"; \
latest_tag=$$(git describe --tags --abbrev=0 2>/dev/null || echo ""); \
if [ -z "$$latest_tag" ]; then \
commit_logs=$$(git log --pretty=format:"- %s" --no-merges); \
else \
commit_logs=$$(git log "$${latest_tag}..HEAD" --pretty=format:"- %s" --no-merges); \
fi; \
if [ -z "$$commit_logs" ]; then \
tag_message="Release $$version"; \
else \
tag_message="Release $$version\n\n$$commit_logs"; \
fi; \
git tag -a "$$version" -m "$$tag_message"; \
git push origin "$$version"; \
echo "Tag $$version created and pushed to remote repository."
lint: ## Run linter
@echo "Running linter..."
@if command -v golangci-lint > /dev/null; then \
golangci-lint run --config=.golangci.json; \
else \
echo "golangci-lint not installed. Install with: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest"; \
exit 1; \
fi
lintfix: ## Run linter
@echo "Running linter..."
@if command -v golangci-lint > /dev/null; then \
golangci-lint run --config=.golangci.json --fix; \
else \
echo "golangci-lint not installed. Install with: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest"; \
exit 1; \
fi
# Help
help:
@echo "WhatsHooked Makefile"
@echo ""
@echo "Usage:"
@echo " make build - Build server and CLI"
@echo " make build-server - Build server only"
@echo " make build-cli - Build CLI only"
@echo " make clean - Remove build artifacts (preserves bin directory)"
@echo " make test - Run tests with coverage"
@echo " make lint - Run linter"
@echo " make lintfix - Run linter with auto-fix"
@echo " make run-server - Run server (requires config.json)"
@echo " make run-cli ARGS='health' - Run CLI with arguments"
@echo " make deps - Install dependencies"
@echo " make help - Show this help message"