Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update GitHub Actions workflows. #504

Merged
merged 1 commit into from
Feb 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ jobs:
cache: gradle
distribution: temurin
java-version: ${{ env.JAVAVERSION }}
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-version: "7.6"
- name: Download provider + tfgen binaries
uses: actions/download-artifact@v2
with:
Expand Down Expand Up @@ -382,6 +386,10 @@ jobs:
cache: gradle
distribution: temurin
java-version: ${{ env.JAVAVERSION }}
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-version: "7.6"
- name: Download java SDK
uses: actions/download-artifact@v2
with:
Expand Down Expand Up @@ -518,6 +526,10 @@ jobs:
cache: gradle
distribution: temurin
java-version: ${{ env.JAVAVERSION }}
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-version: "7.6"
- name: Download provider + tfgen binaries
uses: actions/download-artifact@v2
with:
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ jobs:
cache: gradle
distribution: temurin
java-version: ${{ env.JAVAVERSION }}
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-version: "7.6"
- name: Download provider + tfgen binaries
uses: actions/download-artifact@v2
with:
Expand Down Expand Up @@ -382,6 +386,10 @@ jobs:
cache: gradle
distribution: temurin
java-version: ${{ env.JAVAVERSION }}
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-version: "7.6"
- name: Download java SDK
uses: actions/download-artifact@v2
with:
Expand Down Expand Up @@ -518,6 +526,10 @@ jobs:
cache: gradle
distribution: temurin
java-version: ${{ env.JAVAVERSION }}
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-version: "7.6"
- name: Download provider + tfgen binaries
uses: actions/download-artifact@v2
with:
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ jobs:
cache: gradle
distribution: temurin
java-version: ${{ env.JAVAVERSION }}
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-version: "7.6"
- name: Download provider + tfgen binaries
uses: actions/download-artifact@v2
with:
Expand Down Expand Up @@ -332,6 +336,10 @@ jobs:
cache: gradle
distribution: temurin
java-version: ${{ env.JAVAVERSION }}
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-version: "7.6"
- name: Download java SDK
uses: actions/download-artifact@v2
with:
Expand Down Expand Up @@ -468,6 +476,10 @@ jobs:
cache: gradle
distribution: temurin
java-version: ${{ env.JAVAVERSION }}
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-version: "7.6"
- name: Download provider + tfgen binaries
uses: actions/download-artifact@v2
with:
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ jobs:
cache: gradle
distribution: temurin
java-version: ${{ env.JAVAVERSION }}
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-version: "7.6"
- name: Download provider + tfgen binaries
uses: actions/download-artifact@v2
with:
Expand Down Expand Up @@ -344,6 +348,10 @@ jobs:
cache: gradle
distribution: temurin
java-version: ${{ env.JAVAVERSION }}
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-version: "7.6"
- name: Download java SDK
uses: actions/download-artifact@v2
with:
Expand Down Expand Up @@ -494,6 +502,10 @@ jobs:
cache: gradle
distribution: temurin
java-version: ${{ env.JAVAVERSION }}
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-version: "7.6"
- name: Download provider + tfgen binaries
uses: actions/download-artifact@v2
with:
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/run-acceptance-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ jobs:
cache: gradle
distribution: temurin
java-version: ${{ env.JAVAVERSION }}
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-version: "7.6"
- name: Download provider + tfgen binaries
uses: actions/download-artifact@v2
with:
Expand Down Expand Up @@ -350,6 +354,10 @@ jobs:
cache: gradle
distribution: temurin
java-version: ${{ env.JAVAVERSION }}
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-version: "7.6"
- name: Download provider + tfgen binaries
uses: actions/download-artifact@v2
with:
Expand Down
61 changes: 54 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,27 @@ install_sdks: install_dotnet_sdk install_python_sdk install_nodejs_sdk install_j
only_build: build

build_dotnet: DOTNET_VERSION := $(shell pulumictl get version --language dotnet)
build_dotnet:
build_dotnet: upstream
pulumictl get version --language dotnet
$(WORKING_DIR)/bin/$(TFGEN) dotnet --out sdk/dotnet/
cd sdk/dotnet/ && \
echo "module fake_dotnet_module // Exclude this directory from Go tools\n\ngo 1.17" > go.mod && \
echo "$(DOTNET_VERSION)" >version.txt && \
dotnet build /p:Version=$(DOTNET_VERSION)

build_go:
build_go: upstream
$(WORKING_DIR)/bin/$(TFGEN) go --out sdk/go/
cd sdk && go list `grep -e "^module" go.mod | cut -d ' ' -f 2`/go/... | xargs go build

build_java: PACKAGE_VERSION := $(shell pulumictl get version --language generic)
build_java: bin/pulumi-java-gen
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/ && \
echo "module fake_java_module // Exclude this directory from Go tools\n\ngo 1.17" > go.mod && \
gradle --console=plain build

