run-tests.sh 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/bin/sh
  2. # I don't even ..
  3. go env -w GOFLAGS="-buildvcs=false"
  4. # Install the tools we use to test our code-quality.
  5. #
  6. # Here we setup the tools to install only if the "CI" environmental variable
  7. # is not empty. This is because locally I have them installed.
  8. #
  9. # NOTE: Github Actions always set CI=true
  10. #
  11. if [ ! -z "${CI}" ] ; then
  12. go install golang.org/x/lint/golint@latest
  13. go install golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow@latest
  14. go install honnef.co/go/tools/cmd/staticcheck@latest
  15. fi
  16. # Run the static-check tool - we ignore errors in goserver/static.go
  17. t=$(mktemp)
  18. staticcheck -checks all ./... | grep -v "is deprecated"> $t
  19. if [ -s $t ]; then
  20. echo "Found errors via 'staticcheck'"
  21. cat $t
  22. rm $t
  23. exit 1
  24. fi
  25. rm $t
  26. # At this point failures cause aborts
  27. set -e
  28. # Run the linter
  29. echo "Launching linter .."
  30. golint -set_exit_status ./...
  31. echo "Completed linter .."
  32. # Run the shadow-checker
  33. echo "Launching shadowed-variable check .."
  34. go vet -vettool=$(which shadow) ./...
  35. echo "Completed shadowed-variable check .."
  36. # Run golang tests
  37. go test ./...