Skip to content

Commit

Permalink
Automatically install pulumictl (#1284)
Browse files Browse the repository at this point in the history
Bridged provider Makefile used to assume that `pulumictl` is available
in PATH. With this change it will now automatically install it if this
is not the case. This is easier to use and also will help `make
renovate` targets succeed without having `pulumictl` installed.

The version of the tool is controlled so that it is in sync across the
Makefile and CI.
  • Loading branch information
t0yv0 authored Jan 13, 2025
1 parent dfd7de2 commit f54bddb
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 13 deletions.
2 changes: 2 additions & 0 deletions provider-ci/internal/pkg/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,8 @@ type toolVersions struct {
Nodejs string `yaml:"nodejs"`
Pulumi string `yaml:"pulumi"`
Python string `yaml:"python"`

PulumiCTL string `yaml:"pulumictl"`
}

type releaseVerification struct {
Expand Down
5 changes: 5 additions & 0 deletions provider-ci/internal/pkg/defaults.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package pkg

const (
defaultPulumiCTLVersion = "v0.0.46"
)
4 changes: 4 additions & 0 deletions provider-ci/internal/pkg/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ func GeneratePackage(opts GenerateOpts) error {
opts.Config.CheckUpstreamUpgrade = false
}

if opts.Config.ToolVersions.PulumiCTL == "" {
opts.Config.ToolVersions.PulumiCTL = defaultPulumiCTLVersion
}

// Clean up old workflows if requested
if opts.Config.CleanGithubWorkflows {
workflows, err := os.ReadDir(filepath.Join(opts.OutDir, ".github", "workflows"))
Expand Down
10 changes: 8 additions & 2 deletions provider-ci/internal/pkg/templates/bridged-provider/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,17 @@ PULUMI_CONVERT := 0
#{{- end }}#
PULUMI_MISSING_DOCS_ERROR := true

PULUMICTL_VERSION := #{{ .Config.ToolVersions.PulumiCTL }}#
PULUMICTL := $(shell which pulumictl || \
(test ! -e $(WORKING_DIR)/bin/pulumictl && \
GOPATH="$(WORKING_DIR)" go install "github.com/pulumi/pulumictl/cmd/pulumictl@$(PULUMICTL_VERSION)"; \
echo "$(WORKING_DIR)/bin/puluimctl"))

# Override during CI using `make [TARGET] PROVIDER_VERSION=""` or by setting a PROVIDER_VERSION environment variable
# Local & branch builds will just used this fixed default version unless specified
PROVIDER_VERSION ?= #{{ .Config.MajorVersion }}#.0.0-alpha.0+dev
# Use this normalised version everywhere rather than the raw input to ensure consistency.
VERSION_GENERIC = $(shell pulumictl convert-version --language generic --version "$(PROVIDER_VERSION)")
VERSION_GENERIC = $(shell $(PULUMICTL) convert-version --language generic --version "$(PROVIDER_VERSION)")

# Strips debug information from the provider binary to reduce its size and speed up builds
LDFLAGS_STRIP_SYMBOLS=-s -w
Expand Down Expand Up @@ -318,7 +324,7 @@ endif
.PHONY: upstream

bin/pulumi-java-gen: .pulumi-java-gen.version
pulumictl download-binary -n pulumi-language-java -v v$(shell cat .pulumi-java-gen.version) -r pulumi/pulumi-java
$(PULUMICTL) download-binary -n pulumi-language-java -v v$(shell cat .pulumi-java-gen.version) -r pulumi/pulumi-java

# To make an immediately observable change to .ci-mgmt.yaml:
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ runs:
if: inputs.tools == 'all' || contains(inputs.tools, 'pulumictl')
uses: jaxxstorm/action-install-gh-release@cd6b2b78ad38bdd294341cda064ec0692b06215b # v1.14.0
with:
tag: v0.0.46
tag: #{{ .Config.ToolVersions.PulumiCTL }}#
repo: pulumi/pulumictl

- name: Install Pulumi CLI
Expand Down
10 changes: 8 additions & 2 deletions provider-ci/test-providers/acme/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,17 @@ PULUMI_PROVIDER_BUILD_PARALLELISM ?=
PULUMI_CONVERT := 0
PULUMI_MISSING_DOCS_ERROR := true

PULUMICTL_VERSION := v0.0.46
PULUMICTL := $(shell which pulumictl || \
(test ! -e $(WORKING_DIR)/bin/pulumictl && \
GOPATH="$(WORKING_DIR)" go install "github.com/pulumi/pulumictl/cmd/pulumictl@$(PULUMICTL_VERSION)"; \
echo "$(WORKING_DIR)/bin/puluimctl"))

# Override during CI using `make [TARGET] PROVIDER_VERSION=""` or by setting a PROVIDER_VERSION environment variable
# Local & branch builds will just used this fixed default version unless specified
PROVIDER_VERSION ?= 0.0.0-alpha.0+dev
# Use this normalised version everywhere rather than the raw input to ensure consistency.
VERSION_GENERIC = $(shell pulumictl convert-version --language generic --version "$(PROVIDER_VERSION)")
VERSION_GENERIC = $(shell $(PULUMICTL) convert-version --language generic --version "$(PROVIDER_VERSION)")

# Strips debug information from the provider binary to reduce its size and speed up builds
LDFLAGS_STRIP_SYMBOLS=-s -w
Expand Down Expand Up @@ -263,7 +269,7 @@ endif
.PHONY: upstream

bin/pulumi-java-gen: .pulumi-java-gen.version
pulumictl download-binary -n pulumi-language-java -v v$(shell cat .pulumi-java-gen.version) -r pulumi/pulumi-java
$(PULUMICTL) download-binary -n pulumi-language-java -v v$(shell cat .pulumi-java-gen.version) -r pulumi/pulumi-java

# To make an immediately observable change to .ci-mgmt.yaml:
#
Expand Down
10 changes: 8 additions & 2 deletions provider-ci/test-providers/aws/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,17 @@ PULUMI_PROVIDER_BUILD_PARALLELISM ?= -p 2
PULUMI_CONVERT := 1
PULUMI_MISSING_DOCS_ERROR := true

PULUMICTL_VERSION := v0.0.46
PULUMICTL := $(shell which pulumictl || \
(test ! -e $(WORKING_DIR)/bin/pulumictl && \
GOPATH="$(WORKING_DIR)" go install "github.com/pulumi/pulumictl/cmd/pulumictl@$(PULUMICTL_VERSION)"; \
echo "$(WORKING_DIR)/bin/puluimctl"))

# Override during CI using `make [TARGET] PROVIDER_VERSION=""` or by setting a PROVIDER_VERSION environment variable
# Local & branch builds will just used this fixed default version unless specified
PROVIDER_VERSION ?= 6.0.0-alpha.0+dev
# Use this normalised version everywhere rather than the raw input to ensure consistency.
VERSION_GENERIC = $(shell pulumictl convert-version --language generic --version "$(PROVIDER_VERSION)")
VERSION_GENERIC = $(shell $(PULUMICTL) convert-version --language generic --version "$(PROVIDER_VERSION)")

# Strips debug information from the provider binary to reduce its size and speed up builds
LDFLAGS_STRIP_SYMBOLS=-s -w
Expand Down Expand Up @@ -277,7 +283,7 @@ endif
.PHONY: upstream

bin/pulumi-java-gen: .pulumi-java-gen.version
pulumictl download-binary -n pulumi-language-java -v v$(shell cat .pulumi-java-gen.version) -r pulumi/pulumi-java
$(PULUMICTL) download-binary -n pulumi-language-java -v v$(shell cat .pulumi-java-gen.version) -r pulumi/pulumi-java

# To make an immediately observable change to .ci-mgmt.yaml:
#
Expand Down
10 changes: 8 additions & 2 deletions provider-ci/test-providers/cloudflare/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,17 @@ PULUMI_PROVIDER_BUILD_PARALLELISM ?=
PULUMI_CONVERT := 1
PULUMI_MISSING_DOCS_ERROR := true

PULUMICTL_VERSION := v0.0.46
PULUMICTL := $(shell which pulumictl || \
(test ! -e $(WORKING_DIR)/bin/pulumictl && \
GOPATH="$(WORKING_DIR)" go install "github.com/pulumi/pulumictl/cmd/pulumictl@$(PULUMICTL_VERSION)"; \
echo "$(WORKING_DIR)/bin/puluimctl"))

# Override during CI using `make [TARGET] PROVIDER_VERSION=""` or by setting a PROVIDER_VERSION environment variable
# Local & branch builds will just used this fixed default version unless specified
PROVIDER_VERSION ?= 5.0.0-alpha.0+dev
# Use this normalised version everywhere rather than the raw input to ensure consistency.
VERSION_GENERIC = $(shell pulumictl convert-version --language generic --version "$(PROVIDER_VERSION)")
VERSION_GENERIC = $(shell $(PULUMICTL) convert-version --language generic --version "$(PROVIDER_VERSION)")

# Strips debug information from the provider binary to reduce its size and speed up builds
LDFLAGS_STRIP_SYMBOLS=-s -w
Expand Down Expand Up @@ -273,7 +279,7 @@ endif
.PHONY: upstream

bin/pulumi-java-gen: .pulumi-java-gen.version
pulumictl download-binary -n pulumi-language-java -v v$(shell cat .pulumi-java-gen.version) -r pulumi/pulumi-java
$(PULUMICTL) download-binary -n pulumi-language-java -v v$(shell cat .pulumi-java-gen.version) -r pulumi/pulumi-java

# To make an immediately observable change to .ci-mgmt.yaml:
#
Expand Down
10 changes: 8 additions & 2 deletions provider-ci/test-providers/docker/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,17 @@ PULUMI_PROVIDER_BUILD_PARALLELISM ?=
PULUMI_CONVERT := 1
PULUMI_MISSING_DOCS_ERROR := true

PULUMICTL_VERSION := v0.0.46
PULUMICTL := $(shell which pulumictl || \
(test ! -e $(WORKING_DIR)/bin/pulumictl && \
GOPATH="$(WORKING_DIR)" go install "github.com/pulumi/pulumictl/cmd/pulumictl@$(PULUMICTL_VERSION)"; \
echo "$(WORKING_DIR)/bin/puluimctl"))

# Override during CI using `make [TARGET] PROVIDER_VERSION=""` or by setting a PROVIDER_VERSION environment variable
# Local & branch builds will just used this fixed default version unless specified
PROVIDER_VERSION ?= 4.0.0-alpha.0+dev
# Use this normalised version everywhere rather than the raw input to ensure consistency.
VERSION_GENERIC = $(shell pulumictl convert-version --language generic --version "$(PROVIDER_VERSION)")
VERSION_GENERIC = $(shell $(PULUMICTL) convert-version --language generic --version "$(PROVIDER_VERSION)")

# Strips debug information from the provider binary to reduce its size and speed up builds
LDFLAGS_STRIP_SYMBOLS=-s -w
Expand Down Expand Up @@ -276,7 +282,7 @@ endif
.PHONY: upstream

bin/pulumi-java-gen: .pulumi-java-gen.version
pulumictl download-binary -n pulumi-language-java -v v$(shell cat .pulumi-java-gen.version) -r pulumi/pulumi-java
$(PULUMICTL) download-binary -n pulumi-language-java -v v$(shell cat .pulumi-java-gen.version) -r pulumi/pulumi-java

# To make an immediately observable change to .ci-mgmt.yaml:
#
Expand Down
10 changes: 8 additions & 2 deletions provider-ci/test-providers/eks/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,17 @@ PULUMI_PROVIDER_BUILD_PARALLELISM ?=
PULUMI_CONVERT := 0
PULUMI_MISSING_DOCS_ERROR := true

PULUMICTL_VERSION := v0.0.46
PULUMICTL := $(shell which pulumictl || \
(test ! -e $(WORKING_DIR)/bin/pulumictl && \
GOPATH="$(WORKING_DIR)" go install "github.com/pulumi/pulumictl/cmd/pulumictl@$(PULUMICTL_VERSION)"; \
echo "$(WORKING_DIR)/bin/puluimctl"))

# Override during CI using `make [TARGET] PROVIDER_VERSION=""` or by setting a PROVIDER_VERSION environment variable
# Local & branch builds will just used this fixed default version unless specified
PROVIDER_VERSION ?= 3.0.0-alpha.0+dev
# Use this normalised version everywhere rather than the raw input to ensure consistency.
VERSION_GENERIC = $(shell pulumictl convert-version --language generic --version "$(PROVIDER_VERSION)")
VERSION_GENERIC = $(shell $(PULUMICTL) convert-version --language generic --version "$(PROVIDER_VERSION)")

# Strips debug information from the provider binary to reduce its size and speed up builds
LDFLAGS_STRIP_SYMBOLS=-s -w
Expand Down Expand Up @@ -258,7 +264,7 @@ upstream: .make/upstream
.PHONY: upstream

bin/pulumi-java-gen: .pulumi-java-gen.version
pulumictl download-binary -n pulumi-language-java -v v$(shell cat .pulumi-java-gen.version) -r pulumi/pulumi-java
$(PULUMICTL) download-binary -n pulumi-language-java -v v$(shell cat .pulumi-java-gen.version) -r pulumi/pulumi-java

# To make an immediately observable change to .ci-mgmt.yaml:
#
Expand Down

0 comments on commit f54bddb

Please sign in to comment.