build_nodejs: VERSION := $(shell pulumictl get version --language javascript)
build_nodejs:
build_nodejs: upstream
$(WORKING_DIR)/bin/$(TFGEN) nodejs --out sdk/nodejs/
cd sdk/nodejs/ && \
echo "module fake_nodejs_module // Exclude this directory from Go tools\n\ngo 1.17" > go.mod && \
Expand All @@ -60,7 +60,7 @@ build_nodejs:
sed -i.bak -e "s/\$${VERSION}/$(VERSION)/g" ./bin/package.json

build_python: PYPI_VERSION := $(shell pulumictl get version --language python)
build_python:
build_python: upstream
$(WORKING_DIR)/bin/$(TFGEN) python --out sdk/python/
cd sdk/python/ && \
echo "module fake_python_module // Exclude this directory from Go tools\n\ngo 1.17" > go.mod && \
Expand All @@ -81,6 +81,11 @@ cleanup:
docs:
cd provider/pkg/docs-gen/examples/ && go run generate.go ./yaml ./

finish-patch:
@if [ ! -z "$$(cd upstream && git status --porcelain)" ]; then echo "Please commit your changes before finishing the patch"; exit 1; fi
@cd upstream && \
git format-patch HEAD~ -o ../patches --start-number $$(($$(ls ../patches | wc -l | xargs)+1))

help:
@grep '^[^.#]\+:\s\+.*#' Makefile | \
sed "s/\(.\+\):\s*\(.*\) #\s*\(.*\)/`printf "\033[93m"`\1`printf "\033[0m"` \3 [\2]/" | \
Expand All @@ -94,14 +99,37 @@ install_nodejs_sdk:
yarn link --cwd $(WORKING_DIR)/sdk/nodejs/bin

install_plugins:
[ -x $(shell which pulumi) ] || curl -fsSL https://get.pulumi.com | sh
[ -x "$(shell command -v pulumi)" ] || curl -fsSL https://get.pulumi.com | sh

lint_provider: provider
cd provider && golangci-lint run -c ../.golangci.yml

provider: tfgen install_plugins
(cd provider && go build -p 1 -o $(WORKING_DIR)/bin/$(PROVIDER) -ldflags "-X $(PROJECT)/$(VERSION_PATH)=$(VERSION)" $(PROJECT)/$(PROVIDER_PATH)/cmd/$(PROVIDER))

start-patch: upstream
ifeq ("$(wildcard upstream)","")
@echo "No upstream found, so upstream can't be patched"
@exit 1
else
# To add an additional patch:
#
# 1. Run this command (`make start-patch`).
#
# 2. Edit the `upstream` repo, making whatever changes you want to appear in the new
# patch. It's fine to edit multiple files.
#
# 3. Commit your changes. The slugified first line of your commit description will
# be used to generate the patch file name. Only the diff from the latest commit will
# end up in the final patch.
#
# 4. Run `make finish-patch`.
#
# It is safe to run `make start-patch` as many times as you want, but any changes
# might be reverted until `make finish-patch` is run.
@cd upstream && git commit --quiet -m "existing patches"
endif

test:
cd examples && go test -v -tags=all -parallel $(TESTPARALLELISM) -timeout 2h

Expand All @@ -110,7 +138,26 @@ tfgen: install_plugins docs
$(WORKING_DIR)/bin/$(TFGEN) schema --out provider/cmd/$(PROVIDER)
(cd provider && VERSION=$(VERSION) go generate cmd/$(PROVIDER)/main.go)

upstream:
ifeq ("$(wildcard upstream)","")
# upstream doesn't exist, so skip
else ifeq ("$(wildcard patches/*.patch)","")
# upstream exists, but patches don't exist. This is probably an error.
@echo "No patches found within the patch operation"
@echo "patches were expected because upstream exists"
@exit 1
else
# Checkout the submodule at the pinned commit.
# `--force`: If the submodule is at a different commit, move it to the pinned commit.
# `--init`: If the submodule is not initialized, initialize it.
git submodule update --force --init
# Iterating over the patches folder in sorted order,
# apply the patch using a 3-way merge strategy. This mirrors the default behavior of `git merge`
cd upstream && \
for patch in $(sort $(wildcard patches/*.patch)); do git apply --3way ../$$patch || exit 1; done
endif

bin/pulumi-java-gen:
$(shell pulumictl download-binary -n pulumi-language-java -v $(JAVA_GEN_VERSION) -r pulumi/pulumi-java)

.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 docs help install_dotnet_sdk install_nodejs_sdk install_plugins lint_provider provider test 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 docs finish-patch help install_dotnet_sdk install_nodejs_sdk install_plugins lint_provider provider start-patch test tfgen upstream