mirror of
https://github.com/sonr-io/common.git
synced 2026-01-12 04:09:13 +00:00
111 lines
3.5 KiB
Makefile
111 lines
3.5 KiB
Makefile
|
|
# Makefile for sonr-io/common
|
||
|
|
# Provides convenient testing and validation commands for ipfs and webauthn modules
|
||
|
|
|
||
|
|
.PHONY: help test test-ipfs test-webauthn test-all coverage coverage-ipfs coverage-webauthn coverage-all lint vet fmt clean
|
||
|
|
|
||
|
|
# Default target
|
||
|
|
help:
|
||
|
|
@echo "Available targets:"
|
||
|
|
@echo " make test - Run all tests"
|
||
|
|
@echo " make test-ipfs - Run tests for ipfs module"
|
||
|
|
@echo " make test-webauthn - Run tests for webauthn module"
|
||
|
|
@echo " make test-all - Run all tests with verbose output"
|
||
|
|
@echo " make coverage - Generate coverage report for all modules"
|
||
|
|
@echo " make coverage-ipfs - Generate coverage report for ipfs module"
|
||
|
|
@echo " make coverage-webauthn - Generate coverage report for webauthn module"
|
||
|
|
@echo " make coverage-all - Generate combined coverage report (HTML)"
|
||
|
|
@echo " make lint - Run golangci-lint"
|
||
|
|
@echo " make vet - Run go vet"
|
||
|
|
@echo " make fmt - Format all Go files"
|
||
|
|
@echo " make clean - Clean test cache and coverage files"
|
||
|
|
|
||
|
|
# Run all tests
|
||
|
|
test:
|
||
|
|
@echo "Running tests for all modules..."
|
||
|
|
@go test ./ipfs/... ./webauthn/...
|
||
|
|
|
||
|
|
# Run tests for ipfs module
|
||
|
|
test-ipfs:
|
||
|
|
@echo "Running tests for ipfs module..."
|
||
|
|
@go test ./ipfs/... -v
|
||
|
|
|
||
|
|
# Run tests for webauthn module
|
||
|
|
test-webauthn:
|
||
|
|
@echo "Running tests for webauthn module..."
|
||
|
|
@go test ./webauthn/... -v
|
||
|
|
|
||
|
|
# Run all tests with verbose output
|
||
|
|
test-all:
|
||
|
|
@echo "Running all tests with verbose output..."
|
||
|
|
@go test -v ./ipfs/... ./webauthn/...
|
||
|
|
|
||
|
|
# Generate coverage report for all modules
|
||
|
|
coverage:
|
||
|
|
@echo "Generating coverage report for all modules..."
|
||
|
|
@go test ./ipfs/... ./webauthn/... -coverprofile=coverage.out
|
||
|
|
@go tool cover -func=coverage.out
|
||
|
|
|
||
|
|
# Generate coverage report for ipfs module
|
||
|
|
coverage-ipfs:
|
||
|
|
@echo "Generating coverage report for ipfs module..."
|
||
|
|
@go test ./ipfs/... -coverprofile=coverage-ipfs.out
|
||
|
|
@go tool cover -func=coverage-ipfs.out
|
||
|
|
|
||
|
|
# Generate coverage report for webauthn module
|
||
|
|
coverage-webauthn:
|
||
|
|
@echo "Generating coverage report for webauthn module..."
|
||
|
|
@go test ./webauthn/... -coverprofile=coverage-webauthn.out
|
||
|
|
@go tool cover -func=coverage-webauthn.out
|
||
|
|
|
||
|
|
# Generate HTML coverage report for all modules
|
||
|
|
coverage-all:
|
||
|
|
@echo "Generating HTML coverage report for all modules..."
|
||
|
|
@go test ./ipfs/... ./webauthn/... -coverprofile=coverage.out
|
||
|
|
@go tool cover -html=coverage.out -o coverage.html
|
||
|
|
@echo "Coverage report generated: coverage.html"
|
||
|
|
|
||
|
|
# Run golangci-lint (requires golangci-lint to be installed)
|
||
|
|
lint:
|
||
|
|
@echo "Running golangci-lint..."
|
||
|
|
@which golangci-lint > /dev/null || (echo "golangci-lint not found. Install from https://golangci-lint.run/usage/install/" && exit 1)
|
||
|
|
@golangci-lint run ./ipfs/... ./webauthn/...
|
||
|
|
|
||
|
|
# Run go vet
|
||
|
|
vet:
|
||
|
|
@echo "Running go vet..."
|
||
|
|
@go vet ./ipfs/...
|
||
|
|
@go vet ./webauthn/...
|
||
|
|
|
||
|
|
# Format all Go files
|
||
|
|
fmt:
|
||
|
|
@echo "Formatting Go files..."
|
||
|
|
@go fmt ./ipfs/...
|
||
|
|
@go fmt ./webauthn/...
|
||
|
|
|
||
|
|
# Clean test cache and coverage files
|
||
|
|
clean:
|
||
|
|
@echo "Cleaning test cache and coverage files..."
|
||
|
|
@go clean -testcache
|
||
|
|
@rm -f coverage.out coverage-ipfs.out coverage-webauthn.out coverage.html
|
||
|
|
@echo "Clean complete"
|
||
|
|
|
||
|
|
# Run tests with race detector
|
||
|
|
test-race:
|
||
|
|
@echo "Running tests with race detector..."
|
||
|
|
@go test -race ./ipfs/... ./webauthn/...
|
||
|
|
|
||
|
|
# Run benchmarks
|
||
|
|
bench:
|
||
|
|
@echo "Running benchmarks..."
|
||
|
|
@go test -bench=. -benchmem ./ipfs/... ./webauthn/...
|
||
|
|
|
||
|
|
# Install test dependencies
|
||
|
|
deps:
|
||
|
|
@echo "Installing dependencies..."
|
||
|
|
@go mod download
|
||
|
|
@go mod tidy
|
||
|
|
|
||
|
|
# Quick check: fmt, vet, and test
|
||
|
|
check: fmt vet test
|
||
|
|
@echo "All checks passed!"
|