Skip to content

Commit

Permalink
Dapr build flavors. (dapr#6290)
Browse files Browse the repository at this point in the history
* Dapr build flavors.

Signed-off-by: Artur Souza <[email protected]>

* Split unit test & lint + add darwin,win unit tests to worklow again.

Signed-off-by: Artur Souza <[email protected]>

---------

Signed-off-by: Artur Souza <[email protected]>
  • Loading branch information
artursouza authored Apr 27, 2023
1 parent 07a6e03 commit acb348d
Show file tree
Hide file tree
Showing 124 changed files with 576 additions and 123 deletions.
431 changes: 314 additions & 117 deletions .github/workflows/dapr.yml

Large diffs are not rendered by default.

24 changes: 18 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ BINARIES ?= daprd placement operator injector sentry
HA_MODE ?= false
# Force in-memory log for placement
FORCE_INMEM ?= true
# Go's build tags:
# all_components - includes all components in Dapr sidecar
# stable_components - includes all stable components in Dapr sidecar
DAPR_SIDECAR_FLAVOR ?= all
DAPR_GO_BUILD_TAGS = $(DAPR_SIDECAR_FLAVOR)_components

# Add latest tag if LATEST_RELEASE is true
LATEST_RELEASE ?=
Expand Down Expand Up @@ -176,7 +181,7 @@ build: $(DAPR_BINS)
define genBinariesForTarget
.PHONY: $(5)/$(1)
$(5)/$(1):
CGO_ENABLED=$(CGO) GOOS=$(3) GOARCH=$(4) go build $(GCFLAGS) -ldflags=$(LDFLAGS) \
CGO_ENABLED=$(CGO) GOOS=$(3) GOARCH=$(4) go build $(GCFLAGS) -ldflags=$(LDFLAGS) -tags=$(DAPR_GO_BUILD_TAGS) \
-o $(5)/$(1) $(2)/;
endef

Expand All @@ -199,8 +204,10 @@ endif
################################################################################
ARCHIVE_OUT_DIR ?= $(DAPR_OUT_DIR)
ARCHIVE_FILE_EXTS:=$(foreach ITEM,$(BINARIES),archive-$(ITEM)$(ARCHIVE_EXT))
ARCHIVE_FILE_FLAVOR_EXTS:=$(foreach ITEM,$(BINARIES),archive-$(ITEM)-$(DAPR_SIDECAR_FLAVOR)$(ARCHIVE_EXT))

archive: $(ARCHIVE_FILE_EXTS)
archive-flavor: $(ARCHIVE_FILE_FLAVOR_EXTS)

# Generate archive files for each binary
# $(1): the binary name to be archived
Expand All @@ -209,14 +216,18 @@ define genArchiveBinary
ifeq ($(GOOS),windows)
archive-$(1).zip:
7z.exe a -tzip "$(2)\\$(1)_$(GOOS)_$(GOARCH)$(ARCHIVE_EXT)" "$(DAPR_OUT_DIR)\\$(1)$(BINARY_EXT)"
archive-$(1)-$(3).zip:
7z.exe a -tzip "$(2)\\$(1)_$(GOOS)_$(GOARCH)-$(3)$(ARCHIVE_EXT)" "$(DAPR_OUT_DIR)\\$(1)$(BINARY_EXT)"
else
archive-$(1).tar.gz:
tar czf "$(2)/$(1)_$(GOOS)_$(GOARCH)$(ARCHIVE_EXT)" -C "$(DAPR_OUT_DIR)" "$(1)$(BINARY_EXT)"
archive-$(1)-$(3).tar.gz:
tar czf "$(2)/$(1)_$(GOOS)_$(GOARCH)-$(3)$(ARCHIVE_EXT)" -C "$(DAPR_OUT_DIR)" "$(1)$(BINARY_EXT)"
endif
endef

# Generate archive-*.[zip|tar.gz] targets
$(foreach ITEM,$(BINARIES),$(eval $(call genArchiveBinary,$(ITEM),$(ARCHIVE_OUT_DIR))))
$(foreach ITEM,$(BINARIES),$(eval $(call genArchiveBinary,$(ITEM),$(ARCHIVE_OUT_DIR),$(DAPR_SIDECAR_FLAVOR))))


################################################################################
Expand Down Expand Up @@ -276,6 +287,7 @@ docker-deploy-k8s: check-docker-env check-arch
# Target: archive #
################################################################################
release: build archive
release-flavor: build archive-flavor

################################################################################
# Target: test #
Expand All @@ -288,9 +300,9 @@ test: test-deps
--format standard-quiet \
-- \
./pkg/... ./utils/... ./cmd/... \
$(COVERAGE_OPTS) --tags=unit
$(COVERAGE_OPTS) --tags=unit,all_components
CGO_ENABLED=$(CGO) \
go test ./tests/...
go test --tags=all_components ./tests/...

################################################################################
# Target: test-race #
Expand Down Expand Up @@ -329,7 +341,7 @@ TEST_WITH_RACE=./pkg/acl/... \
.PHONY: test-race
test-race:
echo "$(TEST_WITH_RACE)" | xargs \
go test -tags=unit -race
go test -tags="all_components unit" -race

################################################################################
# Target: lint #
Expand All @@ -338,7 +350,7 @@ test-race:
# You can download version v1.51.2 at https://github.com/golangci/golangci-lint/releases/tag/v1.51.2
.PHONY: lint
lint:
$(GOLANGCI_LINT) run --timeout=20m
$(GOLANGCI_LINT) run --build-tags=all_components --timeout=20m

################################################################################
# Target: modtidy-all #
Expand Down
2 changes: 2 additions & 0 deletions cmd/daprd/components/binding_alicloud_oss.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build all_components

/*
Copyright 2021 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions cmd/daprd/components/binding_alicloud_sls.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build all_components

/*
Copyright 2021 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions cmd/daprd/components/binding_alicloud_tablestore.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build all_components

/*
Copyright 2021 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions cmd/daprd/components/binding_apns.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build all_components

/*
Copyright 2021 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions cmd/daprd/components/binding_aws_dynamodb.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build all_components

/*
Copyright 2021 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions cmd/daprd/components/binding_aws_kinesis.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build all_components

/*
Copyright 2021 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions cmd/daprd/components/binding_aws_s3.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build all_components

/*
Copyright 2021 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions cmd/daprd/components/binding_aws_ses.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build all_components

/*
Copyright 2021 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions cmd/daprd/components/binding_aws_sns.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build all_components

/*
Copyright 2021 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions cmd/daprd/components/binding_aws_sqs.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build all_components

/*
Copyright 2021 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions cmd/daprd/components/binding_azure_blobstorage.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build all_components || stable_components

/*
Copyright 2021 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions cmd/daprd/components/binding_azure_cosmosdb.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build all_components || stable_components

/*
Copyright 2021 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions cmd/daprd/components/binding_azure_cosmosdb_gremlinapi.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build all_components

/*
Copyright 2021 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions cmd/daprd/components/binding_azure_eventgrid.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build all_components

/*
Copyright 2021 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions cmd/daprd/components/binding_azure_eventhubs.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build all_components || stable_components

/*
Copyright 2021 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions cmd/daprd/components/binding_azure_servicebus_queues.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build all_components || stable_components

/*
Copyright 2021 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions cmd/daprd/components/binding_azure_signalr.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build all_components

/*
Copyright 2021 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions cmd/daprd/components/binding_azure_storagequeues.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build all_components || stable_components

/*
Copyright 2021 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions cmd/daprd/components/binding_cloudflare_queues.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build all_components

/*
Copyright 2021 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions cmd/daprd/components/binding_commercetools.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build all_components

/*
Copyright 2021 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions cmd/daprd/components/binding_cron.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build all_components || stable_components

/*
Copyright 2021 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions cmd/daprd/components/binding_dingtalk_webhook.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build all_components

/*
Copyright 2021 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions cmd/daprd/components/binding_dubbo.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build all_components

/*
Copyright 2021 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions cmd/daprd/components/binding_gcp_bucket.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build all_components

/*
Copyright 2021 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions cmd/daprd/components/binding_gcp_pubsub.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build all_components

/*
Copyright 2021 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions cmd/daprd/components/binding_graphql.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build all_components

/*
Copyright 2021 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions cmd/daprd/components/binding_http.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build all_components || stable_components

/*
Copyright 2021 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions cmd/daprd/components/binding_huawei_obs.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build all_components

/*
Copyright 2021 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions cmd/daprd/components/binding_influx.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build all_components

/*
Copyright 2021 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions cmd/daprd/components/binding_kafka.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build all_components || stable_components

/*
Copyright 2021 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions cmd/daprd/components/binding_kubemq.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build all_components

/*
Copyright 2021 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions cmd/daprd/components/binding_kubernetes.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build all_components

/*
Copyright 2021 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions cmd/daprd/components/binding_localstorage.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build all_components || stable_components

/*
Copyright 2021 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions cmd/daprd/components/binding_mqtt.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build all_components

/*
Copyright 2021 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions cmd/daprd/components/binding_mysql.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build all_components

/*
Copyright 2021 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions cmd/daprd/components/binding_postgres.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build all_components || stable_components

/*
Copyright 2021 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions cmd/daprd/components/binding_postmark.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build all_components

/*
Copyright 2021 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions cmd/daprd/components/binding_rabbitmq.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build all_components || stable_components

/*
Copyright 2021 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions cmd/daprd/components/binding_redis.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build all_components || stable_components

/*
Copyright 2021 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions cmd/daprd/components/binding_rethinkdb_statechange.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build all_components

/*
Copyright 2021 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions cmd/daprd/components/binding_smtp.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build all_components

/*
Copyright 2021 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions cmd/daprd/components/binding_twilio_sendgrid.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build all_components

/*
Copyright 2021 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions cmd/daprd/components/binding_twilio_sms.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build all_components

/*
Copyright 2021 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions cmd/daprd/components/binding_wasm.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build all_components

/*
Copyright 2023 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions cmd/daprd/components/binding_zeebe_command.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build all_components

/*
Copyright 2021 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions cmd/daprd/components/binding_zeebe_jobworker.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build all_components

/*
Copyright 2021 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions cmd/daprd/components/configuration_azure_appconfig.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build all_components

/*
Copyright 2021 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions cmd/daprd/components/configuration_postgres.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build all_components

/*
Copyright 2021 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions cmd/daprd/components/configuration_redis.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build all_components

/*
Copyright 2021 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions cmd/daprd/components/crypto_azure_keyvault.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build all_components

/*
Copyright 2023 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions cmd/daprd/components/crypto_dapr_jwks.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build all_components

/*
Copyright 2023 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
Loading

0 comments on commit acb348d

Please sign in to comment.