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.

138 lines
4.0 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@v1
  40. with:
  41. SUFFIX_FILTER: |
  42. .go
  43. .mod
  44. .sum
  45. SET_ENV_NAME_INSERTIONS: 1
  46. SET_ENV_NAME_LINES: 1
  47. - uses: actions/download-artifact@v2
  48. with:
  49. name: "${{ github.sha }}-aa"
  50. if: "env.GIT_DIFF != ''"
  51. - name: test & coverage report creation
  52. run: |
  53. cat xaa.txt | xargs go test -mod=readonly -timeout 8m -race -coverprofile=coverage.txt -covermode=atomic
  54. if: "env.GIT_DIFF != ''"
  55. - uses: codecov/codecov-action@v1.0.7
  56. with:
  57. file: ./coverage.txt
  58. if: "env.GIT_DIFF != ''"
  59. test-coverage-part-2:
  60. runs-on: ubuntu-latest
  61. needs: split-test-files
  62. steps:
  63. - uses: actions/checkout@v2
  64. - uses: technote-space/get-diff-action@v1
  65. with:
  66. SUFFIX_FILTER: |
  67. .go
  68. .mod
  69. .sum
  70. SET_ENV_NAME_INSERTIONS: 1
  71. SET_ENV_NAME_LINES: 1
  72. - uses: actions/download-artifact@v2
  73. with:
  74. name: "${{ github.sha }}-ab"
  75. if: "env.GIT_DIFF != ''"
  76. - name: test & coverage report creation
  77. run: |
  78. cat xab.txt | xargs go test -mod=readonly -timeout 5m -race -coverprofile=coverage.txt -covermode=atomic
  79. if: "env.GIT_DIFF != ''"
  80. - uses: codecov/codecov-action@v1.0.7
  81. with:
  82. file: ./coverage.txt
  83. if: "env.GIT_DIFF != ''"
  84. test-coverage-part-3:
  85. runs-on: ubuntu-latest
  86. needs: split-test-files
  87. steps:
  88. - uses: actions/checkout@v2
  89. - uses: technote-space/get-diff-action@v1
  90. with:
  91. SUFFIX_FILTER: |
  92. .go
  93. .mod
  94. .sum
  95. SET_ENV_NAME_INSERTIONS: 1
  96. SET_ENV_NAME_LINES: 1
  97. - uses: actions/download-artifact@v2
  98. with:
  99. name: "${{ github.sha }}-ac"
  100. if: "env.GIT_DIFF != ''"
  101. - name: test & coverage report creation
  102. run: |
  103. cat xac.txt | xargs go test -mod=readonly -timeout 5m -race -coverprofile=coverage.txt -covermode=atomic
  104. if: "env.GIT_DIFF != ''"
  105. - uses: codecov/codecov-action@v1.0.7
  106. with:
  107. file: ./coverage.txt
  108. if: "env.GIT_DIFF != ''"
  109. test-coverage-part-4:
  110. runs-on: ubuntu-latest
  111. needs: split-test-files
  112. steps:
  113. - uses: actions/checkout@v2
  114. - uses: technote-space/get-diff-action@v1
  115. with:
  116. SUFFIX_FILTER: |
  117. .go
  118. .mod
  119. .sum
  120. SET_ENV_NAME_INSERTIONS: 1
  121. SET_ENV_NAME_LINES: 1
  122. - uses: actions/download-artifact@v2
  123. with:
  124. name: "${{ github.sha }}-ad"
  125. if: "env.GIT_DIFF != ''"
  126. - name: test & coverage report creation
  127. run: |
  128. cat xad.txt | xargs go test -mod=readonly -timeout 5m -race -coverprofile=coverage.txt -covermode=atomic
  129. if: "env.GIT_DIFF != ''"
  130. - uses: codecov/codecov-action@v1.0.7
  131. with:
  132. file: ./coverage.txt
  133. if: "env.GIT_DIFF != ''"