Skip to content
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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions prow/cluster/jobs/istio/api/istio.api.master.gen.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion prow/cluster/jobs/istio/pkg/istio.pkg.master.gen.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions prow/config/jobs/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion prow/config/jobs/client-go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
2 changes: 1 addition & 1 deletion prow/config/jobs/gogo-genproto.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
2 changes: 1 addition & 1 deletion prow/config/jobs/pkg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
1 change: 1 addition & 0 deletions prow/config/jobs/proxy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion tools/automator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 '\<string\>'. If no additional changes remain, the automator task will stop. | `^common/`<br> `^pkg/\|^pilot/`|

### Environment Variables

Expand Down
21 changes: 17 additions & 4 deletions tools/automator/automator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ get_opts() {
shift
;;
--git-exclude)
git_exclude=(":^$2")
git_exclude="$2"
shift 2
;;
--)
Expand Down Expand Up @@ -196,7 +196,7 @@ validate_opts() {
fi

if [ -z "${git_exclude:-}" ]; then
git_exclude=()
git_exclude=""
fi
}

Expand Down Expand Up @@ -237,7 +237,7 @@ add_labels() {

commit() {
if $dry_run; then
git diff --cached "${git_exclude[@]}"
git diff --cached
return 0
fi

Expand Down Expand Up @@ -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

Expand All @@ -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
Expand All @@ -323,6 +335,7 @@ main() {
get_opts "$@"
validate_opts
export_globals
validate_changes_exist_in_latest_commit

AUTOMATOR_ROOT_DIR="$(pwd)"

Expand Down