Переглянути джерело

hack/validate: clean-up output, move golang-ci-lint to end

The golang-ci-lint takes longest to run, so do the other
checks first; this also makes the output a bit more readable.

While at it, fix some consistency issues in the output of the
other checks.

Before this change:

    TEST_FORCE_VALIDATE=1 hack/validate/default
    Congratulations!  All commits are properly signed with the DCO!
    Congratulations! Seccomp profile generation is done correctly.
    INFO [config_reader] Used config file hack/validate/golangci-lint.yml
    INFO [lintersdb] Active 15 linters: [deadcode gofmt goimports golint gosec gosimple govet ineffassign misspell staticcheck structcheck typecheck unconvert unused varcheck]
    ...
    INFO Execution took 2m12.4287302s
    Congratulations!  "./pkg/..." is safely isolated from internal code.
    The swagger spec at "api/swagger.yaml" is valid against swagger specification 2.0
    Congratulations! All api changes are done the right way.
    Congratulations!  All toml source files changed here have valid syntax.
    Congratulations!  Changelog CHANGELOG.md is well-formed.
    Congratulations!  Changelog CHANGELOG.md dates are in descending order.

After this change:

    TEST_FORCE_VALIDATE=1 hack/validate/default
    Congratulations!  All commits are properly signed with the DCO!
    Congratulations!  Seccomp profile generation is done correctly.
    Congratulations!  Packages in "./pkg/..." are safely isolated from internal code.
    Congratulations!  The swagger spec at "api/swagger.yaml" is valid against swagger specification 2.0
    Congratulations!  All API changes are done the right way.
    Congratulations!  All TOML source files changed here have valid syntax.
    Congratulations!  Changelog CHANGELOG.md is well-formed.
    Congratulations!  Changelog CHANGELOG.md dates are in descending order.
    Congratulations!  No new tests were added to integration-cli.

    INFO Start validation with golang-ci-lint
    INFO [config_reader] Used config file hack/validate/golangci-lint.yml
    INFO [lintersdb] Active 15 linters: [deadcode gofmt goimports golint gosec gosimple govet ineffassign misspell staticcheck structcheck typecheck unconvert unused varcheck]
    ...
    INFO Execution took 2m12.4287302s

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn 5 роки тому
батько
коміт
1f0fdcc6f5

+ 1 - 1
hack/validate/default

@@ -6,7 +6,6 @@ export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
 
 . "${SCRIPTDIR}"/dco
 . "${SCRIPTDIR}"/default-seccomp
-. "${SCRIPTDIR}"/golangci-lint
 . "${SCRIPTDIR}"/pkg-imports
 . "${SCRIPTDIR}"/swagger
 . "${SCRIPTDIR}"/swagger-gen
@@ -14,3 +13,4 @@ export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
 . "${SCRIPTDIR}"/changelog-well-formed
 . "${SCRIPTDIR}"/changelog-date-descending
 . "${SCRIPTDIR}"/deprecate-integration-cli
+. "${SCRIPTDIR}"/golangci-lint

+ 1 - 1
hack/validate/default-seccomp

@@ -23,6 +23,6 @@ if [ -n "${TEST_FORCE_VALIDATE:-}" ] || [ ${#files[@]} -gt 0 ]; then
 		} >&2
 		false
 	else
-		echo 'Congratulations! Seccomp profile generation is done correctly.'
+		echo 'Congratulations!  Seccomp profile generation is done correctly.'
 	fi
 fi

+ 1 - 1
hack/validate/deprecate-integration-cli

@@ -21,5 +21,5 @@ if [ -n "$new_tests" ]; then
 	} >&2
 	false
 else
-	echo 'Congratulations!  No new tests added to integration-cli.'
+	echo 'Congratulations!  No new tests were added to integration-cli.'
 fi

+ 2 - 0
hack/validate/golangci-lint

@@ -17,6 +17,8 @@ elif ${PKG_CONFIG} 'libsystemd-journal' 2> /dev/null ; then
 	DOCKER_BUILDTAGS+=" journald journald_compat"
 fi
 
+echo -e "\n\033[0;36mINFO\033[0m Start validation with golang-ci-lint"
+
 # TODO use --out-format=junit-xml and store artifacts
 # shellcheck disable=SC2086
 GOGC=75 golangci-lint run \

+ 1 - 1
hack/validate/pkg-imports

@@ -20,7 +20,7 @@ for f in "${files[@]}"; do
 done
 
 if [ ${#badFiles[@]} -eq 0 ]; then
-	echo 'Congratulations!  "./pkg/..." is safely isolated from internal code.'
+	echo 'Congratulations!  Packages in "./pkg/..." are safely isolated from internal code.'
 else
 	{
 		echo 'These files import internal code: (either directly or indirectly)'

+ 6 - 1
hack/validate/swagger

@@ -9,5 +9,10 @@ unset IFS
 
 if [ -n "${TEST_FORCE_VALIDATE:-}" ] || [ ${#files[@]} -gt 0 ]; then
 	LANG=C.UTF-8 yamllint -c "${SCRIPTDIR}"/.swagger-yamllint api/swagger.yaml
-	swagger validate api/swagger.yaml
+	if out=$(swagger validate api/swagger.yaml); then
+		echo "Congratulations!  ${out}"
+	else
+		echo  "${out}" >&2
+		false
+	fi
 fi

+ 3 - 3
hack/validate/swagger-gen

@@ -17,12 +17,12 @@ if [ -n "${TEST_FORCE_VALIDATE:-}" ] || [ ${#files[@]} -gt 0 ]; then
 			echo
 			echo "$diffs"
 			echo
-			echo 'Please update api/swagger.yaml with any api changes, then '
-			echo 'run `hack/generate-swagger-api.sh`.'
+			echo 'Please update api/swagger.yaml with any API changes, then '
+			echo 'run hack/generate-swagger-api.sh.'
 		} >&2
 		false
 	else
-		echo 'Congratulations! All api changes are done the right way.'
+		echo 'Congratulations!  All API changes are done the right way.'
 	fi
 else
 	echo 'No api/types/ or api/swagger.yaml changes in diff.'

+ 4 - 4
hack/validate/toml

@@ -9,22 +9,22 @@ unset IFS
 
 badFiles=()
 for f in "${files[@]}"; do
-	# we use "git show" here to validate that what's committed has valid toml syntax
+	# we use "git show" here to validate that what's committed has valid TOML syntax
 	if ! git show "$VALIDATE_HEAD:$f" | tomlv /proc/self/fd/0 ; then
 		badFiles+=( "$f" )
 	fi
 done
 
 if [ ${#badFiles[@]} -eq 0 ]; then
-	echo 'Congratulations!  All toml source files changed here have valid syntax.'
+	echo 'Congratulations!  All TOML source files changed here have valid syntax.'
 else
 	{
-		echo "These files are not valid toml:"
+		echo "These files are not valid TOML:"
 		for f in "${badFiles[@]}"; do
 			echo " - $f"
 		done
 		echo
-		echo 'Please reformat the above files as valid toml'
+		echo 'Please reformat the above files as valid TOML'
 		echo
 	} >&2
 	false