From 1f0fdcc6f54d841cb76599bb7ce055555bb7f93c Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Fri, 11 Oct 2019 13:31:18 +0200 Subject: [PATCH] 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 --- hack/validate/default | 2 +- hack/validate/default-seccomp | 2 +- hack/validate/deprecate-integration-cli | 2 +- hack/validate/golangci-lint | 2 ++ hack/validate/pkg-imports | 2 +- hack/validate/swagger | 7 ++++++- hack/validate/swagger-gen | 6 +++--- hack/validate/toml | 8 ++++---- 8 files changed, 19 insertions(+), 12 deletions(-) diff --git a/hack/validate/default b/hack/validate/default index fe6d51be9a..16609d4e85 100755 --- a/hack/validate/default +++ b/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 diff --git a/hack/validate/default-seccomp b/hack/validate/default-seccomp index 32921ae268..10baf52c91 100755 --- a/hack/validate/default-seccomp +++ b/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 diff --git a/hack/validate/deprecate-integration-cli b/hack/validate/deprecate-integration-cli index 07a0628778..1260166b1f 100755 --- a/hack/validate/deprecate-integration-cli +++ b/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 diff --git a/hack/validate/golangci-lint b/hack/validate/golangci-lint index 02fcf50ff7..3c168757ff 100755 --- a/hack/validate/golangci-lint +++ b/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 \ diff --git a/hack/validate/pkg-imports b/hack/validate/pkg-imports index a9aab6456f..485032be38 100755 --- a/hack/validate/pkg-imports +++ b/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)' diff --git a/hack/validate/swagger b/hack/validate/swagger index 927fb0c00a..160a002a14 100755 --- a/hack/validate/swagger +++ b/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 diff --git a/hack/validate/swagger-gen b/hack/validate/swagger-gen index 118cff057e..fafa2c296b 100755 --- a/hack/validate/swagger-gen +++ b/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.' diff --git a/hack/validate/toml b/hack/validate/toml index d5b2ce1c29..2b7f4607b7 100755 --- a/hack/validate/toml +++ b/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