Makefile 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. GOVERSION ?= $(shell go env GOVERSION)
  2. ## help: 💡 Display available commands
  3. .PHONY: help
  4. help:
  5. @echo '⚡️ GoFiber/Fiber Development:'
  6. @sed -n 's/^##//p' ${MAKEFILE_LIST} | column -t -s ':' | sed -e 's/^/ /'
  7. ## audit: 🚀 Conduct quality checks
  8. .PHONY: audit
  9. audit:
  10. go mod verify
  11. go vet ./...
  12. GOTOOLCHAIN=$(GOVERSION) go run golang.org/x/vuln/cmd/govulncheck@latest ./...
  13. ## benchmark: 📈 Benchmark code performance
  14. .PHONY: benchmark
  15. benchmark:
  16. go test ./... -benchmem -bench=. -run=^Benchmark_$
  17. ## coverage: ☂️ Generate coverage report
  18. .PHONY: coverage
  19. coverage:
  20. GOTOOLCHAIN=$(GOVERSION) go run gotest.tools/gotestsum@latest -f testname -- ./... -race -count=1 -coverprofile=/tmp/coverage.out -covermode=atomic
  21. go tool cover -html=/tmp/coverage.out
  22. ## format: 🎨 Fix code format issues
  23. .PHONY: format
  24. format:
  25. GOTOOLCHAIN=$(GOVERSION) go run mvdan.cc/gofumpt@latest -w -l .
  26. ## markdown: 🎨 Find markdown format issues (Requires markdownlint-cli2)
  27. .PHONY: markdown
  28. markdown:
  29. @which markdownlint-cli2 > /dev/null || npm install -g markdownlint-cli2
  30. markdownlint-cli2 "**/*.md" "#vendor"
  31. ## lint: 🚨 Run lint checks
  32. .PHONY: lint
  33. lint:
  34. GOTOOLCHAIN=$(GOVERSION) go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.5.0 run ./...
  35. ## modernize: 🛠 Run gopls modernize
  36. .PHONY: modernize
  37. modernize:
  38. GOTOOLCHAIN=$(GOVERSION) go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest -fix -test=false ./...
  39. ## test: 🚦 Execute all tests
  40. .PHONY: test
  41. test:
  42. GOTOOLCHAIN=$(GOVERSION) go run gotest.tools/gotestsum@latest -f testname -- ./... -race -count=1 -shuffle=on
  43. ## longtest: 🚦 Execute all tests 10x
  44. .PHONY: longtest
  45. longtest:
  46. GOTOOLCHAIN=$(GOVERSION) go run gotest.tools/gotestsum@latest -f testname -- ./... -race -count=15 -shuffle=on
  47. ## tidy: 📌 Clean and tidy dependencies
  48. .PHONY: tidy
  49. tidy:
  50. go mod tidy -v
  51. ## betteralign: 📐 Optimize alignment of fields in structs
  52. .PHONY: betteralign
  53. betteralign:
  54. GOTOOLCHAIN=$(GOVERSION) go run github.com/dkorunic/betteralign/cmd/betteralign@v0.8.0 -test_files -generated_files -apply ./...
  55. ## generate: ⚡️ Generate msgp && interface implementations
  56. .PHONY: generate
  57. generate:
  58. go install github.com/tinylib/msgp@latest
  59. go install github.com/vburenin/ifacemaker@f30b6f9bdbed4b5c4804ec9ba4a04a999525c202
  60. go generate ./...
  61. # actionspin: 🤖 Bulk replace GitHub actions references from version tags to commit hashes
  62. .PHONY: actionspin
  63. actionspin:
  64. GOTOOLCHAIN=$(GOVERSION) go run github.com/mashiike/actionspin/cmd/actionspin@latest