linter.yml 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. name: Lint
  2. on:
  3. push:
  4. branches: [master]
  5. pull_request:
  6. branches: [master]
  7. types: [opened, synchronize, reopened]
  8. jobs:
  9. lint:
  10. runs-on: ubuntu-latest
  11. steps:
  12. - name: Set up Go 1.x
  13. uses: actions/setup-go@v2
  14. with:
  15. go-version: ^1.14
  16. - name: Checkout codebase
  17. uses: actions/checkout@v2
  18. - name: Cache go module
  19. uses: actions/cache@v2
  20. with:
  21. path: ~/go/pkg/mod
  22. key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
  23. restore-keys: ${{ runner.os }}-go-
  24. - name: Show if need to format code
  25. if: ${{ always() }}
  26. run: |
  27. filesNeedToFormat=$(go fmt ./...)
  28. if [[ $filesNeedToFormat ]]; then
  29. echo -e "\033[0;36m[Error] The following Go files need to be formatted:\033[0m"
  30. echo -e "\033[0;31m$filesNeedToFormat\033[0m"
  31. exit 1
  32. fi
  33. - name: Lint *.go files
  34. if: ${{ always() }}
  35. run: |
  36. go vet $(go list ./... | grep -v /external/)
  37. if [[ $? != 0 ]]; then
  38. exit 1
  39. fi
  40. - name: Lint other files
  41. if: ${{ always() }}
  42. uses: github/super-linter@v3.9.3
  43. env:
  44. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  45. VALIDATE_ALL_CODEBASE: false
  46. VALIDATE_BASH: false
  47. VALIDATE_DOCKERFILE: false
  48. VALIDATE_DOCKERFILE_HADOLINT: false
  49. VALIDATE_GO: false
  50. VALIDATE_JSON: false
  51. VALIDATE_MD: false
  52. VALIDATE_PROTOBUF: false