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.

130 lines
3.6 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
  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 -n l/4 --additional-suffix=.txt ./pkgs.txt
  17. # cache multiple
  18. - uses: actions/upload-artifact@v2
  19. with:
  20. name: "${{ github.sha }}-aa"
  21. path: ./xaa.txt
  22. - uses: actions/upload-artifact@v2
  23. with:
  24. name: "${{ github.sha }}-ab"
  25. path: ./xab.txt
  26. - uses: actions/upload-artifact@v2
  27. with:
  28. name: "${{ github.sha }}-ac"
  29. path: ./xac.txt
  30. - uses: actions/upload-artifact@v2
  31. with:
  32. name: "${{ github.sha }}-ad"
  33. path: ./xad.txt
  34. test-coverage-part-1:
  35. runs-on: ubuntu-latest
  36. needs: split-test-files
  37. steps:
  38. - uses: actions/checkout@v2
  39. - uses: technote-space/get-diff-action@v4
  40. with:
  41. PATTERNS: |
  42. **/**.go
  43. go.mod
  44. go.sum
  45. - uses: actions/download-artifact@v2
  46. with:
  47. name: "${{ github.sha }}-aa"
  48. if: env.GIT_DIFF
  49. - name: test & coverage report creation
  50. run: |
  51. cat xaa.txt | xargs go test -mod=readonly -timeout 8m -race -coverprofile=coverage.txt -covermode=atomic
  52. if: env.GIT_DIFF
  53. - uses: codecov/codecov-action@v1.0.13
  54. with:
  55. file: ./coverage.txt
  56. if: env.GIT_DIFF
  57. test-coverage-part-2:
  58. runs-on: ubuntu-latest
  59. needs: split-test-files
  60. steps:
  61. - uses: actions/checkout@v2
  62. - uses: technote-space/get-diff-action@v4
  63. with:
  64. PATTERNS: |
  65. **/**.go
  66. go.mod
  67. go.sum
  68. - uses: actions/download-artifact@v2
  69. with:
  70. name: "${{ github.sha }}-ab"
  71. if: env.GIT_DIFF
  72. - name: test & coverage report creation
  73. run: |
  74. cat xab.txt | xargs go test -mod=readonly -timeout 5m -race -coverprofile=coverage.txt -covermode=atomic
  75. if: env.GIT_DIFF
  76. - uses: codecov/codecov-action@v1.0.13
  77. with:
  78. file: ./coverage.txt
  79. if: env.GIT_DIFF
  80. test-coverage-part-3:
  81. runs-on: ubuntu-latest
  82. needs: split-test-files
  83. steps:
  84. - uses: actions/checkout@v2
  85. - uses: technote-space/get-diff-action@v4
  86. with:
  87. PATTERNS: |
  88. **/**.go
  89. go.mod
  90. go.sum
  91. - uses: actions/download-artifact@v2
  92. with:
  93. name: "${{ github.sha }}-ac"
  94. if: env.GIT_DIFF
  95. - name: test & coverage report creation
  96. run: |
  97. cat xac.txt | xargs go test -mod=readonly -timeout 10m -race -coverprofile=coverage.txt -covermode=atomic
  98. if: env.GIT_DIFF
  99. - uses: codecov/codecov-action@v1.0.13
  100. with:
  101. file: ./coverage.txt
  102. if: env.GIT_DIFF
  103. test-coverage-part-4:
  104. runs-on: ubuntu-latest
  105. needs: split-test-files
  106. steps:
  107. - uses: actions/checkout@v2
  108. - uses: technote-space/get-diff-action@v4
  109. with:
  110. PATTERNS: |
  111. **/**.go
  112. go.mod
  113. go.sum
  114. - uses: actions/download-artifact@v2
  115. with:
  116. name: "${{ github.sha }}-ad"
  117. if: env.GIT_DIFF
  118. - name: test & coverage report creation
  119. run: |
  120. cat xad.txt | xargs go test -mod=readonly -timeout 5m -race -coverprofile=coverage.txt -covermode=atomic
  121. if: env.GIT_DIFF
  122. - uses: codecov/codecov-action@v1.0.13
  123. with:
  124. file: ./coverage.txt
  125. if: env.GIT_DIFF