Files
moby/hack/validate/default
T
Kir Kolyshkin 5a9f94d84d hack/validate/{all,default}: run all scripts
Currently, hack/validate/default and hack/validate/all source all the
scripts, thus making them part of the current one.

This is wrong for a number of reasons, the main one being any script
being sourced can make changes in the current shell thus influencing all
the scripts that are sourced after it. For example, any script sourced
can set or unset shell variables, change shell options, or just exit.

In fact, four of the scripts have exit statement:

	$ git grep -w exit hack/validate/
	hack/validate/module-replace:	exit 1
	hack/validate/pr-gh-references:	exit 1
	hack/validate/shfmt:	exit 1
	hack/validate/vendor:	exit 1

and most of the others have `set -e` and/or `set -o pipefail`.
This means that if there is any error from any of the scripts,
or even just innocent "exit 0"), all the script below won't be
executed.

To fix this, while still making the "mega" script return an error, let's
run those scripts one by one, checking their exit codes, and exit with
the last non-zero exit code, if any (or 0, if all scripts exited with 0).

While at it, fix some issues reported by shellcheck.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-10-11 12:28:08 -07:00

20 lines
377 B
Bash
Executable File

#!/usr/bin/env bash
#
# Run default validation, exclude vendor because it's slow
SCRIPTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SCRIPTS=(
# Skip DCO check here, as it's already checked in a separate check in ci
# dco
pkg-imports
deprecate-integration-cli
golangci-lint
shfmt
)
RET=0
for SCR in "${SCRIPTS[@]}"; do
"$SCRIPTDIR/$SCR" || RET=$?
done
exit $RET