This commit is contained in:
Dev
2025-09-13 03:03:35 +03:00
parent 67b170415b
commit d3416687c9
6 changed files with 69 additions and 172 deletions

View File

@@ -16,7 +16,7 @@ all: test build ## Run tests and build binary
build: ## Build the binary for current platform
@echo "🔨 Building $(BINARY_NAME) v$(VERSION)..."
go build $(LDFLAGS) -o $(BINARY_NAME) .
@echo "Build complete: ./$(BINARY_NAME)"
@echo "Build complete: ./$(BINARY_NAME)"
build-all: ## Build binaries for all platforms
@echo "🏗️ Building for all platforms..."
@@ -26,53 +26,53 @@ build-all: ## Build binaries for all platforms
GOOS=linux GOARCH=386 go build $(LDFLAGS) -o dist/$(BINARY_NAME)-linux-386 .
GOOS=darwin GOARCH=amd64 go build $(LDFLAGS) -o dist/$(BINARY_NAME)-darwin-amd64 .
GOOS=darwin GOARCH=arm64 go build $(LDFLAGS) -o dist/$(BINARY_NAME)-darwin-arm64 .
@echo "Multi-platform build complete in ./dist/"
@echo "Multi-platform build complete in ./dist/"
test: ## Run tests
@echo "🧪 Running tests..."
go test -v ./...
@echo "Tests complete"
@echo "Tests complete"
test-coverage: ## Run tests with coverage
@echo "🧪 Running tests with coverage..."
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
@echo "Coverage report generated: coverage.html"
@echo "Coverage report generated: coverage.html"
fmt: ## Format code
@echo "🎨 Formatting code..."
@echo "Formatting code..."
go fmt ./...
@echo "Code formatted"
@echo "Code formatted"
lint: ## Run linters
@echo "🔍 Running linters..."
@echo "Running linters..."
@if command -v golangci-lint >/dev/null 2>&1; then \
golangci-lint run; \
else \
echo "⚠️ golangci-lint not installed. Install with: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest"; \
echo "golangci-lint not installed. Install with: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest"; \
go vet ./...; \
fi
@echo "Linting complete"
@echo "Linting complete"
clean: ## Clean build artifacts
@echo "🧹 Cleaning up..."
@echo "Cleaning up..."
rm -f $(BINARY_NAME)
rm -rf dist/
rm -f coverage.out coverage.html
@echo "Clean complete"
@echo "Clean complete"
install: build ## Install binary to /usr/local/bin
@echo "📦 Installing $(BINARY_NAME) to /usr/local/bin..."
@echo "Installing $(BINARY_NAME) to /usr/local/bin..."
sudo cp $(BINARY_NAME) /usr/local/bin/
@echo "Installation complete"
@echo "Installation complete"
uninstall: ## Remove binary from /usr/local/bin
@echo "🗑️ Uninstalling $(BINARY_NAME)..."
@echo "Uninstalling $(BINARY_NAME)..."
sudo rm -f /usr/local/bin/$(BINARY_NAME)
@echo "Uninstallation complete"
@echo "Uninstallation complete"
package: build-all ## Create distribution packages
@echo "📦 Creating packages..."
@echo "Creating packages..."
@mkdir -p dist/packages
# Create tar.gz archives
@@ -84,7 +84,7 @@ package: build-all ## Create distribution packages
fi \
done
@echo "Packages created in dist/packages/"
@echo "Packages created in dist/packages/"
release: clean test package ## Prepare a release
@echo "🚀 Release $(VERSION) ready!"
@@ -95,7 +95,7 @@ deps: ## Download dependencies
@echo "📥 Downloading dependencies..."
go mod download
go mod tidy
@echo "Dependencies updated"
@echo "Dependencies updated"
dev-deps: ## Install development dependencies
@echo "🛠️ Installing development dependencies..."
@@ -103,7 +103,7 @@ dev-deps: ## Install development dependencies
echo "Installing golangci-lint..."; \
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest; \
fi
@echo "Development dependencies installed"
@echo "Development dependencies installed"
run: build ## Build and run the application
@echo "🏃 Running $(BINARY_NAME)..."
@@ -114,7 +114,7 @@ demo: build ## Run a demo of the find command
./$(BINARY_NAME) find --top 3
check: fmt lint test ## Run all checks (format, lint, test)
@echo "All checks passed!"
@echo "All checks passed!"
help: ## Show this help message
@echo "FastestMirror Build System"