Makefile 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. include .env
  2. GOOSE_DB_STRING = "user=${DB_USER} password=${DB_PASSWORD} dbname=${DB_NAME} port=${DB_PORT} host=${DB_HOST} sslmode=disable"
  3. usage:
  4. @echo "make run"
  5. @echo "make test"
  6. @echo "make test-cover"
  7. @echo "make swag"
  8. @echo "make lint"
  9. @echo "make migration-status"
  10. @echo "make migration-up"
  11. @echo "make migration-down"
  12. @echo "make docker-build"
  13. @echo "make docker-up"
  14. @echo "make docker-down"
  15. @echo "make install-deps"
  16. @echo "make build"
  17. run:
  18. cd cmd/app && go run main.go
  19. run-frontend:
  20. npm run dev
  21. test:
  22. go test ./...
  23. test-cover:
  24. go clean -testcache
  25. go test ./... -coverprofile=coverage.tmp.out -covermode count -coverpkg=git.dmitriygnatenko.ru/dima/homethings/internal/api/...
  26. grep -v 'mocks\|config' coverage.tmp.out > coverage.out
  27. rm coverage.tmp.out
  28. go tool cover -html=coverage.out;
  29. lint:
  30. golangci-lint run --timeout=3m
  31. swag:
  32. swag init -o "docs" -d "cmd/app,internal/api/v1,internal/dto"
  33. migration-status:
  34. goose -dir migrations postgres ${GOOSE_DB_STRING} status
  35. migration-up:
  36. goose -dir migrations postgres ${GOOSE_DB_STRING} up
  37. migration-down:
  38. goose -dir migrations postgres ${GOOSE_DB_STRING} down
  39. docker-build:
  40. docker compose up --build --detach
  41. docker-up:
  42. docker compose up --detach
  43. docker-down:
  44. docker compose down
  45. install-deps: install-lint install-goose install-minimock install-swagger
  46. install-lint:
  47. go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
  48. install-goose:
  49. go install github.com/pressly/goose/v3/cmd/goose@latest
  50. install-minimock:
  51. go install github.com/gojuno/minimock/v3/cmd/minimock@latest
  52. install-swagger:
  53. go install github.com/swaggo/swag/cmd/swag@latest
  54. install-frontend:
  55. npm install
  56. .PHONY: build
  57. build:
  58. env GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o build/app/app cmd/app/main.go
  59. build-frontend:
  60. npm run build --emptyOutDir