static-analysis.yml 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. name: static-analysis
  2. on:
  3. push:
  4. branches:
  5. - main
  6. pull_request:
  7. branches:
  8. - '*'
  9. - 'release-branch/*'
  10. concurrency:
  11. group: ${{ github.workflow }}-$${{ github.head_ref || github.run_id }}
  12. cancel-in-progress: true
  13. jobs:
  14. gofmt:
  15. runs-on: ubuntu-latest
  16. steps:
  17. - name: Check out code
  18. uses: actions/checkout@v3
  19. - name: Set up Go
  20. uses: actions/setup-go@v3
  21. with:
  22. go-version-file: go.mod
  23. - name: Run gofmt (goimports)
  24. run: go run golang.org/x/tools/cmd/goimports -d --format-only .
  25. - uses: k0kubun/[email protected]
  26. with:
  27. payload: |
  28. {
  29. "attachments": [{
  30. "text": "${{ job.status }}: ${{ github.workflow }} <https://github.com/${{ github.repository }}/commit/${{ github.sha }}/checks|${{ env.COMMIT_DATE }} #${{ env.COMMIT_NUMBER_OF_DAY }}> " +
  31. "(<https://github.com/${{ github.repository }}/commit/${{ github.sha }}|" + "${{ github.sha }}".substring(0, 10) + ">) " +
  32. "of ${{ github.repository }}@" + "${{ github.ref }}".split('/').reverse()[0] + " by ${{ github.event.head_commit.committer.name }}",
  33. "color": "danger"
  34. }]
  35. }
  36. env:
  37. SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
  38. if: failure() && github.event_name == 'push'
  39. vet:
  40. runs-on: ubuntu-latest
  41. steps:
  42. - name: Set up Go
  43. uses: actions/setup-go@v3
  44. with:
  45. go-version: 1.19
  46. - name: Check out code
  47. uses: actions/checkout@v3
  48. - name: Run go vet
  49. run: go vet ./...
  50. - uses: k0kubun/[email protected]
  51. with:
  52. payload: |
  53. {
  54. "attachments": [{
  55. "text": "${{ job.status }}: ${{ github.workflow }} <https://github.com/${{ github.repository }}/commit/${{ github.sha }}/checks|${{ env.COMMIT_DATE }} #${{ env.COMMIT_NUMBER_OF_DAY }}> " +
  56. "(<https://github.com/${{ github.repository }}/commit/${{ github.sha }}|" + "${{ github.sha }}".substring(0, 10) + ">) " +
  57. "of ${{ github.repository }}@" + "${{ github.ref }}".split('/').reverse()[0] + " by ${{ github.event.head_commit.committer.name }}",
  58. "color": "danger"
  59. }]
  60. }
  61. env:
  62. SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
  63. if: failure() && github.event_name == 'push'
  64. staticcheck:
  65. runs-on: ubuntu-latest
  66. strategy:
  67. matrix:
  68. goos: [linux, windows, darwin]
  69. goarch: [amd64]
  70. include:
  71. - goos: windows
  72. goarch: 386
  73. steps:
  74. - name: Set up Go
  75. uses: actions/setup-go@v3
  76. with:
  77. go-version: 1.19
  78. - name: Check out code
  79. uses: actions/checkout@v3
  80. - name: Install staticcheck
  81. run: "GOBIN=~/.local/bin go install honnef.co/go/tools/cmd/staticcheck"
  82. - name: Print staticcheck version
  83. run: "staticcheck -version"
  84. - name: "Run staticcheck (${{ matrix.goos }}/${{ matrix.goarch }})"
  85. env:
  86. GOOS: ${{ matrix.goos }}
  87. GOARCH: ${{ matrix.goarch }}
  88. run: "staticcheck -- $(go list ./... | grep -v tempfork)"
  89. - uses: k0kubun/[email protected]
  90. with:
  91. payload: |
  92. {
  93. "attachments": [{
  94. "text": "${{ job.status }}: ${{ github.workflow }} <https://github.com/${{ github.repository }}/commit/${{ github.sha }}/checks|${{ env.COMMIT_DATE }} #${{ env.COMMIT_NUMBER_OF_DAY }}> " +
  95. "(<https://github.com/${{ github.repository }}/commit/${{ github.sha }}|" + "${{ github.sha }}".substring(0, 10) + ">) " +
  96. "of ${{ github.repository }}@" + "${{ github.ref }}".split('/').reverse()[0] + " by ${{ github.event.head_commit.committer.name }}",
  97. "color": "danger"
  98. }]
  99. }
  100. env:
  101. SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
  102. if: failure() && github.event_name == 'push'