You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

176 lines
7.9 KiB

  1. PWD := $(shell pwd)
  2. GOPATH := $(shell go env GOPATH)
  3. LDFLAGS := $(shell go run buildscripts/gen-ldflags.go)
  4. GOARCH := $(shell go env GOARCH)
  5. GOOS := $(shell go env GOOS)
  6. VERSION ?= $(shell git describe --tags)
  7. TAG ?= "minio/minio:$(VERSION)"
  8. GOLANGCI_VERSION = v1.51.2
  9. GOLANGCI_DIR = .bin/golangci/$(GOLANGCI_VERSION)
  10. GOLANGCI = $(GOLANGCI_DIR)/golangci-lint
  11. all: build
  12. checks: ## check dependencies
  13. @echo "Checking dependencies"
  14. @(env bash $(PWD)/buildscripts/checkdeps.sh)
  15. help: ## print this help
  16. @grep -E '^[a-zA-Z_-]+:.*?## .*$$' Makefile | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-40s\033[0m %s\n", $$1, $$2}'
  17. getdeps: ## fetch necessary dependencies
  18. @mkdir -p ${GOPATH}/bin
  19. @echo "Installing golangci-lint" && curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOLANGCI_DIR) $(GOLANGCI_VERSION)
  20. @echo "Installing msgp" && go install -v github.com/tinylib/msgp@v1.1.7
  21. @echo "Installing stringer" && go install -v golang.org/x/tools/cmd/stringer@latest
  22. crosscompile: ## cross compile minio
  23. @(env bash $(PWD)/buildscripts/cross-compile.sh)
  24. verifiers: lint check-gen
  25. check-gen: ## check for updated autogenerated files
  26. @go generate ./... >/dev/null
  27. @(! git diff --name-only | grep '_gen.go$$') || (echo "Non-committed changes in auto-generated code is detected, please commit them to proceed." && false)
  28. lint: getdeps ## runs golangci-lint suite of linters
  29. @echo "Running $@ check"
  30. @$(GOLANGCI) run --build-tags kqueue --timeout=10m --config ./.golangci.yml
  31. lint-fix: getdeps ## runs golangci-lint suite of linters with automatic fixes
  32. @echo "Running $@ check"
  33. @$(GOLANGCI) run --build-tags kqueue --timeout=10m --config ./.golangci.yml --fix
  34. check: test
  35. test: verifiers build ## builds minio, runs linters, tests
  36. @echo "Running unit tests"
  37. @MINIO_API_REQUESTS_MAX=10000 CGO_ENABLED=0 go test -tags kqueue ./...
  38. test-root-disable: install
  39. @echo "Running minio root lockdown tests"
  40. @env bash $(PWD)/buildscripts/disable-root.sh
  41. test-decom: install
  42. @echo "Running minio decom tests"
  43. @env bash $(PWD)/docs/distributed/decom.sh
  44. @env bash $(PWD)/docs/distributed/decom-encrypted.sh
  45. @env bash $(PWD)/docs/distributed/decom-encrypted-sse-s3.sh
  46. @env bash $(PWD)/docs/distributed/decom-compressed-sse-s3.sh
  47. test-upgrade: build
  48. @echo "Running minio upgrade tests"
  49. @(env bash $(PWD)/buildscripts/minio-upgrade.sh)
  50. test-race: verifiers build ## builds minio, runs linters, tests (race)
  51. @echo "Running unit tests under -race"
  52. @(env bash $(PWD)/buildscripts/race.sh)
  53. test-iam: build ## verify IAM (external IDP, etcd backends)
  54. @echo "Running tests for IAM (external IDP, etcd backends)"
  55. @MINIO_API_REQUESTS_MAX=10000 CGO_ENABLED=0 go test -tags kqueue -v -run TestIAM* ./cmd
  56. @echo "Running tests for IAM (external IDP, etcd backends) with -race"
  57. @MINIO_API_REQUESTS_MAX=10000 GORACE=history_size=7 CGO_ENABLED=1 go test -race -tags kqueue -v -run TestIAM* ./cmd
  58. test-sio-error:
  59. @(env bash $(PWD)/docs/bucket/replication/sio-error.sh)
  60. test-replication-2site:
  61. @(env bash $(PWD)/docs/bucket/replication/setup_2site_existing_replication.sh)
  62. test-replication-3site:
  63. @(env bash $(PWD)/docs/bucket/replication/setup_3site_replication.sh)
  64. test-delete-replication:
  65. @(env bash $(PWD)/docs/bucket/replication/delete-replication.sh)
  66. test-replication: install test-replication-2site test-replication-3site test-delete-replication test-sio-error ## verify multi site replication
  67. @echo "Running tests for replicating three sites"
  68. test-site-replication-ldap: install ## verify automatic site replication
  69. @echo "Running tests for automatic site replication of IAM (with LDAP)"
  70. @(env bash $(PWD)/docs/site-replication/run-multi-site-ldap.sh)
  71. test-site-replication-oidc: install ## verify automatic site replication
  72. @echo "Running tests for automatic site replication of IAM (with OIDC)"
  73. @(env bash $(PWD)/docs/site-replication/run-multi-site-oidc.sh)
  74. test-site-replication-minio: install ## verify automatic site replication
  75. @echo "Running tests for automatic site replication of IAM (with MinIO IDP)"
  76. @(env bash $(PWD)/docs/site-replication/run-multi-site-minio-idp.sh)
  77. verify: ## verify minio various setups
  78. @echo "Verifying build with race"
  79. @GORACE=history_size=7 CGO_ENABLED=1 go build -race -tags kqueue -trimpath --ldflags "$(LDFLAGS)" -o $(PWD)/minio 1>/dev/null
  80. @(env bash $(PWD)/buildscripts/verify-build.sh)
  81. verify-healing: ## verify healing and replacing disks with minio binary
  82. @echo "Verify healing build with race"
  83. @GORACE=history_size=7 CGO_ENABLED=1 go build -race -tags kqueue -trimpath --ldflags "$(LDFLAGS)" -o $(PWD)/minio 1>/dev/null
  84. @(env bash $(PWD)/buildscripts/verify-healing.sh)
  85. @(env bash $(PWD)/buildscripts/unaligned-healing.sh)
  86. @(env bash $(PWD)/buildscripts/heal-inconsistent-versions.sh)
  87. verify-healing-with-root-disks: ## verify healing root disks
  88. @echo "Verify healing with root drives"
  89. @GORACE=history_size=7 CGO_ENABLED=1 go build -race -tags kqueue -trimpath --ldflags "$(LDFLAGS)" -o $(PWD)/minio 1>/dev/null
  90. @(env bash $(PWD)/buildscripts/verify-healing-with-root-disks.sh)
  91. verify-healing-with-rewrite: ## verify healing to rewrite old xl.meta -> new xl.meta
  92. @echo "Verify healing with rewrite"
  93. @GORACE=history_size=7 CGO_ENABLED=1 go build -race -tags kqueue -trimpath --ldflags "$(LDFLAGS)" -o $(PWD)/minio 1>/dev/null
  94. @(env bash $(PWD)/buildscripts/rewrite-old-new.sh)
  95. verify-healing-inconsistent-versions: ## verify resolving inconsistent versions
  96. @echo "Verify resolving inconsistent versions build with race"
  97. @GORACE=history_size=7 CGO_ENABLED=1 go build -race -tags kqueue -trimpath --ldflags "$(LDFLAGS)" -o $(PWD)/minio 1>/dev/null
  98. @(env bash $(PWD)/buildscripts/resolve-right-versions.sh)
  99. build: checks ## builds minio to $(PWD)
  100. @echo "Building minio binary to './minio'"
  101. @CGO_ENABLED=0 go build -tags kqueue -trimpath --ldflags "$(LDFLAGS)" -o $(PWD)/minio 1>/dev/null
  102. hotfix-vars:
  103. $(eval LDFLAGS := $(shell MINIO_RELEASE="RELEASE" MINIO_HOTFIX="hotfix.$(shell git rev-parse --short HEAD)" go run buildscripts/gen-ldflags.go $(shell git describe --tags --abbrev=0 | \
  104. sed 's#RELEASE\.\([0-9]\+\)-\([0-9]\+\)-\([0-9]\+\)T\([0-9]\+\)-\([0-9]\+\)-\([0-9]\+\)Z#\1-\2-\3T\4:\5:\6Z#')))
  105. $(eval VERSION := $(shell git describe --tags --abbrev=0).hotfix.$(shell git rev-parse --short HEAD))
  106. $(eval TAG := "minio/minio:$(VERSION)")
  107. hotfix: hotfix-vars install ## builds minio binary with hotfix tags
  108. @mv -f ./minio ./minio.$(VERSION)
  109. @minisign -qQSm ./minio.$(VERSION) -s "${CRED_DIR}/minisign.key" < "${CRED_DIR}/minisign-passphrase"
  110. @sha256sum < ./minio.$(VERSION) | sed 's, -,minio.$(VERSION),g' > minio.$(VERSION).sha256sum
  111. hotfix-push: hotfix
  112. @scp -q -r minio.$(VERSION)* minio@dl-0.minio.io:~/releases/server/minio/hotfixes/linux-amd64/archive/
  113. @scp -q -r minio.$(VERSION)* minio@dl-1.minio.io:~/releases/server/minio/hotfixes/linux-amd64/archive/
  114. @echo "Published new hotfix binaries at https://dl.min.io/server/minio/hotfixes/linux-amd64/archive/minio.$(VERSION)"
  115. docker-hotfix-push: docker-hotfix
  116. @docker push -q $(TAG) && echo "Published new container $(TAG)"
  117. docker-hotfix: hotfix-push checks ## builds minio docker container with hotfix tags
  118. @echo "Building minio docker image '$(TAG)'"
  119. @docker build -q --no-cache -t $(TAG) --build-arg RELEASE=$(VERSION) . -f Dockerfile.hotfix
  120. docker: build ## builds minio docker container
  121. @echo "Building minio docker image '$(TAG)'"
  122. @docker build -q --no-cache -t $(TAG) . -f Dockerfile
  123. install: build ## builds minio and installs it to $GOPATH/bin.
  124. @echo "Installing minio binary to '$(GOPATH)/bin/minio'"
  125. @mkdir -p $(GOPATH)/bin && cp -f $(PWD)/minio $(GOPATH)/bin/minio
  126. @echo "Installation successful. To learn more, try \"minio --help\"."
  127. clean: ## cleanup all generated assets
  128. @echo "Cleaning up all the generated files"
  129. @find . -name '*.test' | xargs rm -fv
  130. @find . -name '*~' | xargs rm -fv
  131. @find . -name '.#*#' | xargs rm -fv
  132. @find . -name '#*#' | xargs rm -fv
  133. @rm -rvf minio
  134. @rm -rvf build
  135. @rm -rvf release
  136. @rm -rvf .verify*