go.yml 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. name: Go
  2. on:
  3. push:
  4. branches:
  5. - main
  6. - 'release/**'
  7. paths:
  8. - '**.go'
  9. - 'go.mod'
  10. - '.golangci.yml'
  11. - '.github/workflows/go.yml'
  12. pull_request:
  13. paths:
  14. - '**.go'
  15. - 'go.mod'
  16. - '.golangci.yml'
  17. - '.github/workflows/go.yml'
  18. env:
  19. GOPROXY: "https://proxy.golang.org"
  20. jobs:
  21. lint:
  22. name: Lint
  23. runs-on: ubuntu-latest
  24. steps:
  25. - name: Checkout code
  26. uses: actions/checkout@v2
  27. - name: Run golangci-lint
  28. uses: golangci/golangci-lint-action@v2
  29. with:
  30. version: latest
  31. args: --timeout=30m
  32. - name: Install Task
  33. uses: arduino/setup-task@v1
  34. - name: Install go-bindata
  35. shell: bash
  36. run: |
  37. curl --silent --location --output /usr/local/bin/go-bindata https://github.com/kevinburke/go-bindata/releases/download/v3.23.0/go-bindata-linux-amd64
  38. chmod +x /usr/local/bin/go-bindata
  39. - name: Check Go module tidiness and generated files
  40. shell: bash
  41. run: |
  42. go mod tidy
  43. task generate
  44. STATUS=$(git status --porcelain)
  45. if [ ! -z "$STATUS" ]; then
  46. echo "Unstaged files:"
  47. echo $STATUS
  48. echo "Run 'go mod tidy' or 'task generate' and commit them"
  49. exit 1
  50. fi
  51. test:
  52. name: Test
  53. strategy:
  54. matrix:
  55. go-version: [ 1.15.x, 1.16.x, 1.17.x ]
  56. platform: [ ubuntu-latest, macos-latest, windows-latest ]
  57. runs-on: ${{ matrix.platform }}
  58. steps:
  59. - name: Install Go
  60. uses: actions/setup-go@v2
  61. with:
  62. go-version: ${{ matrix.go-version }}
  63. - name: Checkout code
  64. uses: actions/checkout@v2
  65. - name: Run tests with coverage
  66. run: go test -v -race -coverprofile=coverage -covermode=atomic ./...
  67. - name: Upload coverage report to Codecov
  68. uses: codecov/codecov-action@v1.5.0
  69. with:
  70. file: ./coverage
  71. flags: unittests
  72. - name: Send email on failure
  73. uses: dawidd6/action-send-mail@v3
  74. if: ${{ failure() && github.event_name == 'push' && github.ref == 'refs/heads/main' }}
  75. with:
  76. server_address: smtp.mailgun.org
  77. server_port: 465
  78. username: ${{ secrets.SMTP_USERNAME }}
  79. password: ${{ secrets.SMTP_PASSWORD }}
  80. subject: GitHub Actions (${{ github.repository }}) job result
  81. to: github-actions-8ce6454@unknwon.io
  82. from: GitHub Actions (${{ github.repository }})
  83. reply_to: noreply@unknwon.io
  84. body: |
  85. The job "${{ github.job }}" of ${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }} completed with "${{ job.status }}".
  86. View the job run at: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}