diff --git a/prow/cluster/jobs/istio-private/proxy/istio-private.proxy.master.gen.yaml b/prow/cluster/jobs/istio-private/proxy/istio-private.proxy.master.gen.yaml index aba953ee596..43396ec827b 100644 --- a/prow/cluster/jobs/istio-private/proxy/istio-private.proxy.master.gen.yaml +++ b/prow/cluster/jobs/istio-private/proxy/istio-private.proxy.master.gen.yaml @@ -139,6 +139,7 @@ postsubmits: - --labels=auto-merge,release-notes-none - --modifier=update_proxy_dep - --token-path=/etc/github-token/oauth + - --git-exclude=^common/ - --cmd=bin/update_proxy.sh $AUTOMATOR_SHA env: - name: BAZEL_BUILD_RBE_INSTANCE diff --git a/prow/cluster/jobs/istio/api/istio.api.master.gen.yaml b/prow/cluster/jobs/istio/api/istio.api.master.gen.yaml index 2dba2c313ec..952e0ca32ac 100644 --- a/prow/cluster/jobs/istio/api/istio.api.master.gen.yaml +++ b/prow/cluster/jobs/istio/api/istio.api.master.gen.yaml @@ -98,6 +98,7 @@ postsubmits: - --labels=auto-merge,release-notes-none - --modifier=update_api_dep - --token-path=/etc/github-token/oauth + - --git-exclude=^common/ - --cmd=go get istio.io/api@$AUTOMATOR_SHA && go mod tidy && make clean gen image: gcr.io/istio-testing/build-tools:master-2021-07-06T15-41-58 name: "" diff --git a/prow/cluster/jobs/istio/client-go/istio.client-go.master.gen.yaml b/prow/cluster/jobs/istio/client-go/istio.client-go.master.gen.yaml index a37ad6a7f97..e870c4937f6 100644 --- a/prow/cluster/jobs/istio/client-go/istio.client-go.master.gen.yaml +++ b/prow/cluster/jobs/istio/client-go/istio.client-go.master.gen.yaml @@ -134,7 +134,7 @@ postsubmits: - --labels=auto-merge,release-notes-none - --modifier=update_client-go_dep - --token-path=/etc/github-token/oauth - - --git-exclude=common + - --git-exclude=^common/ - --cmd=go get istio.io/client-go@$AUTOMATOR_SHA && go mod tidy && make clean gen image: gcr.io/istio-testing/build-tools:master-2021-07-06T15-41-58 diff --git a/prow/cluster/jobs/istio/gogo-genproto/istio.gogo-genproto.master.gen.yaml b/prow/cluster/jobs/istio/gogo-genproto/istio.gogo-genproto.master.gen.yaml index 2095ee67214..3171123ed39 100644 --- a/prow/cluster/jobs/istio/gogo-genproto/istio.gogo-genproto.master.gen.yaml +++ b/prow/cluster/jobs/istio/gogo-genproto/istio.gogo-genproto.master.gen.yaml @@ -134,7 +134,7 @@ postsubmits: - --labels=auto-merge,release-notes-none - --modifier=update_gogo-genproto_dep - --token-path=/etc/github-token/oauth - - --git-exclude=common + - --git-exclude=^common/ - --cmd=go get istio.io/gogo-genproto@$AUTOMATOR_SHA && go mod tidy && make clean gen image: gcr.io/istio-testing/build-tools:master-2021-07-06T15-41-58 diff --git a/prow/cluster/jobs/istio/pkg/istio.pkg.master.gen.yaml b/prow/cluster/jobs/istio/pkg/istio.pkg.master.gen.yaml index 5e2793c2c18..131d128a5ab 100644 --- a/prow/cluster/jobs/istio/pkg/istio.pkg.master.gen.yaml +++ b/prow/cluster/jobs/istio/pkg/istio.pkg.master.gen.yaml @@ -170,7 +170,7 @@ postsubmits: - --labels=auto-merge,release-notes-none - --modifier=update_pkg_dep - --token-path=/etc/github-token/oauth - - --git-exclude=common + - --git-exclude=^common/ - --cmd=go get istio.io/pkg@$AUTOMATOR_SHA && go mod tidy && make clean gen image: gcr.io/istio-testing/build-tools:master-2021-07-06T15-41-58 name: "" diff --git a/prow/cluster/jobs/istio/proxy/istio.proxy.master.gen.yaml b/prow/cluster/jobs/istio/proxy/istio.proxy.master.gen.yaml index 0eee429a9e0..8b473b58974 100644 --- a/prow/cluster/jobs/istio/proxy/istio.proxy.master.gen.yaml +++ b/prow/cluster/jobs/istio/proxy/istio.proxy.master.gen.yaml @@ -110,6 +110,7 @@ postsubmits: - --labels=auto-merge,release-notes-none - --modifier=update_proxy_dep - --token-path=/etc/github-token/oauth + - --git-exclude=^common/ - --cmd=bin/update_proxy.sh $AUTOMATOR_SHA image: gcr.io/istio-testing/build-tools:master-2021-07-06T15-41-58 name: "" diff --git a/prow/config/jobs/api.yaml b/prow/config/jobs/api.yaml index 160022e846c..3232e2d2e51 100644 --- a/prow/config/jobs/api.yaml +++ b/prow/config/jobs/api.yaml @@ -20,6 +20,7 @@ jobs: - --labels=auto-merge,release-notes-none - --modifier=update_api_dep - --token-path=/etc/github-token/oauth + - --git-exclude=^common/ - --cmd=go get istio.io/api@$AUTOMATOR_SHA && go mod tidy && make clean gen requirements: [github] repos: [istio/test-infra@master] diff --git a/prow/config/jobs/client-go.yaml b/prow/config/jobs/client-go.yaml index 26a400733ba..6c95f7e8f93 100644 --- a/prow/config/jobs/client-go.yaml +++ b/prow/config/jobs/client-go.yaml @@ -23,7 +23,7 @@ jobs: - --labels=auto-merge,release-notes-none - --modifier=update_client-go_dep - --token-path=/etc/github-token/oauth - - --git-exclude=common + - --git-exclude=^common/ - --cmd=go get istio.io/client-go@$AUTOMATOR_SHA && go mod tidy && make clean gen requirements: [github] repos: [istio/test-infra@master] diff --git a/prow/config/jobs/gogo-genproto.yaml b/prow/config/jobs/gogo-genproto.yaml index 3c9305e0b87..a6797bc4a2d 100644 --- a/prow/config/jobs/gogo-genproto.yaml +++ b/prow/config/jobs/gogo-genproto.yaml @@ -23,7 +23,7 @@ jobs: - --labels=auto-merge,release-notes-none - --modifier=update_gogo-genproto_dep - --token-path=/etc/github-token/oauth - - --git-exclude=common + - --git-exclude=^common/ - --cmd=go get istio.io/gogo-genproto@$AUTOMATOR_SHA && go mod tidy && make clean gen requirements: [github] repos: [istio/test-infra@master] diff --git a/prow/config/jobs/pkg.yaml b/prow/config/jobs/pkg.yaml index a37139508cf..a52295eb48e 100644 --- a/prow/config/jobs/pkg.yaml +++ b/prow/config/jobs/pkg.yaml @@ -26,7 +26,7 @@ jobs: - --labels=auto-merge,release-notes-none - --modifier=update_pkg_dep - --token-path=/etc/github-token/oauth - - --git-exclude=common + - --git-exclude=^common/ - --cmd=go get istio.io/pkg@$AUTOMATOR_SHA && go mod tidy && make clean gen requirements: [github] repos: [istio/test-infra@master] diff --git a/prow/config/jobs/proxy.yaml b/prow/config/jobs/proxy.yaml index 2c6c5d15e1a..52357b13cca 100644 --- a/prow/config/jobs/proxy.yaml +++ b/prow/config/jobs/proxy.yaml @@ -66,6 +66,7 @@ jobs: - --labels=auto-merge,release-notes-none - --modifier=update_proxy_dep - --token-path=/etc/github-token/oauth + - --git-exclude=^common/ - --cmd=bin/update_proxy.sh $AUTOMATOR_SHA requirements: [github] repos: [istio/test-infra@master] diff --git a/tools/automator/README.md b/tools/automator/README.md index 9f84d1e4812..23597c943e8 100644 --- a/tools/automator/README.md +++ b/tools/automator/README.md @@ -57,7 +57,7 @@ The following is a list of supported options for `automator.sh`. If an option is | `--verbose` | | Enable verbose output. Print commands and their arguments as they are executed. **WARNING**: this has the potential to print sensitive data to standard output. | | | `--strict` | | Enable strict mode. When enabled, if the command does not produce a [git diff] it will exit with a non-zero exit code. | | | `--dry-run` | | Enable dry run mode. When enabled, the command will terminate early and **NOT** perform a commit, push, or pull request for any changes. This is useful for local testing/debugging or when concerned only with the [git diff] or exit code of the command. | | -| `--git-exclude` | string | Added to `git diff` to exclude a file/path when detrining changes | `common` | +| `--git-exclude` | string | Applied to list of file changes in the commit CAUSING this automator run using grep -vE '\'. If no additional changes remain, the automator task will stop. | `^common/`
`^pkg/\|^pilot/`| ### Environment Variables diff --git a/tools/automator/automator.sh b/tools/automator/automator.sh index 314edef3db8..df96a577d03 100755 --- a/tools/automator/automator.sh +++ b/tools/automator/automator.sh @@ -118,7 +118,7 @@ get_opts() { shift ;; --git-exclude) - git_exclude=(":^$2") + git_exclude="$2" shift 2 ;; --) @@ -196,7 +196,7 @@ validate_opts() { fi if [ -z "${git_exclude:-}" ]; then - git_exclude=() + git_exclude="" fi } @@ -237,7 +237,7 @@ add_labels() { commit() { if $dry_run; then - git diff --cached "${git_exclude[@]}" + git diff --cached return 0 fi @@ -280,6 +280,18 @@ merge() { fi } +# validate_changes_exist_in_latest_commit validates changes exist in the prior commit after removing files specified +# in the git_exclude list. If no files remain after exclusion, the automation script exits. +validate_changes_exist_in_latest_commit() { + if [ -n "$git_exclude" ]; then + changes=$(git show --name-only --pretty=oneline | sed 1d | grep -cvE "$git_exclude") # need to remove first line + if [ "${changes}" -eq 0 ] + then + print_error_and_exit "No changes remaining in upstream PR after excluding" 0 # not really an error so return 0 + fi + fi +} + work() { ( set -e @@ -305,7 +317,7 @@ work() { ( git add --all - if ! git diff --cached --quiet --exit-code "${git_exclude[@]}"; then + if ! git diff --cached --quiet --exit-code; then commit elif $strict; then print_error "no diff for $repo" 1 @@ -323,6 +335,7 @@ main() { get_opts "$@" validate_opts export_globals + validate_changes_exist_in_latest_commit AUTOMATOR_ROOT_DIR="$(pwd)"