github.com/GoogleCloudPlatform/testgrid@v0.0.174/hack/autodeps.sh (about)

     1  #!/bin/bash
     2  # Copyright 2018 The Kubernetes Authors.
     3  #
     4  # Licensed under the Apache License, Version 2.0 (the "License");
     5  # you may not use this file except in compliance with the License.
     6  # You may obtain a copy of the License at
     7  #
     8  #     http://www.apache.org/licenses/LICENSE-2.0
     9  #
    10  # Unless required by applicable law or agreed to in writing, software
    11  # distributed under the License is distributed on an "AS IS" BASIS,
    12  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  # See the License for the specific language governing permissions and
    14  # limitations under the License.
    15  
    16  set -o nounset
    17  set -o errexit
    18  set -o pipefail
    19  
    20  cd $(git rev-parse --show-toplevel)
    21  
    22  if [[ $# -lt 2 ]]; then
    23      echo "Usage: $(basename "$0") <github-login> </path/to/github/token> [git-name] [git-email] [--patch|--minor]" >&2
    24      exit 1
    25  fi
    26  user=$1
    27  token=$2
    28  shift 2
    29  if [[ $# -ge 2 ]]; then
    30    echo "git config user.name=$1 user.email=$2..." >&2
    31    git config user.name "$1"
    32    git config user.email "$2"
    33    shift 2
    34  fi
    35  if ! git config user.name &>/dev/null && git config user.email &>/dev/null; then
    36      echo "ERROR: git config user.name, user.email unset. No defaults provided" >&2
    37      exit 1
    38  fi
    39  
    40  export GO111MODULE=on
    41  ./hack/update-deps.sh "$@"  # --patch or --minor
    42  
    43  
    44  git add -A
    45  if git diff --name-only --exit-code HEAD; then
    46      echo "Nothing changed" >&2
    47      exit 0
    48  fi
    49  
    50  if ! bazel test //... -- -//vendor/...; then
    51      echo "ERROR: update fails unit tests." >&2
    52      exit 1
    53  fi
    54  
    55  title="Run ./hack/update-deps.sh $@"
    56  git commit -m "${title}"
    57  git push -f "git@github.com:${user}/testgrid.git" HEAD:autoupdate
    58  
    59  echo "Creating PR to merge ${user}:autoupdate into master..." >&2
    60  bazel run //robots/pr-creator -- \
    61      --github-token-path="${token}" \
    62      --org=GoogleCloudPlatform --repo=testgrid --branch=master \
    63      --title="${title}" --match-title="${title}" \
    64      --body="Automatic go module update. Please review" \
    65      --source="${user}":autoupdate \
    66      --confirm