sigs.k8s.io/kueue@v0.6.2/hack/verify-toc.sh (about)

     1  #!/usr/bin/env bash
     2  
     3  # Copyright 2022 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  # keep in sync with hack/update-toc.sh
    22  TOOL_VERSION=b8c54a57d69f29386d055584e595f38d65ce2a1f
    23  
    24  # cd to the root path
    25  ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)"
    26  cd "${ROOT}"
    27  
    28  # create a temporary directory
    29  TMP_DIR=$(mktemp -d)
    30  
    31  # cleanup
    32  exitHandler() (
    33    echo "Cleaning up..."
    34    rm -rf "${TMP_DIR}"
    35  )
    36  trap exitHandler EXIT
    37  
    38  # perform go install in a temp dir as we are not tracking this version in a go module
    39  # if we do the go install in the repo, it will create / update a go.mod and go.sum
    40  cd "${TMP_DIR}"
    41  GO111MODULE=on GOBIN="${TMP_DIR}" go install "sigs.k8s.io/mdtoc@${TOOL_VERSION}"
    42  export PATH="${TMP_DIR}:${PATH}"
    43  cd "${ROOT}"
    44  
    45  echo "Checking table of contents are up to date..."
    46  # Verify tables of contents are up-to-date
    47  find keps -name '*.md' \
    48      | grep -Fxvf hack/.notableofcontents \
    49      | xargs mdtoc --inplace --max-depth=5 --dryrun || (
    50        echo "Table of content not up to date. If this failed silently and you are on mac, try 'brew install grep'"
    51        exit 1
    52      )