Browse code

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 authored on 2019/10/11 20:31:18
Showing 8 changed files
... ...
@@ -6,7 +6,6 @@ export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
6 6
 
7 7
 . "${SCRIPTDIR}"/dco
8 8
 . "${SCRIPTDIR}"/default-seccomp
9
-. "${SCRIPTDIR}"/golangci-lint
10 9
 . "${SCRIPTDIR}"/pkg-imports
11 10
 . "${SCRIPTDIR}"/swagger
12 11
 . "${SCRIPTDIR}"/swagger-gen
... ...
@@ -14,3 +13,4 @@ export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
14 14
 . "${SCRIPTDIR}"/changelog-well-formed
15 15
 . "${SCRIPTDIR}"/changelog-date-descending
16 16
 . "${SCRIPTDIR}"/deprecate-integration-cli
17
+. "${SCRIPTDIR}"/golangci-lint
... ...
@@ -23,6 +23,6 @@ if [ -n "${TEST_FORCE_VALIDATE:-}" ] || [ ${#files[@]} -gt 0 ]; then
23 23
 		} >&2
24 24
 		false
25 25
 	else
26
-		echo 'Congratulations! Seccomp profile generation is done correctly.'
26
+		echo 'Congratulations!  Seccomp profile generation is done correctly.'
27 27
 	fi
28 28
 fi
... ...
@@ -21,5 +21,5 @@ if [ -n "$new_tests" ]; then
21 21
 	} >&2
22 22
 	false
23 23
 else
24
-	echo 'Congratulations!  No new tests added to integration-cli.'
24
+	echo 'Congratulations!  No new tests were added to integration-cli.'
25 25
 fi
... ...
@@ -17,6 +17,8 @@ elif ${PKG_CONFIG} 'libsystemd-journal' 2> /dev/null ; then
17 17
 	DOCKER_BUILDTAGS+=" journald journald_compat"
18 18
 fi
19 19
 
20
+echo -e "\n\033[0;36mINFO\033[0m Start validation with golang-ci-lint"
21
+
20 22
 # TODO use --out-format=junit-xml and store artifacts
21 23
 # shellcheck disable=SC2086
22 24
 GOGC=75 golangci-lint run \
... ...
@@ -20,7 +20,7 @@ for f in "${files[@]}"; do
20 20
 done
21 21
 
22 22
 if [ ${#badFiles[@]} -eq 0 ]; then
23
-	echo 'Congratulations!  "./pkg/..." is safely isolated from internal code.'
23
+	echo 'Congratulations!  Packages in "./pkg/..." are safely isolated from internal code.'
24 24
 else
25 25
 	{
26 26
 		echo 'These files import internal code: (either directly or indirectly)'
... ...
@@ -9,5 +9,10 @@ unset IFS
9 9
 
10 10
 if [ -n "${TEST_FORCE_VALIDATE:-}" ] || [ ${#files[@]} -gt 0 ]; then
11 11
 	LANG=C.UTF-8 yamllint -c "${SCRIPTDIR}"/.swagger-yamllint api/swagger.yaml
12
-	swagger validate api/swagger.yaml
12
+	if out=$(swagger validate api/swagger.yaml); then
13
+		echo "Congratulations!  ${out}"
14
+	else
15
+		echo  "${out}" >&2
16
+		false
17
+	fi
13 18
 fi
... ...
@@ -17,12 +17,12 @@ if [ -n "${TEST_FORCE_VALIDATE:-}" ] || [ ${#files[@]} -gt 0 ]; then
17 17
 			echo
18 18
 			echo "$diffs"
19 19
 			echo
20
-			echo 'Please update api/swagger.yaml with any api changes, then '
21
-			echo 'run `hack/generate-swagger-api.sh`.'
20
+			echo 'Please update api/swagger.yaml with any API changes, then '
21
+			echo 'run hack/generate-swagger-api.sh.'
22 22
 		} >&2
23 23
 		false
24 24
 	else
25
-		echo 'Congratulations! All api changes are done the right way.'
25
+		echo 'Congratulations!  All API changes are done the right way.'
26 26
 	fi
27 27
 else
28 28
 	echo 'No api/types/ or api/swagger.yaml changes in diff.'
... ...
@@ -9,22 +9,22 @@ unset IFS
9 9
 
10 10
 badFiles=()
11 11
 for f in "${files[@]}"; do
12
-	# we use "git show" here to validate that what's committed has valid toml syntax
12
+	# we use "git show" here to validate that what's committed has valid TOML syntax
13 13
 	if ! git show "$VALIDATE_HEAD:$f" | tomlv /proc/self/fd/0 ; then
14 14
 		badFiles+=( "$f" )
15 15
 	fi
16 16
 done
17 17
 
18 18
 if [ ${#badFiles[@]} -eq 0 ]; then
19
-	echo 'Congratulations!  All toml source files changed here have valid syntax.'
19
+	echo 'Congratulations!  All TOML source files changed here have valid syntax.'
20 20
 else
21 21
 	{
22
-		echo "These files are not valid toml:"
22
+		echo "These files are not valid TOML:"
23 23
 		for f in "${badFiles[@]}"; do
24 24
 			echo " - $f"
25 25
 		done
26 26
 		echo
27
-		echo 'Please reformat the above files as valid toml'
27
+		echo 'Please reformat the above files as valid TOML'
28 28
 		echo
29 29
 	} >&2
30 30
 	false