From 0b5372dbb6a9ea907fd8ce20c75b5e8471c95976 Mon Sep 17 00:00:00 2001 From: Anton Tayanovskyy Date: Wed, 15 Jan 2025 10:55:21 -0500 Subject: [PATCH 01/10] Make build_provider_cmd extension point more explicit --- provider-ci/internal/pkg/config.go | 10 +++---- .../pkg/templates/bridged-provider/Makefile | 28 +++++++++---------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/provider-ci/internal/pkg/config.go b/provider-ci/internal/pkg/config.go index d5233f363..cc0b5b752 100644 --- a/provider-ci/internal/pkg/config.go +++ b/provider-ci/internal/pkg/config.go @@ -274,13 +274,13 @@ 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"` diff --git a/provider-ci/internal/pkg/templates/bridged-provider/Makefile b/provider-ci/internal/pkg/templates/bridged-provider/Makefile index e9879eaaa..56f24fecd 100644 --- a/provider-ci/internal/pkg/templates/bridged-provider/Makefile +++ b/provider-ci/internal/pkg/templates/bridged-provider/Makefile @@ -261,13 +261,13 @@ lint_provider.fix: #{{- if .Config.BuildProviderCmd }}# build_provider_cmd = #{{ .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 = 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) 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) @@ -370,18 +370,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. From 6e05216ed442e6d75070f25ea41d677806c645a9 Mon Sep 17 00:00:00 2001 From: Anton Tayanovskyy Date: Wed, 15 Jan 2025 10:58:25 -0500 Subject: [PATCH 02/10] make --- provider-ci/test-providers/acme/Makefile | 28 +++++++++---------- provider-ci/test-providers/aws/Makefile | 28 +++++++++---------- .../test-providers/cloudflare/Makefile | 28 +++++++++---------- provider-ci/test-providers/docker/Makefile | 28 +++++++++---------- provider-ci/test-providers/eks/Makefile | 28 +++++++++---------- 5 files changed, 70 insertions(+), 70 deletions(-) diff --git a/provider-ci/test-providers/acme/Makefile b/provider-ci/test-providers/acme/Makefile index aa8bd5609..d2c41789d 100644 --- a/provider-ci/test-providers/acme/Makefile +++ b/provider-ci/test-providers/acme/Makefile @@ -218,12 +218,12 @@ lint_provider.fix: # `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) +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) 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) @@ -315,18 +315,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..6a23e1bc6 100644 --- a/provider-ci/test-providers/aws/Makefile +++ b/provider-ci/test-providers/aws/Makefile @@ -228,12 +228,12 @@ lint_provider.fix: # `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) +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) 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) @@ -329,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/cloudflare/Makefile b/provider-ci/test-providers/cloudflare/Makefile index 1298ddc2d..d5642c1dc 100644 --- a/provider-ci/test-providers/cloudflare/Makefile +++ b/provider-ci/test-providers/cloudflare/Makefile @@ -228,12 +228,12 @@ lint_provider.fix: # `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) +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) 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) @@ -325,18 +325,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..cbc41b3b4 100644 --- a/provider-ci/test-providers/docker/Makefile +++ b/provider-ci/test-providers/docker/Makefile @@ -231,12 +231,12 @@ lint_provider.fix: # `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) +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) 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) @@ -328,18 +328,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/Makefile b/provider-ci/test-providers/eks/Makefile index 9990038c9..d9c6287da 100644 --- a/provider-ci/test-providers/eks/Makefile +++ b/provider-ci/test-providers/eks/Makefile @@ -218,12 +218,12 @@ lint_provider.fix: # `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) +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) 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) @@ -310,18 +310,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. From 3f082b54936d8adf818a695d8f0e5d18014fbc59 Mon Sep 17 00:00:00 2001 From: Anton Tayanovskyy Date: Wed, 15 Jan 2025 11:02:37 -0500 Subject: [PATCH 03/10] Customize how the provider is tested --- provider-ci/internal/pkg/config.go | 5 +++++ .../pkg/templates/bridged-provider/Makefile | 15 ++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/provider-ci/internal/pkg/config.go b/provider-ci/internal/pkg/config.go index cc0b5b752..e8969b3d2 100644 --- a/provider-ci/internal/pkg/config.go +++ b/provider-ci/internal/pkg/config.go @@ -284,6 +284,11 @@ type Config struct { // // Customizing this value allows providers implemented in Node or other languages. BuildProviderCmd string `yaml:"buildProviderCmd"` + + // 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"` } // 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 56f24fecd..b4bd6b649 100644 --- a/provider-ci/internal/pkg/templates/bridged-provider/Makefile +++ b/provider-ci/internal/pkg/templates/bridged-provider/Makefile @@ -275,12 +275,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 From 0bafe9bb4b83f663bb9de7ef4d0eeaefd02e5d16 Mon Sep 17 00:00:00 2001 From: Anton Tayanovskyy Date: Wed, 15 Jan 2025 11:02:46 -0500 Subject: [PATCH 04/10] make --- provider-ci/test-providers/acme/Makefile | 12 ++++++------ provider-ci/test-providers/aws/Makefile | 12 ++++++------ provider-ci/test-providers/cloudflare/Makefile | 12 ++++++------ provider-ci/test-providers/docker/Makefile | 12 ++++++------ provider-ci/test-providers/eks/Makefile | 12 ++++++------ 5 files changed, 30 insertions(+), 30 deletions(-) diff --git a/provider-ci/test-providers/acme/Makefile b/provider-ci/test-providers/acme/Makefile index d2c41789d..01e8571ba 100644 --- a/provider-ci/test-providers/acme/Makefile +++ b/provider-ci/test-providers/acme/Makefile @@ -230,13 +230,13 @@ 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 diff --git a/provider-ci/test-providers/aws/Makefile b/provider-ci/test-providers/aws/Makefile index 6a23e1bc6..f2b07d3bd 100644 --- a/provider-ci/test-providers/aws/Makefile +++ b/provider-ci/test-providers/aws/Makefile @@ -240,13 +240,13 @@ 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 diff --git a/provider-ci/test-providers/cloudflare/Makefile b/provider-ci/test-providers/cloudflare/Makefile index d5642c1dc..36e726693 100644 --- a/provider-ci/test-providers/cloudflare/Makefile +++ b/provider-ci/test-providers/cloudflare/Makefile @@ -240,13 +240,13 @@ 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 diff --git a/provider-ci/test-providers/docker/Makefile b/provider-ci/test-providers/docker/Makefile index cbc41b3b4..05d04e49a 100644 --- a/provider-ci/test-providers/docker/Makefile +++ b/provider-ci/test-providers/docker/Makefile @@ -243,13 +243,13 @@ 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 diff --git a/provider-ci/test-providers/eks/Makefile b/provider-ci/test-providers/eks/Makefile index d9c6287da..5d31830ef 100644 --- a/provider-ci/test-providers/eks/Makefile +++ b/provider-ci/test-providers/eks/Makefile @@ -230,13 +230,13 @@ 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 From b8e723b7874c73c280c09425b7df972ed253f01f Mon Sep 17 00:00:00 2001 From: Anton Tayanovskyy Date: Wed, 15 Jan 2025 11:07:42 -0500 Subject: [PATCH 05/10] Allow customizing renovate_cmd --- provider-ci/internal/pkg/config.go | 6 ++++++ .../internal/pkg/templates/bridged-provider/Makefile | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/provider-ci/internal/pkg/config.go b/provider-ci/internal/pkg/config.go index e8969b3d2..ad75c1955 100644 --- a/provider-ci/internal/pkg/config.go +++ b/provider-ci/internal/pkg/config.go @@ -289,6 +289,12 @@ type Config struct { // // 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 b4bd6b649..0e423249a 100644 --- a/provider-ci/internal/pkg/templates/bridged-provider/Makefile +++ b/provider-ci/internal/pkg/templates/bridged-provider/Makefile @@ -445,5 +445,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) From a11bf10cc2c4e1de53e2bde850727dd85e1a3983 Mon Sep 17 00:00:00 2001 From: Anton Tayanovskyy Date: Wed, 15 Jan 2025 11:13:37 -0500 Subject: [PATCH 06/10] Retain build_provider_cmd_default command so that a custom build_provider_cmd can wrap it --- .../internal/pkg/templates/bridged-provider/Makefile | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/provider-ci/internal/pkg/templates/bridged-provider/Makefile b/provider-ci/internal/pkg/templates/bridged-provider/Makefile index 0e423249a..80e81fca6 100644 --- a/provider-ci/internal/pkg/templates/bridged-provider/Makefile +++ b/provider-ci/internal/pkg/templates/bridged-provider/Makefile @@ -255,15 +255,18 @@ 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`. +build_provider_cmd_default = cd provider && GOOS=$(1) GOARCH=$(2) CGO_ENABLED=0 go build $(PULUMI_PROVIDER_BUILD_PARALLELISM) -o "$(3)" -ldflags "$(LDFLAGS)" $(PROJECT)/$(PROVIDER_PATH)/cmd/$(PROVIDER) #{{- if .Config.BuildProviderCmd }}# build_provider_cmd = #{{ .Config.BuildProviderCmd }}# #{{- else }}# -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) +build_provider_cmd = $(call build_provider_cmd_default,$(1),$(2),$(3)) #{{- 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,$(shell go env GOOS),$(shell go env GOARCH),$(WORKING_DIR)/bin/$(PROVIDER)) bin/$(PROVIDER): .make/schema From 8f115340e6212869c574e208dbbb2b27a27d99b4 Mon Sep 17 00:00:00 2001 From: Anton Tayanovskyy Date: Wed, 15 Jan 2025 11:14:50 -0500 Subject: [PATCH 07/10] make --- provider-ci/test-providers/acme/Makefile | 7 +++++-- provider-ci/test-providers/aws/Makefile | 7 +++++-- provider-ci/test-providers/cloudflare/Makefile | 7 +++++-- provider-ci/test-providers/docker/Makefile | 7 +++++-- provider-ci/test-providers/eks/Makefile | 7 +++++-- 5 files changed, 25 insertions(+), 10 deletions(-) diff --git a/provider-ci/test-providers/acme/Makefile b/provider-ci/test-providers/acme/Makefile index 01e8571ba..3573e4aad 100644 --- a/provider-ci/test-providers/acme/Makefile +++ b/provider-ci/test-providers/acme/Makefile @@ -215,11 +215,14 @@ lint_provider.fix: cd provider && golangci-lint run --path-prefix provider -c ../.golangci.yml --fix .PHONY: lint_provider lint_provider.fix +build_provider_cmd_default = cd provider && GOOS=$(1) GOARCH=$(2) CGO_ENABLED=0 go build $(PULUMI_PROVIDER_BUILD_PARALLELISM) -o "$(3)" -ldflags "$(LDFLAGS)" $(PROJECT)/$(PROVIDER_PATH)/cmd/$(PROVIDER) +build_provider_cmd = $(call build_provider_cmd_default,$(1),$(2),$(3)) + +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 && 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) provider_no_deps: $(call build_provider_cmd,$(shell go env GOOS),$(shell go env GOARCH),$(WORKING_DIR)/bin/$(PROVIDER)) bin/$(PROVIDER): .make/schema diff --git a/provider-ci/test-providers/aws/Makefile b/provider-ci/test-providers/aws/Makefile index f2b07d3bd..903124f97 100644 --- a/provider-ci/test-providers/aws/Makefile +++ b/provider-ci/test-providers/aws/Makefile @@ -225,11 +225,14 @@ lint_provider.fix: cd provider && golangci-lint run --path-prefix provider -c ../.golangci.yml --fix .PHONY: lint_provider lint_provider.fix +build_provider_cmd_default = cd provider && GOOS=$(1) GOARCH=$(2) CGO_ENABLED=0 go build $(PULUMI_PROVIDER_BUILD_PARALLELISM) -o "$(3)" -ldflags "$(LDFLAGS)" $(PROJECT)/$(PROVIDER_PATH)/cmd/$(PROVIDER) +build_provider_cmd = $(call build_provider_cmd_default,$(1),$(2),$(3)) + +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 && 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) provider_no_deps: $(call build_provider_cmd,$(shell go env GOOS),$(shell go env GOARCH),$(WORKING_DIR)/bin/$(PROVIDER)) bin/$(PROVIDER): .make/schema diff --git a/provider-ci/test-providers/cloudflare/Makefile b/provider-ci/test-providers/cloudflare/Makefile index 36e726693..aa4f92784 100644 --- a/provider-ci/test-providers/cloudflare/Makefile +++ b/provider-ci/test-providers/cloudflare/Makefile @@ -225,11 +225,14 @@ lint_provider.fix: cd provider && golangci-lint run --path-prefix provider -c ../.golangci.yml --fix .PHONY: lint_provider lint_provider.fix +build_provider_cmd_default = cd provider && GOOS=$(1) GOARCH=$(2) CGO_ENABLED=0 go build $(PULUMI_PROVIDER_BUILD_PARALLELISM) -o "$(3)" -ldflags "$(LDFLAGS)" $(PROJECT)/$(PROVIDER_PATH)/cmd/$(PROVIDER) +build_provider_cmd = $(call build_provider_cmd_default,$(1),$(2),$(3)) + +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 && 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) provider_no_deps: $(call build_provider_cmd,$(shell go env GOOS),$(shell go env GOARCH),$(WORKING_DIR)/bin/$(PROVIDER)) bin/$(PROVIDER): .make/schema diff --git a/provider-ci/test-providers/docker/Makefile b/provider-ci/test-providers/docker/Makefile index 05d04e49a..4c6a45ea7 100644 --- a/provider-ci/test-providers/docker/Makefile +++ b/provider-ci/test-providers/docker/Makefile @@ -228,11 +228,14 @@ lint_provider.fix: cd provider && golangci-lint run --path-prefix provider -c ../.golangci.yml --fix .PHONY: lint_provider lint_provider.fix +build_provider_cmd_default = cd provider && GOOS=$(1) GOARCH=$(2) CGO_ENABLED=0 go build $(PULUMI_PROVIDER_BUILD_PARALLELISM) -o "$(3)" -ldflags "$(LDFLAGS)" $(PROJECT)/$(PROVIDER_PATH)/cmd/$(PROVIDER) +build_provider_cmd = $(call build_provider_cmd_default,$(1),$(2),$(3)) + +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 && 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) provider_no_deps: $(call build_provider_cmd,$(shell go env GOOS),$(shell go env GOARCH),$(WORKING_DIR)/bin/$(PROVIDER)) bin/$(PROVIDER): .make/schema diff --git a/provider-ci/test-providers/eks/Makefile b/provider-ci/test-providers/eks/Makefile index 5d31830ef..be55bd9d8 100644 --- a/provider-ci/test-providers/eks/Makefile +++ b/provider-ci/test-providers/eks/Makefile @@ -215,11 +215,14 @@ lint_provider.fix: cd provider && golangci-lint run --path-prefix provider -c ../.golangci.yml --fix .PHONY: lint_provider lint_provider.fix +build_provider_cmd_default = cd provider && GOOS=$(1) GOARCH=$(2) CGO_ENABLED=0 go build $(PULUMI_PROVIDER_BUILD_PARALLELISM) -o "$(3)" -ldflags "$(LDFLAGS)" $(PROJECT)/$(PROVIDER_PATH)/cmd/$(PROVIDER) +build_provider_cmd = $(call build_provider_cmd_default,$(1),$(2),$(3)) + +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 && 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) provider_no_deps: $(call build_provider_cmd,$(shell go env GOOS),$(shell go env GOARCH),$(WORKING_DIR)/bin/$(PROVIDER)) bin/$(PROVIDER): .make/schema From 278df6f970970ecf7837c3085456cb3b8d3db7fd Mon Sep 17 00:00:00 2001 From: Anton Tayanovskyy Date: Thu, 16 Jan 2025 11:23:50 -0500 Subject: [PATCH 08/10] Remove build_provider_cmd_default --- provider-ci/internal/pkg/templates/bridged-provider/Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/provider-ci/internal/pkg/templates/bridged-provider/Makefile b/provider-ci/internal/pkg/templates/bridged-provider/Makefile index 80e81fca6..fb6de95f8 100644 --- a/provider-ci/internal/pkg/templates/bridged-provider/Makefile +++ b/provider-ci/internal/pkg/templates/bridged-provider/Makefile @@ -255,11 +255,10 @@ lint_provider.fix: cd provider && golangci-lint run --path-prefix provider -c ../.golangci.yml --fix .PHONY: lint_provider lint_provider.fix -build_provider_cmd_default = cd provider && GOOS=$(1) GOARCH=$(2) CGO_ENABLED=0 go build $(PULUMI_PROVIDER_BUILD_PARALLELISM) -o "$(3)" -ldflags "$(LDFLAGS)" $(PROJECT)/$(PROVIDER_PATH)/cmd/$(PROVIDER) #{{- if .Config.BuildProviderCmd }}# build_provider_cmd = #{{ .Config.BuildProviderCmd }}# #{{- else }}# -build_provider_cmd = $(call build_provider_cmd_default,$(1),$(2),$(3)) +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) #{{- end }}# provider: bin/$(PROVIDER) From 3b4cfa39d118192346c257de99cbf8d64a177c29 Mon Sep 17 00:00:00 2001 From: Anton Tayanovskyy Date: Thu, 16 Jan 2025 11:24:15 -0500 Subject: [PATCH 09/10] make --- provider-ci/test-providers/acme/Makefile | 4 +--- provider-ci/test-providers/aws/Makefile | 6 ++---- provider-ci/test-providers/cloudflare/Makefile | 4 +--- provider-ci/test-providers/docker/Makefile | 4 +--- provider-ci/test-providers/eks/Makefile | 4 +--- 5 files changed, 6 insertions(+), 16 deletions(-) diff --git a/provider-ci/test-providers/acme/Makefile b/provider-ci/test-providers/acme/Makefile index 3573e4aad..1948bbf18 100644 --- a/provider-ci/test-providers/acme/Makefile +++ b/provider-ci/test-providers/acme/Makefile @@ -214,9 +214,7 @@ 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_default = cd provider && GOOS=$(1) GOARCH=$(2) CGO_ENABLED=0 go build $(PULUMI_PROVIDER_BUILD_PARALLELISM) -o "$(3)" -ldflags "$(LDFLAGS)" $(PROJECT)/$(PROVIDER_PATH)/cmd/$(PROVIDER) -build_provider_cmd = $(call build_provider_cmd_default,$(1),$(2),$(3)) +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) diff --git a/provider-ci/test-providers/aws/Makefile b/provider-ci/test-providers/aws/Makefile index 903124f97..b8c248d2b 100644 --- a/provider-ci/test-providers/aws/Makefile +++ b/provider-ci/test-providers/aws/Makefile @@ -224,9 +224,7 @@ 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_default = cd provider && GOOS=$(1) GOARCH=$(2) CGO_ENABLED=0 go build $(PULUMI_PROVIDER_BUILD_PARALLELISM) -o "$(3)" -ldflags "$(LDFLAGS)" $(PROJECT)/$(PROVIDER_PATH)/cmd/$(PROVIDER) -build_provider_cmd = $(call build_provider_cmd_default,$(1),$(2),$(3)) +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) @@ -253,7 +251,7 @@ test_provider: .PHONY: test_provider tfgen: schema -schema: .make/schema +schema: .make/schema # This does actually have dependencies, but we're keeping it around for backwards compatibility for now tfgen_no_deps: .make/schema .make/schema: export PULUMI_HOME := $(WORKING_DIR)/.pulumi diff --git a/provider-ci/test-providers/cloudflare/Makefile b/provider-ci/test-providers/cloudflare/Makefile index aa4f92784..951966048 100644 --- a/provider-ci/test-providers/cloudflare/Makefile +++ b/provider-ci/test-providers/cloudflare/Makefile @@ -224,9 +224,7 @@ 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_default = cd provider && GOOS=$(1) GOARCH=$(2) CGO_ENABLED=0 go build $(PULUMI_PROVIDER_BUILD_PARALLELISM) -o "$(3)" -ldflags "$(LDFLAGS)" $(PROJECT)/$(PROVIDER_PATH)/cmd/$(PROVIDER) -build_provider_cmd = $(call build_provider_cmd_default,$(1),$(2),$(3)) +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) diff --git a/provider-ci/test-providers/docker/Makefile b/provider-ci/test-providers/docker/Makefile index 4c6a45ea7..89004926e 100644 --- a/provider-ci/test-providers/docker/Makefile +++ b/provider-ci/test-providers/docker/Makefile @@ -227,9 +227,7 @@ 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_default = cd provider && GOOS=$(1) GOARCH=$(2) CGO_ENABLED=0 go build $(PULUMI_PROVIDER_BUILD_PARALLELISM) -o "$(3)" -ldflags "$(LDFLAGS)" $(PROJECT)/$(PROVIDER_PATH)/cmd/$(PROVIDER) -build_provider_cmd = $(call build_provider_cmd_default,$(1),$(2),$(3)) +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) diff --git a/provider-ci/test-providers/eks/Makefile b/provider-ci/test-providers/eks/Makefile index be55bd9d8..36086cf9c 100644 --- a/provider-ci/test-providers/eks/Makefile +++ b/provider-ci/test-providers/eks/Makefile @@ -214,9 +214,7 @@ 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_default = cd provider && GOOS=$(1) GOARCH=$(2) CGO_ENABLED=0 go build $(PULUMI_PROVIDER_BUILD_PARALLELISM) -o "$(3)" -ldflags "$(LDFLAGS)" $(PROJECT)/$(PROVIDER_PATH)/cmd/$(PROVIDER) -build_provider_cmd = $(call build_provider_cmd_default,$(1),$(2),$(3)) +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) From 07fac7ab3f1c27b925129d5d01500e15545d04bd Mon Sep 17 00:00:00 2001 From: Anton Tayanovskyy Date: Thu, 16 Jan 2025 11:38:54 -0500 Subject: [PATCH 10/10] BuildProviderPre hook --- provider-ci/internal/pkg/config.go | 3 +++ .../internal/pkg/templates/bridged-provider/Makefile | 10 ++++++++-- provider-ci/test-providers/aws/Makefile | 2 +- provider-ci/test-providers/eks/.ci-mgmt.yaml | 1 + provider-ci/test-providers/eks/Makefile | 2 +- 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/provider-ci/internal/pkg/config.go b/provider-ci/internal/pkg/config.go index ad75c1955..ca65cd822 100644 --- a/provider-ci/internal/pkg/config.go +++ b/provider-ci/internal/pkg/config.go @@ -285,6 +285,9 @@ type Config struct { // 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. diff --git a/provider-ci/internal/pkg/templates/bridged-provider/Makefile b/provider-ci/internal/pkg/templates/bridged-provider/Makefile index fb6de95f8..9c92d82f9 100644 --- a/provider-ci/internal/pkg/templates/bridged-provider/Makefile +++ b/provider-ci/internal/pkg/templates/bridged-provider/Makefile @@ -256,9 +256,15 @@ lint_provider.fix: .PHONY: lint_provider lint_provider.fix #{{- 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 && GOOS=$(1) GOARCH=$(2) CGO_ENABLED=0 go build $(PULUMI_PROVIDER_BUILD_PARALLELISM) -o "$(3)" -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) diff --git a/provider-ci/test-providers/aws/Makefile b/provider-ci/test-providers/aws/Makefile index b8c248d2b..dfb89c174 100644 --- a/provider-ci/test-providers/aws/Makefile +++ b/provider-ci/test-providers/aws/Makefile @@ -251,7 +251,7 @@ test_provider: .PHONY: test_provider tfgen: schema -schema: .make/schema +schema: .make/schema # This does actually have dependencies, but we're keeping it around for backwards compatibility for now tfgen_no_deps: .make/schema .make/schema: export PULUMI_HOME := $(WORKING_DIR)/.pulumi 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 36086cf9c..6f2db5017 100644 --- a/provider-ci/test-providers/eks/Makefile +++ b/provider-ci/test-providers/eks/Makefile @@ -214,7 +214,7 @@ 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) +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)