109 lines
2.9 KiB
Makefile
109 lines
2.9 KiB
Makefile
.PHONY: build clean wipe test help sync-version pkg-deb
|
|
|
|
# Default target
|
|
all: build
|
|
|
|
# Build the binary
|
|
build:
|
|
@echo "Building s3-genindex..."
|
|
go build -o s3-genindex ./cmd/s3-genindex
|
|
@echo "Build complete: s3-genindex"
|
|
|
|
# Run tests
|
|
test:
|
|
@echo "Running tests..."
|
|
go test -v ./...
|
|
@echo "Tests complete"
|
|
|
|
# Run tests with coverage
|
|
test-coverage:
|
|
@echo "Running tests with coverage..."
|
|
go test -v -coverprofile=coverage.out ./...
|
|
go tool cover -html=coverage.out -o coverage.html
|
|
@echo "Coverage report generated: coverage.html"
|
|
|
|
# Clean build artifacts
|
|
clean:
|
|
@echo "Cleaning build artifacts..."
|
|
rm -f s3-genindex
|
|
rm -f coverage.out coverage.html
|
|
rm -rf debian/s3-genindex debian/files debian/*.substvars debian/debhelper-build-stamp
|
|
[ -d debian/go ] && chmod -R +w debian/go || true
|
|
rm -rf debian/.gocache debian/go
|
|
find . -name index.html -delete
|
|
@echo "Clean complete"
|
|
|
|
# Wipe everything including test caches
|
|
wipe: clean
|
|
@echo "Wiping test cache and module cache..."
|
|
go clean -testcache
|
|
go clean -modcache
|
|
@echo "Wipe complete"
|
|
|
|
# Install binary to $GOPATH/bin or $GOBIN
|
|
install:
|
|
@echo "Installing s3-genindex..."
|
|
go install ./cmd/s3-genindex
|
|
@echo "Install complete"
|
|
|
|
# Format code
|
|
fmt:
|
|
@echo "Formatting code..."
|
|
go fmt ./...
|
|
@echo "Format complete"
|
|
|
|
# Vet code for issues
|
|
vet:
|
|
@echo "Vetting code..."
|
|
go vet ./...
|
|
@echo "Vet complete"
|
|
|
|
# Lint code (requires golangci-lint)
|
|
lint:
|
|
@echo "Linting code..."
|
|
@if command -v golangci-lint >/dev/null 2>&1; then \
|
|
golangci-lint run; \
|
|
else \
|
|
echo "golangci-lint not found, skipping lint"; \
|
|
fi
|
|
|
|
# Run all checks
|
|
check: fmt vet lint test
|
|
@echo "All checks passed"
|
|
|
|
# Run benchmarks
|
|
bench:
|
|
@echo "Running benchmarks..."
|
|
go test -bench=. ./...
|
|
|
|
# Sync version from debian/changelog to source code
|
|
sync-version:
|
|
@echo "Syncing version..."
|
|
@version=$$(head -1 debian/changelog | sed -n 's/.*(\([^)]*\)).*/\1/p'); \
|
|
sed -i "s/const Version = .*/const Version = \"$$version\"/" cmd/s3-genindex/main.go; \
|
|
echo "Updated version to $$version"
|
|
|
|
# Build Debian package
|
|
pkg-deb: sync-version
|
|
@echo "Building Debian package..."
|
|
DEB_BUILD_OPTIONS=noautodbgsym fakeroot dpkg-buildpackage -us -uc -b
|
|
@echo "Debian package build complete"
|
|
|
|
# Show help
|
|
help:
|
|
@echo "Available targets:"
|
|
@echo " build - Build the s3-genindex binary"
|
|
@echo " test - Run all tests"
|
|
@echo " test-coverage - Run tests with coverage report"
|
|
@echo " clean - Remove build artifacts"
|
|
@echo " wipe - Clean everything including caches"
|
|
@echo " install - Install binary to GOPATH/bin"
|
|
@echo " fmt - Format code"
|
|
@echo " vet - Vet code for issues"
|
|
@echo " lint - Lint code (requires golangci-lint)"
|
|
@echo " check - Run fmt, vet, lint, and test"
|
|
@echo " bench - Run benchmarks"
|
|
@echo " sync-version - Sync version from debian/changelog to source"
|
|
@echo " pkg-deb - Build Debian package"
|
|
@echo " help - Show this help message"
|