diff --git a/provider-ci/internal/pkg/config.go b/provider-ci/internal/pkg/config.go index d5233f363..ca65cd822 100644 --- a/provider-ci/internal/pkg/config.go +++ b/provider-ci/internal/pkg/config.go @@ -274,16 +274,30 @@ type Config struct { // // This function is responsible for creating a provider binary for the desired platform. // - // Use "$(1)" to refer to the desired output location. + // "$(1)" refers to the desired OS, in the same format as GOOS in the Go toolchain + // "$(2)" refers to the desired architecture, in the same format as GOARCH in the Go toolchain + // "$(3)" refers to the desired destination path for the binary // - // If a cross-compiling build is requested, the environment will have GOOS and GOARCH set. + // An example value for the command is: // - // The default value uses go build: - // - // cd provider && go build -o "$(1)" ... + // cd provider && GOOS=$(1) GOARCH=$(2) go build -o "$(3)" ... // // Customizing this value allows providers implemented in Node or other languages. BuildProviderCmd string `yaml:"buildProviderCmd"` + + // Customizes a hook to run right before BuildProviderCmd. + BuildProviderPre string `yaml:"buildProviderPre"` + + // Customizes the Make function test_provider_cmd. + // + // This function is called without arguments to run unit tests for the provider binary. + TestProviderCmd string `yaml:"testProviderCmd"` + + // Customizes the Make function renovate_cmd. + // + // This function is called by the make renovate target after the Renovate bot has finished updating + // project dependencies in a PR. It is responsible for rebuilding any generated files as needed. + RenovateCmd string `yaml:"renovateCmd"` } // LoadLocalConfig loads the provider configuration at the given path with diff --git a/provider-ci/internal/pkg/templates/bridged-provider/Makefile b/provider-ci/internal/pkg/templates/bridged-provider/Makefile index e9879eaaa..9c92d82f9 100644 --- a/provider-ci/internal/pkg/templates/bridged-provider/Makefile +++ b/provider-ci/internal/pkg/templates/bridged-provider/Makefile @@ -255,19 +255,27 @@ lint_provider.fix: cd provider && golangci-lint run --path-prefix provider -c ../.golangci.yml --fix .PHONY: lint_provider lint_provider.fix -# `make provider_no_deps` builds the provider binary directly, without ensuring that -# `cmd/pulumi-resource-#{{ .Config.Provider }}#/schema.json` is valid and up to date. -# To create a release ready binary, you should use `make provider`. #{{- if .Config.BuildProviderCmd }}# -build_provider_cmd = #{{ .Config.BuildProviderCmd }}# +build_provider_cmd = #{{ if .Config.BuildProviderPre -}}# + #{{ .Config.BuildProviderPre }}#; + #{{- end -}}# + #{{ .Config.BuildProviderCmd }}# #{{- else }}# -build_provider_cmd = cd provider && CGO_ENABLED=0 go build $(PULUMI_PROVIDER_BUILD_PARALLELISM) -o "$(1)" -ldflags "$(LDFLAGS)" $(PROJECT)/$(PROVIDER_PATH)/cmd/$(PROVIDER) +build_provider_cmd = #{{ if .Config.BuildProviderPre -}}# + #{{ .Config.BuildProviderPre }}#; + #{{- end -}}# + cd provider && GOOS=$(1) GOARCH=$(2) CGO_ENABLED=0 go build $(PULUMI_PROVIDER_BUILD_PARALLELISM) -o "$(3)" -ldflags "$(LDFLAGS)" $(PROJECT)/$(PROVIDER_PATH)/cmd/$(PROVIDER) #{{- end }}# + provider: bin/$(PROVIDER) + +# `make provider_no_deps` builds the provider binary directly, without ensuring that +# `cmd/pulumi-resource-#{{ .Config.Provider }}#/schema.json` is valid and up to date. +# To create a release ready binary, you should use `make provider`. provider_no_deps: - $(call build_provider_cmd,$(WORKING_DIR)/bin/$(PROVIDER)) + $(call build_provider_cmd,$(shell go env GOOS),$(shell go env GOARCH),$(WORKING_DIR)/bin/$(PROVIDER)) bin/$(PROVIDER): .make/schema - $(call build_provider_cmd,$(WORKING_DIR)/bin/$(PROVIDER)) + $(call build_provider_cmd,$(shell go env GOOS),$(shell go env GOARCH),$(WORKING_DIR)/bin/$(PROVIDER)) .PHONY: provider provider_no_deps test: export PATH := $(WORKING_DIR)/bin:$(PATH) @@ -275,12 +283,17 @@ test: cd examples && go test -v -tags=all -parallel $(TESTPARALLELISM) -timeout 2h .PHONY: test +#{{- if .Config.TestProviderCmd }}# +test_provider_cmd = #{{ .Config.TestProviderCmd }}# +#{{- else }}# +test_provider_cmd = cd provider && go test -v -short \ + -coverprofile="coverage.txt" \ + -coverpkg="./...,github.com/hashicorp/terraform-provider-..." \ + -parallel $(TESTPARALLELISM) \ + ./... +#{{- end }}# test_provider: - cd provider && go test -v -short \ - -coverprofile="coverage.txt" \ - -coverpkg="./...,github.com/hashicorp/terraform-provider-..." \ - -parallel $(TESTPARALLELISM) \ - ./... + $(call test_provider_cmd) .PHONY: test_provider tfgen: schema @@ -370,18 +383,18 @@ SKIP_SIGNING ?= # These targets assume that the schema-embed.json exists - it's generated by tfgen. # We disable CGO to ensure that the binary is statically linked. -bin/linux-amd64/$(PROVIDER): export GOOS := linux -bin/linux-amd64/$(PROVIDER): export GOARCH := amd64 -bin/linux-arm64/$(PROVIDER): export GOOS := linux -bin/linux-arm64/$(PROVIDER): export GOARCH := arm64 -bin/darwin-amd64/$(PROVIDER): export GOOS := darwin -bin/darwin-amd64/$(PROVIDER): export GOARCH := amd64 -bin/darwin-arm64/$(PROVIDER): export GOOS := darwin -bin/darwin-arm64/$(PROVIDER): export GOARCH := arm64 -bin/windows-amd64/$(PROVIDER).exe: export GOOS := windows -bin/windows-amd64/$(PROVIDER).exe: export GOARCH := amd64 +bin/linux-amd64/$(PROVIDER): GOOS := linux +bin/linux-amd64/$(PROVIDER): GOARCH := amd64 +bin/linux-arm64/$(PROVIDER): GOOS := linux +bin/linux-arm64/$(PROVIDER): GOARCH := arm64 +bin/darwin-amd64/$(PROVIDER): GOOS := darwin +bin/darwin-amd64/$(PROVIDER): GOARCH := amd64 +bin/darwin-arm64/$(PROVIDER): GOOS := darwin +bin/darwin-arm64/$(PROVIDER): GOARCH := arm64 +bin/windows-amd64/$(PROVIDER).exe: GOOS := windows +bin/windows-amd64/$(PROVIDER).exe: GOARCH := amd64 bin/%/$(PROVIDER) bin/%/$(PROVIDER).exe: bin/jsign-6.0.jar - $(call build_provider_cmd,$(WORKING_DIR)/$@) + $(call build_provider_cmd,$(GOOS),$(GOARCH),$(WORKING_DIR)/$@) @# Only sign windows binary if fully configured. @# Test variables set by joining with | between and looking for || showing at least one variable is empty. @@ -440,5 +453,12 @@ provider_dist-windows-amd64: bin/$(PROVIDER)-v$(VERSION_GENERIC)-windows-amd64.t provider_dist: provider_dist-linux-amd64 provider_dist-linux-arm64 provider_dist-darwin-amd64 provider_dist-darwin-arm64 provider_dist-windows-amd64 .PHONY: provider_dist-linux-amd64 provider_dist-linux-arm64 provider_dist-darwin-amd64 provider_dist-darwin-arm64 provider_dist-windows-amd64 provider_dist +#{{- if .Config.RenovateCmd }}# +renovate_cmd = #{{ .Config.RenovateCmd }}# +renovate: + $(call renovate_cmd) +.PHONY: renovate +#{{- end }}# + # Permit providers to extend the Makefile with provider-specific Make includes. include $(wildcard .mk/*.mk) diff --git a/provider-ci/test-providers/acme/Makefile b/provider-ci/test-providers/acme/Makefile index aa8bd5609..1948bbf18 100644 --- a/provider-ci/test-providers/acme/Makefile +++ b/provider-ci/test-providers/acme/Makefile @@ -214,29 +214,30 @@ lint_provider: provider lint_provider.fix: cd provider && golangci-lint run --path-prefix provider -c ../.golangci.yml --fix .PHONY: lint_provider lint_provider.fix +build_provider_cmd = cd provider && GOOS=$(1) GOARCH=$(2) CGO_ENABLED=0 go build $(PULUMI_PROVIDER_BUILD_PARALLELISM) -o "$(3)" -ldflags "$(LDFLAGS)" $(PROJECT)/$(PROVIDER_PATH)/cmd/$(PROVIDER) + +provider: bin/$(PROVIDER) # `make provider_no_deps` builds the provider binary directly, without ensuring that # `cmd/pulumi-resource-acme/schema.json` is valid and up to date. # To create a release ready binary, you should use `make provider`. -build_provider_cmd = cd provider && CGO_ENABLED=0 go build $(PULUMI_PROVIDER_BUILD_PARALLELISM) -o "$(1)" -ldflags "$(LDFLAGS)" $(PROJECT)/$(PROVIDER_PATH)/cmd/$(PROVIDER) -provider: bin/$(PROVIDER) provider_no_deps: - $(call build_provider_cmd,$(WORKING_DIR)/bin/$(PROVIDER)) + $(call build_provider_cmd,$(shell go env GOOS),$(shell go env GOARCH),$(WORKING_DIR)/bin/$(PROVIDER)) bin/$(PROVIDER): .make/schema - $(call build_provider_cmd,$(WORKING_DIR)/bin/$(PROVIDER)) + $(call build_provider_cmd,$(shell go env GOOS),$(shell go env GOARCH),$(WORKING_DIR)/bin/$(PROVIDER)) .PHONY: provider provider_no_deps test: export PATH := $(WORKING_DIR)/bin:$(PATH) test: cd examples && go test -v -tags=all -parallel $(TESTPARALLELISM) -timeout 2h .PHONY: test - +test_provider_cmd = cd provider && go test -v -short \ + -coverprofile="coverage.txt" \ + -coverpkg="./...,github.com/hashicorp/terraform-provider-..." \ + -parallel $(TESTPARALLELISM) \ + ./... test_provider: - cd provider && go test -v -short \ - -coverprofile="coverage.txt" \ - -coverpkg="./...,github.com/hashicorp/terraform-provider-..." \ - -parallel $(TESTPARALLELISM) \ - ./... + $(call test_provider_cmd) .PHONY: test_provider tfgen: schema @@ -315,18 +316,18 @@ SKIP_SIGNING ?= # These targets assume that the schema-embed.json exists - it's generated by tfgen. # We disable CGO to ensure that the binary is statically linked. -bin/linux-amd64/$(PROVIDER): export GOOS := linux -bin/linux-amd64/$(PROVIDER): export GOARCH := amd64 -bin/linux-arm64/$(PROVIDER): export GOOS := linux -bin/linux-arm64/$(PROVIDER): export GOARCH := arm64 -bin/darwin-amd64/$(PROVIDER): export GOOS := darwin -bin/darwin-amd64/$(PROVIDER): export GOARCH := amd64 -bin/darwin-arm64/$(PROVIDER): export GOOS := darwin -bin/darwin-arm64/$(PROVIDER): export GOARCH := arm64 -bin/windows-amd64/$(PROVIDER).exe: export GOOS := windows -bin/windows-amd64/$(PROVIDER).exe: export GOARCH := amd64 +bin/linux-amd64/$(PROVIDER): GOOS := linux +bin/linux-amd64/$(PROVIDER): GOARCH := amd64 +bin/linux-arm64/$(PROVIDER): GOOS := linux +bin/linux-arm64/$(PROVIDER): GOARCH := arm64 +bin/darwin-amd64/$(PROVIDER): GOOS := darwin +bin/darwin-amd64/$(PROVIDER): GOARCH := amd64 +bin/darwin-arm64/$(PROVIDER): GOOS := darwin +bin/darwin-arm64/$(PROVIDER): GOARCH := arm64 +bin/windows-amd64/$(PROVIDER).exe: GOOS := windows +bin/windows-amd64/$(PROVIDER).exe: GOARCH := amd64 bin/%/$(PROVIDER) bin/%/$(PROVIDER).exe: bin/jsign-6.0.jar - $(call build_provider_cmd,$(WORKING_DIR)/$@) + $(call build_provider_cmd,$(GOOS),$(GOARCH),$(WORKING_DIR)/$@) @# Only sign windows binary if fully configured. @# Test variables set by joining with | between and looking for || showing at least one variable is empty. diff --git a/provider-ci/test-providers/aws/Makefile b/provider-ci/test-providers/aws/Makefile index 41e4e5564..dfb89c174 100644 --- a/provider-ci/test-providers/aws/Makefile +++ b/provider-ci/test-providers/aws/Makefile @@ -224,29 +224,30 @@ lint_provider: provider lint_provider.fix: cd provider && golangci-lint run --path-prefix provider -c ../.golangci.yml --fix .PHONY: lint_provider lint_provider.fix +build_provider_cmd = cd provider && GOOS=$(1) GOARCH=$(2) CGO_ENABLED=0 go build $(PULUMI_PROVIDER_BUILD_PARALLELISM) -o "$(3)" -ldflags "$(LDFLAGS)" $(PROJECT)/$(PROVIDER_PATH)/cmd/$(PROVIDER) + +provider: bin/$(PROVIDER) # `make provider_no_deps` builds the provider binary directly, without ensuring that # `cmd/pulumi-resource-aws/schema.json` is valid and up to date. # To create a release ready binary, you should use `make provider`. -build_provider_cmd = cd provider && CGO_ENABLED=0 go build $(PULUMI_PROVIDER_BUILD_PARALLELISM) -o "$(1)" -ldflags "$(LDFLAGS)" $(PROJECT)/$(PROVIDER_PATH)/cmd/$(PROVIDER) -provider: bin/$(PROVIDER) provider_no_deps: - $(call build_provider_cmd,$(WORKING_DIR)/bin/$(PROVIDER)) + $(call build_provider_cmd,$(shell go env GOOS),$(shell go env GOARCH),$(WORKING_DIR)/bin/$(PROVIDER)) bin/$(PROVIDER): .make/schema - $(call build_provider_cmd,$(WORKING_DIR)/bin/$(PROVIDER)) + $(call build_provider_cmd,$(shell go env GOOS),$(shell go env GOARCH),$(WORKING_DIR)/bin/$(PROVIDER)) .PHONY: provider provider_no_deps test: export PATH := $(WORKING_DIR)/bin:$(PATH) test: cd examples && go test -v -tags=all -parallel $(TESTPARALLELISM) -timeout 2h .PHONY: test - +test_provider_cmd = cd provider && go test -v -short \ + -coverprofile="coverage.txt" \ + -coverpkg="./...,github.com/hashicorp/terraform-provider-..." \ + -parallel $(TESTPARALLELISM) \ + ./... test_provider: - cd provider && go test -v -short \ - -coverprofile="coverage.txt" \ - -coverpkg="./...,github.com/hashicorp/terraform-provider-..." \ - -parallel $(TESTPARALLELISM) \ - ./... + $(call test_provider_cmd) .PHONY: test_provider tfgen: schema @@ -329,18 +330,18 @@ SKIP_SIGNING ?= # These targets assume that the schema-embed.json exists - it's generated by tfgen. # We disable CGO to ensure that the binary is statically linked. -bin/linux-amd64/$(PROVIDER): export GOOS := linux -bin/linux-amd64/$(PROVIDER): export GOARCH := amd64 -bin/linux-arm64/$(PROVIDER): export GOOS := linux -bin/linux-arm64/$(PROVIDER): export GOARCH := arm64 -bin/darwin-amd64/$(PROVIDER): export GOOS := darwin -bin/darwin-amd64/$(PROVIDER): export GOARCH := amd64 -bin/darwin-arm64/$(PROVIDER): export GOOS := darwin -bin/darwin-arm64/$(PROVIDER): export GOARCH := arm64 -bin/windows-amd64/$(PROVIDER).exe: export GOOS := windows -bin/windows-amd64/$(PROVIDER).exe: export GOARCH := amd64 +bin/linux-amd64/$(PROVIDER): GOOS := linux +bin/linux-amd64/$(PROVIDER): GOARCH := amd64 +bin/linux-arm64/$(PROVIDER): GOOS := linux +bin/linux-arm64/$(PROVIDER): GOARCH := arm64 +bin/darwin-amd64/$(PROVIDER): GOOS := darwin +bin/darwin-amd64/$(PROVIDER): GOARCH := amd64 +bin/darwin-arm64/$(PROVIDER): GOOS := darwin +bin/darwin-arm64/$(PROVIDER): GOARCH := arm64 +bin/windows-amd64/$(PROVIDER).exe: GOOS := windows +bin/windows-amd64/$(PROVIDER).exe: GOARCH := amd64 bin/%/$(PROVIDER) bin/%/$(PROVIDER).exe: bin/jsign-6.0.jar - $(call build_provider_cmd,$(WORKING_DIR)/$@) + $(call build_provider_cmd,$(GOOS),$(GOARCH),$(WORKING_DIR)/$@) @# Only sign windows binary if fully configured. @# Test variables set by joining with | between and looking for || showing at least one variable is empty. diff --git a/provider-ci/test-providers/cloudflare/Makefile b/provider-ci/test-providers/cloudflare/Makefile index 1298ddc2d..951966048 100644 --- a/provider-ci/test-providers/cloudflare/Makefile +++ b/provider-ci/test-providers/cloudflare/Makefile @@ -224,29 +224,30 @@ lint_provider: provider lint_provider.fix: cd provider && golangci-lint run --path-prefix provider -c ../.golangci.yml --fix .PHONY: lint_provider lint_provider.fix +build_provider_cmd = cd provider && GOOS=$(1) GOARCH=$(2) CGO_ENABLED=0 go build $(PULUMI_PROVIDER_BUILD_PARALLELISM) -o "$(3)" -ldflags "$(LDFLAGS)" $(PROJECT)/$(PROVIDER_PATH)/cmd/$(PROVIDER) + +provider: bin/$(PROVIDER) # `make provider_no_deps` builds the provider binary directly, without ensuring that # `cmd/pulumi-resource-cloudflare/schema.json` is valid and up to date. # To create a release ready binary, you should use `make provider`. -build_provider_cmd = cd provider && CGO_ENABLED=0 go build $(PULUMI_PROVIDER_BUILD_PARALLELISM) -o "$(1)" -ldflags "$(LDFLAGS)" $(PROJECT)/$(PROVIDER_PATH)/cmd/$(PROVIDER) -provider: bin/$(PROVIDER) provider_no_deps: - $(call build_provider_cmd,$(WORKING_DIR)/bin/$(PROVIDER)) + $(call build_provider_cmd,$(shell go env GOOS),$(shell go env GOARCH),$(WORKING_DIR)/bin/$(PROVIDER)) bin/$(PROVIDER): .make/schema - $(call build_provider_cmd,$(WORKING_DIR)/bin/$(PROVIDER)) + $(call build_provider_cmd,$(shell go env GOOS),$(shell go env GOARCH),$(WORKING_DIR)/bin/$(PROVIDER)) .PHONY: provider provider_no_deps test: export PATH := $(WORKING_DIR)/bin:$(PATH) test: cd examples && go test -v -tags=all -parallel $(TESTPARALLELISM) -timeout 2h .PHONY: test - +test_provider_cmd = cd provider && go test -v -short \ + -coverprofile="coverage.txt" \ + -coverpkg="./...,github.com/hashicorp/terraform-provider-..." \ + -parallel $(TESTPARALLELISM) \ + ./... test_provider: - cd provider && go test -v -short \ - -coverprofile="coverage.txt" \ - -coverpkg="./...,github.com/hashicorp/terraform-provider-..." \ - -parallel $(TESTPARALLELISM) \ - ./... + $(call test_provider_cmd) .PHONY: test_provider tfgen: schema @@ -325,18 +326,18 @@ SKIP_SIGNING ?= # These targets assume that the schema-embed.json exists - it's generated by tfgen. # We disable CGO to ensure that the binary is statically linked. -bin/linux-amd64/$(PROVIDER): export GOOS := linux -bin/linux-amd64/$(PROVIDER): export GOARCH := amd64 -bin/linux-arm64/$(PROVIDER): export GOOS := linux -bin/linux-arm64/$(PROVIDER): export GOARCH := arm64 -bin/darwin-amd64/$(PROVIDER): export GOOS := darwin -bin/darwin-amd64/$(PROVIDER): export GOARCH := amd64 -bin/darwin-arm64/$(PROVIDER): export GOOS := darwin -bin/darwin-arm64/$(PROVIDER): export GOARCH := arm64 -bin/windows-amd64/$(PROVIDER).exe: export GOOS := windows -bin/windows-amd64/$(PROVIDER).exe: export GOARCH := amd64 +bin/linux-amd64/$(PROVIDER): GOOS := linux +bin/linux-amd64/$(PROVIDER): GOARCH := amd64 +bin/linux-arm64/$(PROVIDER): GOOS := linux +bin/linux-arm64/$(PROVIDER): GOARCH := arm64 +bin/darwin-amd64/$(PROVIDER): GOOS := darwin +bin/darwin-amd64/$(PROVIDER): GOARCH := amd64 +bin/darwin-arm64/$(PROVIDER): GOOS := darwin +bin/darwin-arm64/$(PROVIDER): GOARCH := arm64 +bin/windows-amd64/$(PROVIDER).exe: GOOS := windows +bin/windows-amd64/$(PROVIDER).exe: GOARCH := amd64 bin/%/$(PROVIDER) bin/%/$(PROVIDER).exe: bin/jsign-6.0.jar - $(call build_provider_cmd,$(WORKING_DIR)/$@) + $(call build_provider_cmd,$(GOOS),$(GOARCH),$(WORKING_DIR)/$@) @# Only sign windows binary if fully configured. @# Test variables set by joining with | between and looking for || showing at least one variable is empty. diff --git a/provider-ci/test-providers/docker/Makefile b/provider-ci/test-providers/docker/Makefile index 1449a3475..89004926e 100644 --- a/provider-ci/test-providers/docker/Makefile +++ b/provider-ci/test-providers/docker/Makefile @@ -227,29 +227,30 @@ lint_provider: provider lint_provider.fix: cd provider && golangci-lint run --path-prefix provider -c ../.golangci.yml --fix .PHONY: lint_provider lint_provider.fix +build_provider_cmd = cd provider && GOOS=$(1) GOARCH=$(2) CGO_ENABLED=0 go build $(PULUMI_PROVIDER_BUILD_PARALLELISM) -o "$(3)" -ldflags "$(LDFLAGS)" $(PROJECT)/$(PROVIDER_PATH)/cmd/$(PROVIDER) + +provider: bin/$(PROVIDER) # `make provider_no_deps` builds the provider binary directly, without ensuring that # `cmd/pulumi-resource-docker/schema.json` is valid and up to date. # To create a release ready binary, you should use `make provider`. -build_provider_cmd = cd provider && CGO_ENABLED=0 go build $(PULUMI_PROVIDER_BUILD_PARALLELISM) -o "$(1)" -ldflags "$(LDFLAGS)" $(PROJECT)/$(PROVIDER_PATH)/cmd/$(PROVIDER) -provider: bin/$(PROVIDER) provider_no_deps: - $(call build_provider_cmd,$(WORKING_DIR)/bin/$(PROVIDER)) + $(call build_provider_cmd,$(shell go env GOOS),$(shell go env GOARCH),$(WORKING_DIR)/bin/$(PROVIDER)) bin/$(PROVIDER): .make/schema - $(call build_provider_cmd,$(WORKING_DIR)/bin/$(PROVIDER)) + $(call build_provider_cmd,$(shell go env GOOS),$(shell go env GOARCH),$(WORKING_DIR)/bin/$(PROVIDER)) .PHONY: provider provider_no_deps test: export PATH := $(WORKING_DIR)/bin:$(PATH) test: cd examples && go test -v -tags=all -parallel $(TESTPARALLELISM) -timeout 2h .PHONY: test - +test_provider_cmd = cd provider && go test -v -short \ + -coverprofile="coverage.txt" \ + -coverpkg="./...,github.com/hashicorp/terraform-provider-..." \ + -parallel $(TESTPARALLELISM) \ + ./... test_provider: - cd provider && go test -v -short \ - -coverprofile="coverage.txt" \ - -coverpkg="./...,github.com/hashicorp/terraform-provider-..." \ - -parallel $(TESTPARALLELISM) \ - ./... + $(call test_provider_cmd) .PHONY: test_provider tfgen: schema @@ -328,18 +329,18 @@ SKIP_SIGNING ?= # These targets assume that the schema-embed.json exists - it's generated by tfgen. # We disable CGO to ensure that the binary is statically linked. -bin/linux-amd64/$(PROVIDER): export GOOS := linux -bin/linux-amd64/$(PROVIDER): export GOARCH := amd64 -bin/linux-arm64/$(PROVIDER): export GOOS := linux -bin/linux-arm64/$(PROVIDER): export GOARCH := arm64 -bin/darwin-amd64/$(PROVIDER): export GOOS := darwin -bin/darwin-amd64/$(PROVIDER): export GOARCH := amd64 -bin/darwin-arm64/$(PROVIDER): export GOOS := darwin -bin/darwin-arm64/$(PROVIDER): export GOARCH := arm64 -bin/windows-amd64/$(PROVIDER).exe: export GOOS := windows -bin/windows-amd64/$(PROVIDER).exe: export GOARCH := amd64 +bin/linux-amd64/$(PROVIDER): GOOS := linux +bin/linux-amd64/$(PROVIDER): GOARCH := amd64 +bin/linux-arm64/$(PROVIDER): GOOS := linux +bin/linux-arm64/$(PROVIDER): GOARCH := arm64 +bin/darwin-amd64/$(PROVIDER): GOOS := darwin +bin/darwin-amd64/$(PROVIDER): GOARCH := amd64 +bin/darwin-arm64/$(PROVIDER): GOOS := darwin +bin/darwin-arm64/$(PROVIDER): GOARCH := arm64 +bin/windows-amd64/$(PROVIDER).exe: GOOS := windows +bin/windows-amd64/$(PROVIDER).exe: GOARCH := amd64 bin/%/$(PROVIDER) bin/%/$(PROVIDER).exe: bin/jsign-6.0.jar - $(call build_provider_cmd,$(WORKING_DIR)/$@) + $(call build_provider_cmd,$(GOOS),$(GOARCH),$(WORKING_DIR)/$@) @# Only sign windows binary if fully configured. @# Test variables set by joining with | between and looking for || showing at least one variable is empty. diff --git a/provider-ci/test-providers/eks/.ci-mgmt.yaml b/provider-ci/test-providers/eks/.ci-mgmt.yaml index 23c7d95db..5df4529b1 100644 --- a/provider-ci/test-providers/eks/.ci-mgmt.yaml +++ b/provider-ci/test-providers/eks/.ci-mgmt.yaml @@ -23,3 +23,4 @@ env: PULUMI_LOCAL_NUGET: ${{ github.workspace }}/nuget template: generic freeDiskSpaceBeforeTest: true # TODO: https://github.com/pulumi/pulumi/issues/17718 +buildProviderPre: echo building-provider diff --git a/provider-ci/test-providers/eks/Makefile b/provider-ci/test-providers/eks/Makefile index 9990038c9..6f2db5017 100644 --- a/provider-ci/test-providers/eks/Makefile +++ b/provider-ci/test-providers/eks/Makefile @@ -214,29 +214,30 @@ lint_provider: provider lint_provider.fix: cd provider && golangci-lint run --path-prefix provider -c ../.golangci.yml --fix .PHONY: lint_provider lint_provider.fix +build_provider_cmd = echo building-provider;cd provider && GOOS=$(1) GOARCH=$(2) CGO_ENABLED=0 go build $(PULUMI_PROVIDER_BUILD_PARALLELISM) -o "$(3)" -ldflags "$(LDFLAGS)" $(PROJECT)/$(PROVIDER_PATH)/cmd/$(PROVIDER) + +provider: bin/$(PROVIDER) # `make provider_no_deps` builds the provider binary directly, without ensuring that # `cmd/pulumi-resource-eks/schema.json` is valid and up to date. # To create a release ready binary, you should use `make provider`. -build_provider_cmd = cd provider && CGO_ENABLED=0 go build $(PULUMI_PROVIDER_BUILD_PARALLELISM) -o "$(1)" -ldflags "$(LDFLAGS)" $(PROJECT)/$(PROVIDER_PATH)/cmd/$(PROVIDER) -provider: bin/$(PROVIDER) provider_no_deps: - $(call build_provider_cmd,$(WORKING_DIR)/bin/$(PROVIDER)) + $(call build_provider_cmd,$(shell go env GOOS),$(shell go env GOARCH),$(WORKING_DIR)/bin/$(PROVIDER)) bin/$(PROVIDER): .make/schema - $(call build_provider_cmd,$(WORKING_DIR)/bin/$(PROVIDER)) + $(call build_provider_cmd,$(shell go env GOOS),$(shell go env GOARCH),$(WORKING_DIR)/bin/$(PROVIDER)) .PHONY: provider provider_no_deps test: export PATH := $(WORKING_DIR)/bin:$(PATH) test: cd examples && go test -v -tags=all -parallel $(TESTPARALLELISM) -timeout 2h .PHONY: test - +test_provider_cmd = cd provider && go test -v -short \ + -coverprofile="coverage.txt" \ + -coverpkg="./...,github.com/hashicorp/terraform-provider-..." \ + -parallel $(TESTPARALLELISM) \ + ./... test_provider: - cd provider && go test -v -short \ - -coverprofile="coverage.txt" \ - -coverpkg="./...,github.com/hashicorp/terraform-provider-..." \ - -parallel $(TESTPARALLELISM) \ - ./... + $(call test_provider_cmd) .PHONY: test_provider tfgen: schema @@ -310,18 +311,18 @@ SKIP_SIGNING ?= # These targets assume that the schema-embed.json exists - it's generated by tfgen. # We disable CGO to ensure that the binary is statically linked. -bin/linux-amd64/$(PROVIDER): export GOOS := linux -bin/linux-amd64/$(PROVIDER): export GOARCH := amd64 -bin/linux-arm64/$(PROVIDER): export GOOS := linux -bin/linux-arm64/$(PROVIDER): export GOARCH := arm64 -bin/darwin-amd64/$(PROVIDER): export GOOS := darwin -bin/darwin-amd64/$(PROVIDER): export GOARCH := amd64 -bin/darwin-arm64/$(PROVIDER): export GOOS := darwin -bin/darwin-arm64/$(PROVIDER): export GOARCH := arm64 -bin/windows-amd64/$(PROVIDER).exe: export GOOS := windows -bin/windows-amd64/$(PROVIDER).exe: export GOARCH := amd64 +bin/linux-amd64/$(PROVIDER): GOOS := linux +bin/linux-amd64/$(PROVIDER): GOARCH := amd64 +bin/linux-arm64/$(PROVIDER): GOOS := linux +bin/linux-arm64/$(PROVIDER): GOARCH := arm64 +bin/darwin-amd64/$(PROVIDER): GOOS := darwin +bin/darwin-amd64/$(PROVIDER): GOARCH := amd64 +bin/darwin-arm64/$(PROVIDER): GOOS := darwin +bin/darwin-arm64/$(PROVIDER): GOARCH := arm64 +bin/windows-amd64/$(PROVIDER).exe: GOOS := windows +bin/windows-amd64/$(PROVIDER).exe: GOARCH := amd64 bin/%/$(PROVIDER) bin/%/$(PROVIDER).exe: bin/jsign-6.0.jar - $(call build_provider_cmd,$(WORKING_DIR)/$@) + $(call build_provider_cmd,$(GOOS),$(GOARCH),$(WORKING_DIR)/$@) @# Only sign windows binary if fully configured. @# Test variables set by joining with | between and looking for || showing at least one variable is empty.