go.yml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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
  40. shell: bash
  41. run: |
  42. go mod tidy
  43. STATUS=$(git status --porcelain)
  44. if [ ! -z "$STATUS" ]; then
  45. echo "Unstaged files:"
  46. echo $STATUS
  47. echo "Run 'go mod tidy' and commit them"
  48. exit 1
  49. fi
  50. test:
  51. name: Test
  52. strategy:
  53. matrix:
  54. go-version: [ 1.14.x, 1.15.x, 1.16.x, 1.17.x, 1.18.x ]
  55. platform: [ ubuntu-latest, macos-latest ]
  56. runs-on: ${{ matrix.platform }}
  57. steps:
  58. - name: Install Go
  59. uses: actions/setup-go@v2
  60. with:
  61. go-version: ${{ matrix.go-version }}
  62. - name: Checkout code
  63. uses: actions/checkout@v2
  64. - name: Run tests with coverage
  65. run: go test -v -race -coverprofile=coverage -covermode=atomic ./...
  66. - name: Upload coverage report to Codecov
  67. uses: codecov/codecov-action@v1.5.0
  68. with:
  69. file: ./coverage
  70. flags: unittests
  71. - name: Send email on failure
  72. uses: dawidd6/action-send-mail@v3
  73. if: ${{ failure() && github.event_name == 'push' && github.ref == 'refs/heads/main' }}
  74. with:
  75. server_address: smtp.mailgun.org
  76. server_port: 465
  77. username: ${{ secrets.SMTP_USERNAME }}
  78. password: ${{ secrets.SMTP_PASSWORD }}
  79. subject: GitHub Actions (${{ github.repository }}) job result
  80. to: github-actions-8ce6454@unknwon.io
  81. from: GitHub Actions (${{ github.repository }})
  82. reply_to: noreply@unknwon.io
  83. body: |
  84. The job "${{ github.job }}" of ${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }} completed with "${{ job.status }}".
  85. View the job run at: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
  86. # Running tests with race detection consumes too much memory on Windows,
  87. # see https://github.com/golang/go/issues/46099 for details.
  88. test-windows:
  89. name: Test
  90. strategy:
  91. matrix:
  92. go-version: [ 1.14.x, 1.15.x, 1.16.x, 1.17.x, 1.18.x ]
  93. platform: [ windows-latest ]
  94. runs-on: ${{ matrix.platform }}
  95. steps:
  96. - name: Install Go
  97. uses: actions/setup-go@v2
  98. with:
  99. go-version: ${{ matrix.go-version }}
  100. - name: Checkout code
  101. uses: actions/checkout@v2
  102. - name: Run tests with coverage
  103. run: go test -v -coverprofile=coverage -covermode=atomic ./...
  104. - name: Upload coverage report to Codecov
  105. uses: codecov/codecov-action@v1.5.0
  106. with:
  107. file: ./coverage
  108. flags: unittests
  109. - name: Send email on failure
  110. uses: dawidd6/action-send-mail@v3
  111. if: ${{ failure() && github.event_name == 'push' && github.ref == 'refs/heads/main' }}
  112. with:
  113. server_address: smtp.mailgun.org
  114. server_port: 465
  115. username: ${{ secrets.SMTP_USERNAME }}
  116. password: ${{ secrets.SMTP_PASSWORD }}
  117. subject: GitHub Actions (${{ github.repository }}) job result
  118. to: github-actions-8ce6454@unknwon.io
  119. from: GitHub Actions (${{ github.repository }})
  120. reply_to: noreply@unknwon.io
  121. body: |
  122. The job "${{ github.job }}" of ${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }} completed with "${{ job.status }}".
  123. View the job run at: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}