sigs.k8s.io/gateway-api@v1.0.0/hack/verify-all.sh (about)

     1  #!/bin/bash
     2  
     3  # Copyright 2014 The Kubernetes Authors.
     4  #
     5  # Licensed under the Apache License, Version 2.0 (the "License");
     6  # you may not use this file except in compliance with the License.
     7  # You may obtain a copy of the License at
     8  #
     9  #     http://www.apache.org/licenses/LICENSE-2.0
    10  #
    11  # Unless required by applicable law or agreed to in writing, software
    12  # distributed under the License is distributed on an "AS IS" BASIS,
    13  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14  # See the License for the specific language governing permissions and
    15  # limitations under the License.
    16  
    17  set -o errexit
    18  set -o nounset
    19  set -o pipefail
    20  
    21  SCRIPT_ROOT=$(dirname "${BASH_SOURCE}")/..
    22  source "${SCRIPT_ROOT}/hack/kube-env.sh"
    23  
    24  SILENT=true
    25  
    26  function is-excluded {
    27    for e in $EXCLUDE; do
    28      if [[ $1 -ef ${BASH_SOURCE} ]]; then
    29        return
    30      fi
    31      if [[ $1 -ef "$SCRIPT_ROOT/hack/$e" ]]; then
    32        return
    33      fi
    34    done
    35    return 1
    36  }
    37  
    38  while getopts ":v" opt; do
    39    case $opt in
    40      v)
    41        SILENT=false
    42        ;;
    43      \?)
    44        echo "Invalid flag: -$OPTARG" >&2
    45        exit 1
    46        ;;
    47    esac
    48  done
    49  
    50  if $SILENT ; then
    51    echo "Running in the silent mode, run with -v if you want to see script logs."
    52  fi
    53  
    54  EXCLUDE="verify-all.sh"
    55  
    56  ret=0
    57  for t in `ls $SCRIPT_ROOT/hack/verify-*.sh`
    58  do
    59    if is-excluded $t ; then
    60      echo "Skipping $t"
    61      continue
    62    fi
    63    if $SILENT ; then
    64      echo -e "Verifying $t"
    65      if bash "$t" &> /dev/null; then
    66        echo -e "${color_green}SUCCESS${color_norm}"
    67      else
    68        echo -e "${color_red}FAILED${color_norm}"
    69        ret=1
    70      fi
    71    else
    72      if bash "$t"; then
    73        echo -e "${color_green}SUCCESS: $t ${color_norm}"
    74      else
    75        echo -e "${color_red}Test FAILED: $t ${color_norm}"
    76        ret=1
    77      fi
    78    fi
    79  done
    80  
    81  exit $ret
    82  
    83  # ex: ts=2 sw=2 et filetype=sh