You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

127 lines
3.5 KiB

  1. name: Test Coverage
  2. on:
  3. pull_request:
  4. push:
  5. branches:
  6. - master
  7. - release/**
  8. jobs:
  9. split-test-files:
  10. runs-on: ubuntu-latest
  11. steps:
  12. - uses: actions/checkout@v2.3.4
  13. - name: Create a file with all the pkgs
  14. run: go list ./... > pkgs.txt
  15. - name: Split pkgs into 4 files
  16. run: split -d -n l/4 pkgs.txt pkgs.txt.part.
  17. # cache multiple
  18. - uses: actions/upload-artifact@v2
  19. with:
  20. name: "${{ github.sha }}-00"
  21. path: ./pkgs.txt.part.00
  22. - uses: actions/upload-artifact@v2
  23. with:
  24. name: "${{ github.sha }}-01"
  25. path: ./pkgs.txt.part.01
  26. - uses: actions/upload-artifact@v2
  27. with:
  28. name: "${{ github.sha }}-02"
  29. path: ./pkgs.txt.part.02
  30. - uses: actions/upload-artifact@v2
  31. with:
  32. name: "${{ github.sha }}-03"
  33. path: ./pkgs.txt.part.03
  34. build-linux:
  35. name: Build
  36. runs-on: ubuntu-latest
  37. strategy:
  38. fail-fast: false
  39. matrix:
  40. goarch: ["arm", "amd64"]
  41. timeout-minutes: 5
  42. steps:
  43. - uses: actions/setup-go@v2
  44. with:
  45. go-version: "1.16"
  46. - uses: actions/checkout@v2.3.4
  47. - uses: technote-space/get-diff-action@v4
  48. with:
  49. PATTERNS: |
  50. **/**.go
  51. go.mod
  52. go.sum
  53. - name: install
  54. run: GOOS=linux GOARCH=${{ matrix.goarch }} make build
  55. if: "env.GIT_DIFF != ''"
  56. tests:
  57. runs-on: ubuntu-latest
  58. needs: split-test-files
  59. strategy:
  60. fail-fast: false
  61. matrix:
  62. part: ["00", "01", "02", "03"]
  63. steps:
  64. - uses: actions/setup-go@v2
  65. with:
  66. go-version: "1.16"
  67. - uses: actions/checkout@v2.3.4
  68. - uses: technote-space/get-diff-action@v4
  69. with:
  70. PATTERNS: |
  71. **/**.go
  72. go.mod
  73. go.sum
  74. - uses: actions/download-artifact@v2
  75. with:
  76. name: "${{ github.sha }}-${{ matrix.part }}"
  77. if: env.GIT_DIFF
  78. - name: Set up Go
  79. uses: actions/setup-go@v2
  80. with:
  81. go-version: 1.16
  82. - name: test & coverage report creation
  83. run: |
  84. cat pkgs.txt.part.${{ matrix.part }} | xargs go test -mod=readonly -timeout 8m -race -coverprofile=${{ matrix.part }}profile.out -covermode=atomic
  85. if: env.GIT_DIFF
  86. - uses: actions/upload-artifact@v2
  87. with:
  88. name: "${{ github.sha }}-${{ matrix.part }}-coverage"
  89. path: ./${{ matrix.part }}profile.out
  90. upload-coverage-report:
  91. runs-on: ubuntu-latest
  92. needs: tests
  93. steps:
  94. - uses: actions/checkout@v2.3.4
  95. - uses: technote-space/get-diff-action@v4
  96. with:
  97. PATTERNS: |
  98. **/**.go
  99. go.mod
  100. go.sum
  101. - uses: actions/download-artifact@v2
  102. with:
  103. name: "${{ github.sha }}-00-coverage"
  104. if: env.GIT_DIFF
  105. - uses: actions/download-artifact@v2
  106. with:
  107. name: "${{ github.sha }}-01-coverage"
  108. if: env.GIT_DIFF
  109. - uses: actions/download-artifact@v2
  110. with:
  111. name: "${{ github.sha }}-02-coverage"
  112. if: env.GIT_DIFF
  113. - uses: actions/download-artifact@v2
  114. with:
  115. name: "${{ github.sha }}-03-coverage"
  116. if: env.GIT_DIFF
  117. - run: |
  118. cat ./*profile.out | grep -v "mode: atomic" >> coverage.txt
  119. if: env.GIT_DIFF
  120. - uses: codecov/codecov-action@v1.5.2
  121. with:
  122. file: ./coverage.txt
  123. if: env.GIT_DIFF