From 4d0b3433888a190e898b5532e23f9d92fa5ba9b6 Mon Sep 17 00:00:00 2001 From: Pulumi Bot <30351955+pulumi-bot@users.noreply.github.com> Date: Fri, 26 Jul 2024 00:15:18 -0700 Subject: [PATCH] Update GitHub Actions workflows. (#432) This PR was automatically generated by the update-workflows-ecosystem-providers workflow in the pulumi/ci-mgmt repo, from commit 1aa9684665255d96334711d99f91beacdfb0ecf2. --- Makefile | 4 +- upstream.sh | 106 ++++++++++++++++++++++++++++------------------------ 2 files changed, 59 insertions(+), 51 deletions(-) diff --git a/Makefile b/Makefile index b0863644..f8cf091c 100644 --- a/Makefile +++ b/Makefile @@ -163,7 +163,7 @@ tfgen_build_only: upstream: ifneq ("$(wildcard upstream)","") - ./upstream.sh init -f + ./upstream.sh init endif bin/pulumi-java-gen: .pulumi-java-gen.version @@ -205,7 +205,7 @@ ci-mgmt: .ci-mgmt.yaml debug_tfgen: dlv --listen=:2345 --headless=true --api-version=2 exec $(WORKING_DIR)/bin/$(TFGEN) -- schema --out provider/cmd/$(PROVIDER) -.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 upstream.finalize upstream.rebase ci-mgmt test_provider debug_tfgen tfgen_build_only +.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 diff --git a/upstream.sh b/upstream.sh index f56ca1a5..b3d09931 100755 --- a/upstream.sh +++ b/upstream.sh @@ -12,7 +12,7 @@ NAME upstream.sh - Manages applying patches to the upstream submodule. SYNOPSIS - ${original_exec} [options] + ${original_exec} [options] COMMANDS init [-f] Initialize the upstream submodule and applies the @@ -20,7 +20,6 @@ COMMANDS checkout [-f] Create a branch in the upstream repository with the patches applied as commits. rebase [-o] [-i] Rebase the checked out patches. - format_patches Write checkedout commits back to patches. check_in Write checkedout commits back to patches, add upstream and patches changes to the git staging area and exit checkout mode. @@ -51,12 +50,18 @@ EXAMPLES Moving the patches to a new base commit: ${original_exec} checkout ${original_exec} rebase -o - ${original_exec} format_patches + ${original_exec} check_in Interactively edit the patches: ${original_exec} checkout ${original_exec} rebase -i - ${original_exec} format_patches + ${original_exec} check_in + + Add a new patch: + ${original_exec} checkout + # Make changes to the upstream repository + git commit -am "Add new feature" + ${original_exec} check_in EOF } @@ -67,41 +72,24 @@ assert_upstream_exists() { fi } -# Check the upstream submodule isn't modified in the working tree -assert_upstream_tracked() { - status=$(git status --porcelain upstream) - if [[ ${status} == *"M upstream" ]]; then - current_branch=$(cd upstream && git --no-pager rev-parse --abbrev-ref HEAD) - if [[ "${current_branch}" == "pulumi/patch-checkout" ]]; then - cat < && cd -) - EOF exit 1 fi + } assert_is_checked_out() { @@ -157,6 +145,30 @@ apply_patches() { done } +clean_rebases() { + # Clean up any previous in-progress rebases. + cd upstream + rebase_merge_dir=$(git rev-parse --git-path rebase-merge) + rebase_apply_dir=$(git rev-parse --git-path rebase-apply) + rm -rf "${rebase_merge_dir}" + rm -rf "${rebase_apply_dir}" + cd .. +} + +clean_branches() { + cd upstream + if git show-ref --verify --quiet refs/heads/pulumi/patch-checkout; then + git branch -D pulumi/patch-checkout + fi + if git show-ref --verify --quiet refs/heads/pulumi/checkout-base; then + git branch -D pulumi/checkout-base + fi + if git show-ref --verify --quiet refs/heads/pulumi/original-base; then + git branch -D pulumi/original-base + fi + cd .. +} + init() { # Parse additional flags while getopts "f" flag; do @@ -169,12 +181,15 @@ init() { assert_upstream_exists if [[ "${force}" != "true" ]]; then - assert_upstream_tracked - else - echo "Warning: forcing init command to run even if the upstream submodule is modified." + assert_not_checked_out + assert_no_rebase_in_progress fi git submodule update --force --init + if [[ "${force}" == "true" ]]; then + clean_rebases + clean_branches + fi apply_patches } @@ -190,24 +205,17 @@ checkout() { assert_upstream_exists if [[ "${force}" != "true" ]]; then - assert_upstream_tracked - else - echo "Warning: forcing checkout command to run even if the upstream submodule is modified." + assert_not_checked_out + assert_no_rebase_in_progress fi git submodule update --force --init - cd upstream if [[ "${force}" == "true" ]]; then - echo "Cleaning up any previous branches" - git branch -D pulumi/patch-checkout - git branch -D pulumi/checkout-base - git branch -D pulumi/original-base + clean_rebases + clean_branches fi - # Clean up any previous in-progress rebases. - rebase_merge_dir=$(git rev-parse --git-path rebase-merge) - rebase_apply_dir=$(git rev-parse --git-path rebase-apply) - rm -rf "${rebase_merge_dir}" - rm -rf "${rebase_apply_dir}" + + cd upstream git fetch --all # Set the 'pulumi/checkout-base' branch to the current commit of the upstream repository @@ -344,7 +352,7 @@ case ${original_cmd} in init) init "$@" ;; - checkout) + checkout|check_out) checkout "$@" ;; rebase) @@ -353,7 +361,7 @@ case ${original_cmd} in format_patches) format_patches "$@" ;; - check_in) + check_in|checkin) check_in "$@" ;; *)