From 5df2a0c5160b86694dd20f37da73e6b486061563 Mon Sep 17 00:00:00 2001 From: Mike Dame Date: Mon, 8 Mar 2021 10:51:01 -0500 Subject: [PATCH] Add hack scripts and makefile targets --- Makefile | 6 +++++- hack/update-toc.sh | 25 +++++++++++++++++++++++++ hack/verify-toc.sh | 29 +++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100755 hack/update-toc.sh create mode 100755 hack/verify-toc.sh diff --git a/Makefile b/Makefile index c580d1a46..882f5c448 100644 --- a/Makefile +++ b/Makefile @@ -88,7 +88,7 @@ push-all: image.amd64 image.arm64 clean: rm -rf _output -verify: verify-gofmt verify-vendor lint lint-chart verify-spelling +verify: verify-gofmt verify-vendor lint lint-chart verify-spelling verify-toc verify-spelling: ./hack/verify-spelling.sh @@ -99,6 +99,9 @@ verify-gofmt: verify-vendor: ./hack/verify-vendor.sh +verify-toc: + ./hack/verify-toc.sh + test-unit: ./test/run-unit-tests.sh @@ -109,6 +112,7 @@ gen: ./hack/update-generated-conversions.sh ./hack/update-generated-deep-copies.sh ./hack/update-generated-defaulters.sh + ./hack/update-toc.sh lint: ifndef HAS_GOLANGCI diff --git a/hack/update-toc.sh b/hack/update-toc.sh new file mode 100755 index 000000000..2ce6d0815 --- /dev/null +++ b/hack/update-toc.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# Copyright 2021 The Kubernetes Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -o errexit +set -o nounset +set -o pipefail + +source "$(dirname "${BASH_SOURCE}")/lib/init.sh" + +go build -o "${OS_OUTPUT_BINPATH}/mdtoc" "sigs.k8s.io/mdtoc" + +${OS_OUTPUT_BINPATH}/mdtoc --inplace README.md diff --git a/hack/verify-toc.sh b/hack/verify-toc.sh new file mode 100755 index 000000000..11371b02d --- /dev/null +++ b/hack/verify-toc.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +# Copyright 2021 The Kubernetes Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -o errexit +set -o nounset +set -o pipefail + +source "$(dirname "${BASH_SOURCE}")/lib/init.sh" + +go build -o "${OS_OUTPUT_BINPATH}/mdtoc" "sigs.k8s.io/mdtoc" + +if ! ${OS_OUTPUT_BINPATH}/mdtoc --inplace --dryrun README.md +then + echo "ERROR: Changes detected to table of contents. Run ./hack/update-toc.sh" >&2 + exit 1 +fi