diff --git a/.github/workflows/build_provider.yml b/.github/workflows/build_provider.yml index 6f0d430..89daaa6 100644 --- a/.github/workflows/build_provider.yml +++ b/.github/workflows/build_provider.yml @@ -37,8 +37,6 @@ jobs: uses: ./.github/actions/setup-tools with: tools: pulumictl, go - - name: Prepare local workspace before restoring previously built - run: make prepare_local_workspace - name: Download schema-embed.json uses: actions/download-artifact@v4 with: @@ -47,11 +45,9 @@ jobs: # Avoid creating directories for each artifact merge-multiple: true path: provider/cmd/pulumi-resource-xyz/schema-embed.json - - name: Restore makefile progress - uses: actions/download-artifact@v4 - with: - name: prerequisites.make - path: .make + - name: Prepare for build + # This installs plugins and prepares upstream + run: make upstream - name: Build & package provider run: make provider_dist-${{ matrix.platform.os }}-${{ matrix.platform.arch }} - name: Upload artifacts diff --git a/.github/workflows/build_sdk.yml b/.github/workflows/build_sdk.yml index 3c38ebe..ae54177 100644 --- a/.github/workflows/build_sdk.yml +++ b/.github/workflows/build_sdk.yml @@ -53,17 +53,12 @@ jobs: uses: ./.github/actions/setup-tools with: tools: pulumictl, pulumicli, ${{ matrix.language }} - - name: Prepare local workspace - run: make prepare_local_workspace - name: Download bin uses: ./.github/actions/download-bin + - name: Install plugins + run: make install_plugins - name: Update path run: echo "${{ github.workspace }}/bin" >> "$GITHUB_PATH" - - name: Restore makefile progress - uses: actions/download-artifact@v4 - with: - name: prerequisites.make - path: .make - name: Build SDK run: make build_${{ matrix.language }} - name: Check worktree clean @@ -79,9 +74,3 @@ jobs: uses: ./.github/actions/upload-sdk with: language: ${{ matrix.language }} - - name: Save makefile progress - uses: actions/upload-artifact@v4 - with: - name: build_${{ matrix.language }}.make - path: .make - include-hidden-files: true diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7b783c8..e51fb11 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -144,19 +144,15 @@ jobs: uses: ./.github/actions/setup-tools with: tools: pulumictl, pulumicli, ${{ matrix.language }} - - name: Prepare local workspace - run: make prepare_local_workspace - name: Download bin uses: ./.github/actions/download-bin + - name: Add NuGet source + if: matrix.language == 'dotnet' + run: dotnet nuget add source ${{ github.workspace }}/nuget - name: Download SDK uses: ./.github/actions/download-sdk with: language: ${{ matrix.language }} - - name: Restore makefile progress - uses: actions/download-artifact@v4 - with: - name: build_${{ matrix.language }}.make - path: .make - name: Update path run: echo "${{ github.workspace }}/bin" >> "$GITHUB_PATH" - name: Install Python deps diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml index ee4e388..07a7a7c 100644 --- a/.github/workflows/prerelease.yml +++ b/.github/workflows/prerelease.yml @@ -86,19 +86,15 @@ jobs: uses: ./.github/actions/setup-tools with: tools: pulumictl, pulumicli, dotnet, go, nodejs, python - - name: Prepare local workspace - run: make prepare_local_workspace - name: Download bin uses: ./.github/actions/download-bin + - name: Add NuGet source + if: matrix.language == 'dotnet' + run: dotnet nuget add source ${{ github.workspace }}/nuget - name: Download SDK uses: ./.github/actions/download-sdk with: language: ${{ matrix.language }} - - name: Restore makefile progress - uses: actions/download-artifact@v4 - with: - name: build_${{ matrix.language }}.make - path: .make - name: Update path run: echo "${{ github.workspace }}/bin" >> "$GITHUB_PATH" - name: Install Python deps diff --git a/.github/workflows/prerequisites.yml b/.github/workflows/prerequisites.yml index c2c904c..0932417 100644 --- a/.github/workflows/prerequisites.yml +++ b/.github/workflows/prerequisites.yml @@ -56,16 +56,20 @@ jobs: path: | .pulumi/examples-cache key: ${{ runner.os }}-${{ hashFiles('provider/go.sum') }} + - name: Prepare upstream code + run: make upstream - name: Setup tools uses: ./.github/actions/setup-tools with: tools: go, pulumictl, pulumicli, schema-tools - - name: Prepare local workspace before restoring previously built files - run: make prepare_local_workspace + - name: Build schema generator binary + run: make tfgen_build_only + - name: Install plugins + run: make install_plugins - name: Generate schema - run: make schema + run: make tfgen_no_deps - name: Build provider binary - run: make provider + run: make provider_no_deps - name: Unit-test provider code run: make test_provider - if: inputs.is_pr @@ -77,12 +81,6 @@ jobs: schema-tools compare -r github://api.github.com/pulumi -p xyz -o "${{ inputs.default_branch }}" -n --local-path=provider/cmd/pulumi-resource-xyz/schema.json; echo "$EOF"; } >> "$GITHUB_ENV" - - name: Save makefile progress - uses: actions/upload-artifact@v4 - with: - name: prerequisites.make - path: .make - include-hidden-files: true - if: inputs.is_pr && inputs.is_automated == false name: Comment on PR with Details of Schema Check uses: thollander/actions-comment-pull-request@v2 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a0a0944..173db15 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -92,19 +92,15 @@ jobs: uses: ./.github/actions/setup-tools with: tools: pulumictl, pulumicli, ${{ matrix.language }} - - name: Prepare local workspace - run: make prepare_local_workspace - name: Download bin uses: ./.github/actions/download-bin + - name: Add NuGet source + if: matrix.language == 'dotnet' + run: dotnet nuget add source ${{ github.workspace }}/nuget - name: Download SDK uses: ./.github/actions/download-sdk with: language: ${{ matrix.language }} - - name: Restore makefile progress - uses: actions/download-artifact@v4 - with: - name: build_${{ matrix.language }}.make - path: .make - name: Update path run: echo "${{ github.workspace }}/bin" >> "$GITHUB_PATH" - name: Install Python deps diff --git a/.github/workflows/run-acceptance-tests.yml b/.github/workflows/run-acceptance-tests.yml index 294ff81..8a5f45d 100644 --- a/.github/workflows/run-acceptance-tests.yml +++ b/.github/workflows/run-acceptance-tests.yml @@ -141,19 +141,15 @@ jobs: uses: ./.github/actions/setup-tools with: tools: pulumictl, pulumicli, ${{ matrix.language }} - - name: Prepare local workspace - run: make prepare_local_workspace - name: Download bin uses: ./.github/actions/download-bin + - name: Add NuGet source + if: matrix.language == 'dotnet' + run: dotnet nuget add source ${{ github.workspace }}/nuget - name: Download SDK uses: ./.github/actions/download-sdk with: language: ${{ matrix.language }} - - name: Restore makefile progress - uses: actions/download-artifact@v4 - with: - name: build_${{ matrix.language }}.make - path: .make - name: Update path run: echo "${{ github.workspace }}/bin" >> "$GITHUB_PATH" - name: Install Python deps diff --git a/.github/workflows/upgrade-bridge.yml b/.github/workflows/upgrade-bridge.yml index 51174f5..165ed0b 100644 --- a/.github/workflows/upgrade-bridge.yml +++ b/.github/workflows/upgrade-bridge.yml @@ -49,9 +49,16 @@ on: required: false type: boolean default: false + +permissions: + contents: write + issues: write + pull-requests: write + env: - GH_TOKEN: ${{ secrets.PULUMI_BOT_TOKEN }} + GH_TOKEN: ${{ secrets.PULUMI_PROVIDER_AUTOMATION_TOKEN || secrets.PULUMI_BOT_TOKEN || secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + jobs: upgrade_provider: name: upgrade-provider diff --git a/.github/workflows/upgrade-provider.yml b/.github/workflows/upgrade-provider.yml index be11369..2ad5981 100644 --- a/.github/workflows/upgrade-provider.yml +++ b/.github/workflows/upgrade-provider.yml @@ -22,9 +22,15 @@ on: # 3 AM UTC ~ 8 PM PDT / 7 PM PST daily. Time chosen to run during off hours. - cron: 0 3 * * * +permissions: + contents: write + issues: write + pull-requests: write + env: - GH_TOKEN: ${{ secrets.PULUMI_BOT_TOKEN }} + GH_TOKEN: ${{ secrets.PULUMI_PROVIDER_AUTOMATION_TOKEN || secrets.PULUMI_BOT_TOKEN || secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + jobs: upgrade_provider: name: upgrade-provider diff --git a/Makefile b/Makefile index 8cd16c9..6f29b69 100644 --- a/Makefile +++ b/Makefile @@ -27,237 +27,146 @@ LDFLAGS_UPSTREAM_VERSION= LDFLAGS_EXTRAS= LDFLAGS=$(LDFLAGS_PROJ_VERSION) $(LDFLAGS_UPSTREAM_VERSION) $(LDFLAGS_EXTRAS) $(LDFLAGS_STRIP_SYMBOLS) -# Create a `.make` directory for tracking targets which don't generate a single file output. This should be ignored by git. -# For targets which either don't generate a single file output, or the output file is committed, we use a "sentinel" -# file within `.make/` to track the staleness of the target and only rebuild when needed. -# For each phony target, we create an internal target with the same name, but prefixed with `.make/` where the work is performed. -# At the end of each internal target we run `@touch $@` to update the file which is the name of the target. +development: install_plugins provider build_sdks install_sdks -# Ensure all directories exist before evaluating targets to avoid issues with `touch` creating directories. -_ := $(shell mkdir -p .make bin .pulumi/bin) - -# Build the provider and all SDKs and install ready for testing build: install_plugins provider build_sdks install_sdks -# Keep aliases for old targets to ensure backwards compatibility -development: build -only_build: build -# Prepare the workspace for building the provider and SDKs -# Importantly this is run by CI ahead of restoring the bin directory and resuming SDK builds -prepare_local_workspace: install_plugins upstream -# Creates all generated files which need to be committed -generate: generate_sdks schema -generate_sdks: generate_dotnet generate_go generate_nodejs generate_python -build_sdks: build_dotnet build_go build_nodejs build_python -install_sdks: install_dotnet_sdk install_go_sdk install_nodejs_sdk install_python_sdk -.PHONY: development only_build build generate generate_sdks build_sdks install_sdks -help: - @echo "Usage: make [target]" - @echo "" - @echo "Main Targets" - @echo " build (default) Build the provider and all SDKs and install for testing" - @echo " generate Generate all SDKs, documentation and schema" - @echo " provider Build the local provider binary" - @echo " lint_provider<.fix> Run the linter on the provider (& optionally fix)" - @echo " test_provider Run the provider tests" - @echo " test Run the example tests (must run 'build' first)" - @echo " clean Clean up generated files" - @echo "" - @echo "More Precise Targets" - @echo " schema Generate the schema" - @echo " generate_sdks Generate all SDKs" - @echo " build_sdks Build all SDKs" - @echo " install_sdks Install all SDKs" - @echo " provider_dist Build and package the provider for all platforms" - @echo "" - @echo "Tool Targets" - @echo " ci-mgmt Re-generate CI configuration from .ci-mgmt.yaml" - @echo " debug_tfgen Start a debug server for tfgen" - @echo "" - @echo "Internal Targets (automatically run as dependencies of other targets)" - @echo " prepare_local_workspace Prepare for building" - @echo " install_plugins Install plugin dependencies" - @echo " upstream Initialize the upstream submodule, if present" - @echo "" - @echo "Language-Specific Targets" - @echo " generate_[language] Generate the SDK files ready for committing" - @echo " build_[language] Build the SDK to check correctness" - @echo " install_[language]_sdk Install the SDK ready for testing" - @echo "" - @echo " [language] = dotnet go nodejs python" - @echo "" -.PHONY: help +build_sdks: build_dotnet build_go build_nodejs build_python -GEN_PULUMI_HOME := $(WORKING_DIR)/.pulumi -GEN_PULUMI_CONVERT_EXAMPLES_CACHE_DIR := $(GEN_PULUMI_HOME)/examples-cache -GEN_ENVS := PULUMI_HOME=$(GEN_PULUMI_HOME) PULUMI_CONVERT_EXAMPLES_CACHE_DIR=$(GEN_PULUMI_CONVERT_EXAMPLES_CACHE_DIR) PULUMI_CONVERT=$(PULUMI_CONVERT) PULUMI_DISABLE_AUTOMATIC_PLUGIN_ACQUISITION=$(PULUMI_CONVERT) +install_go_sdk: + +install_java_sdk: + +install_python_sdk: -generate_dotnet: .make/generate_dotnet -build_dotnet: .make/build_dotnet -.make/generate_dotnet: export PATH := $(WORKING_DIR)/.pulumi/bin:$(PATH) -.make/generate_dotnet: bin/$(TFGEN) - $(GEN_ENVS) $(WORKING_DIR)/bin/$(TFGEN) dotnet --out sdk/dotnet/ +install_sdks: install_dotnet_sdk install_python_sdk install_nodejs_sdk install_java_sdk + +only_build: build + +build_dotnet: export PULUMI_HOME := $(WORKING_DIR)/.pulumi +build_dotnet: export PATH := $(WORKING_DIR)/.pulumi/bin:$(PATH) +build_dotnet: export PULUMI_CONVERT_EXAMPLES_CACHE_DIR := $(WORKING_DIR)/.pulumi/examples-cache +build_dotnet: upstream + PULUMI_CONVERT=$(PULUMI_CONVERT) PULUMI_DISABLE_AUTOMATIC_PLUGIN_ACQUISITION=$(PULUMI_CONVERT) $(WORKING_DIR)/bin/$(TFGEN) dotnet --out sdk/dotnet/ cd sdk/dotnet/ && \ printf "module fake_dotnet_module // Exclude this directory from Go tools\n\ngo 1.17\n" > go.mod && \ - echo "$(VERSION_GENERIC)" >version.txt - @touch $@ -.make/build_dotnet: .make/generate_dotnet - cd sdk/dotnet/ && dotnet build - @touch $@ -.PHONY: generate_dotnet build_dotnet - -generate_go: .make/generate_go -build_go: .make/build_go -.make/generate_go: export PATH := $(WORKING_DIR)/.pulumi/bin:$(PATH) -.make/generate_go: bin/$(TFGEN) - $(GEN_ENVS) $(WORKING_DIR)/bin/$(TFGEN) go --out sdk/go/ - @touch $@ -.make/build_go: .make/generate_go + echo "$(VERSION_GENERIC)" >version.txt && \ + dotnet build + +build_go: export PULUMI_HOME := $(WORKING_DIR)/.pulumi +build_go: export PATH := $(WORKING_DIR)/.pulumi/bin:$(PATH) +build_go: export PULUMI_CONVERT_EXAMPLES_CACHE_DIR := $(WORKING_DIR)/.pulumi/examples-cache +build_go: upstream + PULUMI_CONVERT=$(PULUMI_CONVERT) PULUMI_DISABLE_AUTOMATIC_PLUGIN_ACQUISITION=$(PULUMI_CONVERT) $(WORKING_DIR)/bin/$(TFGEN) go --out sdk/go/ cd sdk && go list "$$(grep -e "^module" go.mod | cut -d ' ' -f 2)/go/..." | xargs -I {} bash -c 'go build {} && go clean -i {}' - @touch $@ -.PHONY: generate_go build_go - -generate_java: .make/generate_java -build_java: .make/build_java -.make/generate_java: export PATH := $(WORKING_DIR)/.pulumi/bin:$(PATH) -.make/generate_java: PACKAGE_VERSION := $(VERSION_GENERIC) -.make/generate_java: bin/pulumi-java-gen .make/schema - PULUMI_HOME=$(GEN_PULUMI_HOME) PULUMI_CONVERT_EXAMPLES_CACHE_DIR=$(GEN_PULUMI_CONVERT_EXAMPLES_CACHE_DIR) bin/$(JAVA_GEN) generate --schema provider/cmd/$(PROVIDER)/schema.json --out sdk/java --build gradle-nexus - printf "module fake_java_module // Exclude this directory from Go tools\n\ngo 1.17\n" > sdk/java/go.mod - @touch $@ -.make/build_java: PACKAGE_VERSION := $(VERSION_GENERIC) -.make/build_java: .make/generate_java + +build_java: PACKAGE_VERSION := $(VERSION_GENERIC) +build_java: export PULUMI_HOME := $(WORKING_DIR)/.pulumi +build_java: export PATH := $(WORKING_DIR)/.pulumi/bin:$(PATH) +build_java: export PULUMI_CONVERT_EXAMPLES_CACHE_DIR := $(WORKING_DIR)/.pulumi/examples-cache +build_java: bin/pulumi-java-gen upstream + $(WORKING_DIR)/bin/$(JAVA_GEN) generate --schema provider/cmd/$(PROVIDER)/schema.json --out sdk/java --build gradle-nexus cd sdk/java/ && \ + printf "module fake_java_module // Exclude this directory from Go tools\n\ngo 1.17\n" > go.mod && \ gradle --console=plain build && \ gradle --console=plain javadoc - @touch $@ -.PHONY: generate_java build_java - -generate_nodejs: .make/generate_nodejs -build_nodejs: .make/build_nodejs -.make/generate_nodejs: export PATH := $(WORKING_DIR)/.pulumi/bin:$(PATH) -.make/generate_nodejs: bin/$(TFGEN) - $(GEN_ENVS) $(WORKING_DIR)/bin/$(TFGEN) nodejs --out sdk/nodejs/ - printf "module fake_nodejs_module // Exclude this directory from Go tools\n\ngo 1.17\n" > sdk/nodejs/go.mod - @touch $@ -.make/build_nodejs: .make/generate_nodejs + +build_nodejs: export PULUMI_HOME := $(WORKING_DIR)/.pulumi +build_nodejs: export PATH := $(WORKING_DIR)/.pulumi/bin:$(PATH) +build_nodejs: export PULUMI_CONVERT_EXAMPLES_CACHE_DIR := $(WORKING_DIR)/.pulumi/examples-cache +build_nodejs: upstream + PULUMI_CONVERT=$(PULUMI_CONVERT) PULUMI_DISABLE_AUTOMATIC_PLUGIN_ACQUISITION=$(PULUMI_CONVERT) $(WORKING_DIR)/bin/$(TFGEN) nodejs --out sdk/nodejs/ cd sdk/nodejs/ && \ + printf "module fake_nodejs_module // Exclude this directory from Go tools\n\ngo 1.17\n" > go.mod && \ yarn install && \ yarn run tsc && \ cp ../../README.md ../../LICENSE* package.json yarn.lock ./bin/ - @touch $@ -.PHONY: generate_nodejs build_nodejs - -generate_python: .make/generate_python -build_python: .make/build_python -.make/generate_python: export PATH := $(WORKING_DIR)/.pulumi/bin:$(PATH) -.make/generate_python: bin/$(TFGEN) - $(GEN_ENVS) $(WORKING_DIR)/bin/$(TFGEN) python --out sdk/python/ - printf "module fake_python_module // Exclude this directory from Go tools\n\ngo 1.17\n" > sdk/python/go.mod - cp README.md sdk/python/ - @touch $@ -.make/build_python: .make/generate_python + +build_python: export PULUMI_HOME := $(WORKING_DIR)/.pulumi +build_python: export PATH := $(WORKING_DIR)/.pulumi/bin:$(PATH) +build_python: export PULUMI_CONVERT_EXAMPLES_CACHE_DIR := $(WORKING_DIR)/.pulumi/examples-cache +build_python: upstream + rm -rf sdk/python/ + PULUMI_CONVERT=$(PULUMI_CONVERT) PULUMI_DISABLE_AUTOMATIC_PLUGIN_ACQUISITION=$(PULUMI_CONVERT) $(WORKING_DIR)/bin/$(TFGEN) python --out sdk/python/ cd sdk/python/ && \ + printf "module fake_python_module // Exclude this directory from Go tools\n\ngo 1.17\n" > go.mod && \ + cp ../../README.md . && \ rm -rf ./bin/ ../python.bin/ && cp -R . ../python.bin && mv ../python.bin ./bin && \ rm ./bin/go.mod && \ python3 -m venv venv && \ ./venv/bin/python -m pip install build==1.2.1 && \ cd ./bin && \ ../venv/bin/python -m build . - @touch $@ -.PHONY: generate_python build_python clean: rm -rf sdk/{dotnet,nodejs,go,python} - rm -rf bin/* - rm -rf .make/* - if dotnet nuget list source | grep "$(WORKING_DIR)/nuget"; then \ - dotnet nuget remove source "$(WORKING_DIR)/nuget" \ - ; fi -.PHONY: clean - -install_dotnet_sdk: .make/install_dotnet_sdk -.make/install_dotnet_sdk: .make/build_dotnet - mkdir -p nuget - find sdk/dotnet/bin -name '*.nupkg' -print -exec cp -p "{}" ${WORKING_DIR}/nuget \; - if ! dotnet nuget list source | grep "${WORKING_DIR}/nuget"; then \ - dotnet nuget add source "${WORKING_DIR}/nuget" --name "${WORKING_DIR}/nuget" \ - ; fi - @touch $@ -install_go_sdk: -install_java_sdk: -install_nodejs_sdk: .make/install_nodejs_sdk -.make/install_nodejs_sdk: .make/build_nodejs + +cleanup: + rm -r $(WORKING_DIR)/bin + rm -f provider/cmd/$(PROVIDER)/schema.go + +help: + @grep '^[^.#]\+:\s\+.*#' Makefile | \ + sed "s/\(.\+\):\s*\(.*\) #\s*\(.*\)/`printf "\033[93m"`\1`printf "\033[0m"` \3 [\2]/" | \ + expand -t20 + +install_dotnet_sdk: + mkdir -p $(WORKING_DIR)/nuget + find . -name '*.nupkg' -print -exec cp -p {} $(WORKING_DIR)/nuget \; + +install_nodejs_sdk: yarn link --cwd $(WORKING_DIR)/sdk/nodejs/bin - @touch $@ -install_python_sdk: -.PHONY: install_dotnet_sdk install_go_sdk install_java_sdk install_nodejs_sdk install_python_sdk -# Install Pulumi plugins required for TFGen to resolve references -install_plugins: .make/install_plugins -.make/install_plugins: export PULUMI_HOME := $(WORKING_DIR)/.pulumi -.make/install_plugins: export PATH := $(WORKING_DIR)/.pulumi/bin:$(PATH) -.make/install_plugins: .pulumi/bin/pulumi +install_plugins: export PULUMI_HOME := $(WORKING_DIR)/.pulumi +install_plugins: export PATH := $(WORKING_DIR)/.pulumi/bin:$(PATH) +install_plugins: .pulumi/bin/pulumi .pulumi/bin/pulumi plugin install converter terraform 1.0.16 - @touch $@ -.PHONY: install_plugins lint_provider: provider cd provider && golangci-lint run --path-prefix provider -c ../.golangci.yml + # `lint_provider.fix` is a utility target meant to be run manually # that will run the linter and fix errors when possible. 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-xyz/schema.json` is valid and up to date. # To create a release ready binary, you should use `make provider`. -build_provider_cmd = cd provider && go build $(PULUMI_PROVIDER_BUILD_PARALLELISM) -o $(WORKING_DIR)/bin/$(PROVIDER) -ldflags "$(LDFLAGS)" $(PROJECT)/$(PROVIDER_PATH)/cmd/$(PROVIDER) -provider: bin/$(PROVIDER) provider_no_deps: - $(call build_provider_cmd) -bin/$(PROVIDER): .make/schema - $(call build_provider_cmd) -.PHONY: provider provider_no_deps + (cd provider && go build $(PULUMI_PROVIDER_BUILD_PARALLELISM) -o $(WORKING_DIR)/bin/$(PROVIDER) -ldflags "$(LDFLAGS)" $(PROJECT)/$(PROVIDER_PATH)/cmd/$(PROVIDER)) + +provider: tfgen 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: + @echo "" + @echo "== test_provider ===================================================================" + @echo "" cd provider && go test -v -short ./... -parallel $(TESTPARALLELISM) -.PHONY: test_provider - -tfgen: 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 -.make/schema: export PATH := $(WORKING_DIR)/.pulumi/bin:$(PATH) -.make/schema: export PULUMI_CONVERT := $(PULUMI_CONVERT) -.make/schema: export PULUMI_CONVERT_EXAMPLES_CACHE_DIR := $(WORKING_DIR)/.pulumi/examples-cache -.make/schema: export PULUMI_DISABLE_AUTOMATIC_PLUGIN_ACQUISITION := $(PULUMI_CONVERT) -.make/schema: export PULUMI_MISSING_DOCS_ERROR := $(PULUMI_MISSING_DOCS_ERROR) -.make/schema: bin/$(TFGEN) provider/resources.go provider/go.mod .make/install_plugins .make/upstream + +tfgen: install_plugins upstream tfgen_no_deps + +tfgen_no_deps: export PULUMI_HOME := $(WORKING_DIR)/.pulumi +tfgen_no_deps: export PATH := $(WORKING_DIR)/.pulumi/bin:$(PATH) +tfgen_no_deps: export PULUMI_CONVERT := $(PULUMI_CONVERT) +tfgen_no_deps: export PULUMI_CONVERT_EXAMPLES_CACHE_DIR := $(WORKING_DIR)/.pulumi/examples-cache +tfgen_no_deps: export PULUMI_DISABLE_AUTOMATIC_PLUGIN_ACQUISITION := $(PULUMI_CONVERT) +tfgen_no_deps: export PULUMI_MISSING_DOCS_ERROR := $(PULUMI_MISSING_DOCS_ERROR) +tfgen_no_deps: tfgen_build_only $(WORKING_DIR)/bin/$(TFGEN) schema --out provider/cmd/$(PROVIDER) (cd provider && VERSION=$(VERSION_GENERIC) go generate cmd/$(PROVIDER)/main.go) - @touch $@ -tfgen_build_only: bin/$(TFGEN) -bin/$(TFGEN): + +tfgen_build_only: (cd provider && go build $(PULUMI_PROVIDER_BUILD_PARALLELISM) -o $(WORKING_DIR)/bin/$(TFGEN) -ldflags "$(LDFLAGS_PROJ_VERSION) $(LDFLAGS_EXTRAS)" $(PROJECT)/$(PROVIDER_PATH)/cmd/$(TFGEN)) -.PHONY: tfgen schema tfgen_no_deps tfgen_build_only -# Apply patches to the upstream submodule, if it exists -upstream: .make/upstream -# Re-run if the upstream commit or the patches change -.make/upstream: $(wildcard patches/*) $(wildcard .git/modules/upstream/HEAD) +upstream: ifneq ("$(wildcard upstream)","") ./upstream.sh init endif - @touch $@ -.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 @@ -269,7 +178,6 @@ bin/pulumi-java-gen: .pulumi-java-gen.version # ci-mgmt: .ci-mgmt.yaml go run github.com/pulumi/ci-mgmt/provider-ci@master generate -.PHONY: ci-mgmt # Because some codegen depends on the version of the CLI used, we install a local CLI # version pinned to the same version as `provider/go.mod`. @@ -280,7 +188,6 @@ ci-mgmt: .ci-mgmt.yaml .pulumi/bin/pulumi: .pulumi/version @if [ -x .pulumi/bin/pulumi ] && [ "v$$(cat .pulumi/version)" = "$$(.pulumi/bin/pulumi version)" ]; then \ echo "pulumi/bin/pulumi version: v$$(cat .pulumi/version)"; \ - touch $@; \ else \ curl -fsSL https://get.pulumi.com | \ HOME=$(WORKING_DIR) sh -s -- --version "$$(cat .pulumi/version)"; \ @@ -288,12 +195,14 @@ ci-mgmt: .ci-mgmt.yaml # Compute the version of Pulumi to use by inspecting the Go dependencies of the provider. .pulumi/version: provider/go.mod - cd provider && go list -f "{{slice .Version 1}}" -m github.com/pulumi/pulumi/pkg/v3 | tee ../$@ + @mkdir -p .pulumi + @cd provider && go list -f "{{slice .Version 1}}" -m github.com/pulumi/pulumi/pkg/v3 | tee ../$@ # Start debug server for tfgen debug_tfgen: dlv --listen=:2345 --headless=true --api-version=2 exec $(WORKING_DIR)/bin/$(TFGEN) -- schema --out provider/cmd/$(PROVIDER) -.PHONY: debug_tfgen + +.PHONY: development build build_sdks install_go_sdk install_java_sdk install_python_sdk install_sdks only_build build_dotnet build_go build_java build_nodejs build_python clean cleanup help install_dotnet_sdk install_nodejs_sdk install_plugins lint_provider provider provider_no_deps test tfgen upstream ci-mgmt test_provider debug_tfgen tfgen_build_only # Provider cross-platform build & packaging