go.yml 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. test:
  33. name: Test
  34. strategy:
  35. matrix:
  36. go-version: [ 1.15.x, 1.16.x, 1.17.x ]
  37. platform: [ ubuntu-latest, macos-latest, windows-latest ]
  38. runs-on: ${{ matrix.platform }}
  39. steps:
  40. - name: Install Go
  41. uses: actions/setup-go@v2
  42. with:
  43. go-version: ${{ matrix.go-version }}
  44. - name: Checkout code
  45. uses: actions/checkout@v2
  46. - name: Run tests with coverage
  47. run: go test -v -race -coverprofile=coverage -covermode=atomic ./...
  48. - name: Upload coverage report to Codecov
  49. uses: codecov/[email protected]
  50. with:
  51. file: ./coverage
  52. flags: unittests
  53. - name: Send email on failure
  54. uses: dawidd6/action-send-mail@v3
  55. if: ${{ failure() && github.event_name == 'push' && github.ref == 'refs/heads/main' }}
  56. with:
  57. server_address: smtp.mailgun.org
  58. server_port: 465
  59. username: ${{ secrets.SMTP_USERNAME }}
  60. password: ${{ secrets.SMTP_PASSWORD }}
  61. subject: GitHub Actions (${{ github.repository }}) job result
  62. to: [email protected]
  63. from: GitHub Actions (${{ github.repository }})
  64. reply_to: [email protected]
  65. body: |
  66. The job "${{ github.job }}" of ${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }} completed with "${{ job.status }}".
  67. View the job run at: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}