Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 22 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ $(ENVTEST):
GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) sigs.k8s.io/controller-runtime/tools/setup-envtest $(ENVTEST_BIN) $(ENVTEST_VER)

.PHONY: help
help: ## Display this help.
help: ## Display this help
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)


Expand All @@ -108,7 +108,7 @@ help: ## Display this help.
## --------------------------------------

.PHONY: lint
lint: $(GOLANGCI_LINT)
lint: $(GOLANGCI_LINT) ## Run fast linting
$(GOLANGCI_LINT) run -v

.PHONY: lint-full
Expand All @@ -119,36 +119,36 @@ lint-full: $(GOLANGCI_LINT) ## Run slower linters to detect possible issues
## Development
## --------------------------------------

staticcheck: $(STATICCHECK)
staticcheck: $(STATICCHECK) ## Run static analysis
$(STATICCHECK) ./...

.PHONY: fmt
fmt: $(GOIMPORTS) ## Run go fmt against code.
fmt: $(GOIMPORTS) ## Run go fmt against code
go fmt ./...
$(GOIMPORTS) -local go.goms.io/fleet -w $$(go list -f {{.Dir}} ./...)

.PHONY: vet
vet: ## Run go vet against code.
vet: ## Run go vet against code
go vet ./...

## --------------------------------------
## test
## --------------------------------------

.PHONY: test
test: manifests generate fmt vet local-unit-test integration-test## Run tests.
test: manifests generate fmt vet local-unit-test integration-test## Run unit tests and integration tests

##
# Set up the timeout parameters as some of the tests (rollout controller) lengths have exceeded the default 10 minute mark.
# TO-DO (chenyu1): enable parallelization for single package integration tests.
.PHONY: local-unit-test
local-unit-test: $(ENVTEST) ## Run tests.
local-unit-test: $(ENVTEST) ## Run unit tests
export CGO_ENABLED=1 && \
export KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" && \
go test `go list ./pkg/... ./cmd/...` -race -coverpkg=./... -coverprofile=ut-coverage.xml -covermode=atomic -v -timeout=30m

.PHONY: integration-test
integration-test: $(ENVTEST) ## Run tests.
integration-test: $(ENVTEST) ## Run integration tests
export CGO_ENABLED=1 && \
export KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" && \
ginkgo -v -p --race --cover --coverpkg=./pkg/scheduler/... ./test/scheduler && \
Expand All @@ -160,14 +160,14 @@ integration-test: $(ENVTEST) ## Run tests.
LABEL_FILTER ?= !custom

.PHONY: e2e-tests
e2e-tests: setup-clusters
e2e-tests: setup-clusters ## Run E2E tests
cd ./test/e2e && ginkgo --timeout=70m --label-filter="$(LABEL_FILTER)" -v -p .

e2e-tests-custom: setup-clusters
e2e-tests-custom: setup-clusters ## Run custom E2E tests with labels
cd ./test/e2e && ginkgo --label-filter="custom" -v -p .

.PHONY: setup-clusters
setup-clusters:
setup-clusters: ## Set up Kind clusters for E2E testing
cd ./test/e2e && chmod +x ./setup.sh && ./setup.sh $(MEMBER_CLUSTER_COUNT)

.PHONY: collect-e2e-logs
Expand All @@ -176,7 +176,7 @@ collect-e2e-logs: ## Collect logs from hub and member agent pods after e2e tests

## reviewable
.PHONY: reviewable
reviewable: fmt vet lint staticcheck
reviewable: fmt vet lint staticcheck ## Run all quality checks before PR
go mod tidy

## --------------------------------------
Expand All @@ -188,12 +188,12 @@ CRD_OPTIONS ?= "crd"

# Generate manifests e.g. CRD, RBAC etc.
.PHONY: manifests
manifests: $(CONTROLLER_GEN)
manifests: $(CONTROLLER_GEN) ## Generate CRDs and manifests
$(CONTROLLER_GEN) \
$(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./apis/..." output:crd:artifacts:config=config/crd/bases

# Generate code
generate: $(CONTROLLER_GEN)
generate: $(CONTROLLER_GEN) ## Generate deep copy methods
$(CONTROLLER_GEN) \
object:headerFile="hack/boilerplate.go.txt" paths="./..."

Expand All @@ -202,16 +202,16 @@ generate: $(CONTROLLER_GEN)
## --------------------------------------

.PHONY: build
build: generate fmt vet ## Build agent binaries.
build: generate fmt vet ## Build agent binaries
go build -o bin/hubagent cmd/hubagent/main.go
go build -o bin/memberagent cmd/memberagent/main.go

.PHONY: run-hubagent
run-hubagent: manifests generate fmt vet ## Run a controllers from your host.
run-hubagent: manifests generate fmt vet ## Run hub-agent from your host
go run ./cmd/hubagent/main.go

.PHONY: run-memberagent
run-memberagent: manifests generate fmt vet ## Run a controllers from your host.
run-memberagent: manifests generate fmt vet ## Run member-agent from your host
go run ./cmd/memberagent/main.go

## --------------------------------------
Expand All @@ -224,7 +224,7 @@ QEMU_VERSION ?= 7.2.0-1
BUILDKIT_VERSION ?= v0.18.1

.PHONY: push
push:
push: ## Build and push all Docker images
$(MAKE) OUTPUT_TYPE="type=registry" docker-build-hub-agent docker-build-member-agent docker-build-refresh-token

# By default, docker buildx create will pull image moby/buildkit:buildx-stable-1 and hit the too many requests error
Expand All @@ -250,7 +250,7 @@ docker-buildx-builder:
fi

.PHONY: docker-build-hub-agent
docker-build-hub-agent: docker-buildx-builder
docker-build-hub-agent: docker-buildx-builder ## Build hub-agent image
docker buildx build \
--file docker/$(HUB_AGENT_IMAGE_NAME).Dockerfile \
--output=$(OUTPUT_TYPE) \
Expand All @@ -262,7 +262,7 @@ docker-build-hub-agent: docker-buildx-builder
--build-arg GOOS=$(TARGET_OS) .

.PHONY: docker-build-member-agent
docker-build-member-agent: docker-buildx-builder
docker-build-member-agent: docker-buildx-builder ## Build member-agent image
docker buildx build \
--file docker/$(MEMBER_AGENT_IMAGE_NAME).Dockerfile \
--output=$(OUTPUT_TYPE) \
Expand All @@ -274,7 +274,7 @@ docker-build-member-agent: docker-buildx-builder
--build-arg GOOS=$(TARGET_OS) .

.PHONY: docker-build-refresh-token
docker-build-refresh-token: docker-buildx-builder
docker-build-refresh-token: docker-buildx-builder ## Build refresh-token image
docker buildx build \
--file docker/$(REFRESH_TOKEN_IMAGE_NAME).Dockerfile \
--output=$(OUTPUT_TYPE) \
Expand All @@ -295,5 +295,5 @@ clean-bin: ## Remove all generated binaries
rm -rf ./bin

.PHONY: clean-e2e-tests
clean-e2e-tests:
clean-e2e-tests: ## Clean up E2E test clusters
cd ./test/e2e && chmod +x ./stop.sh && ./stop.sh $(MEMBER_CLUSTER_COUNT)
Loading