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.

97 lines
2.7 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 -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. tests:
  35. runs-on: ubuntu-latest
  36. needs: split-test-files
  37. strategy:
  38. fail-fast: false
  39. matrix:
  40. part: ["00", "01", "02", "03"]
  41. steps:
  42. - uses: actions/checkout@v2
  43. - uses: technote-space/get-diff-action@v4
  44. with:
  45. PATTERNS: |
  46. **/**.go
  47. go.mod
  48. go.sum
  49. - uses: actions/download-artifact@v2
  50. with:
  51. name: "${{ github.sha }}-${{ matrix.part }}"
  52. if: env.GIT_DIFF
  53. - name: test & coverage report creation
  54. run: |
  55. cat pkgs.txt.part.${{ matrix.part }} | xargs go test -mod=readonly -timeout 8m -race -coverprofile=${{ matrix.part }}profile.out -covermode=atomic
  56. if: env.GIT_DIFF
  57. - uses: actions/upload-artifact@v2
  58. with:
  59. name: "${{ github.sha }}-${{ matrix.part }}-coverage"
  60. path: ./${{ matrix.part }}profile.out
  61. upload-coverage-report:
  62. runs-on: ubuntu-latest
  63. needs: tests
  64. steps:
  65. - uses: actions/checkout@v2
  66. - uses: technote-space/get-diff-action@v4
  67. with:
  68. PATTERNS: |
  69. **/**.go
  70. go.mod
  71. go.sum
  72. - uses: actions/download-artifact@v2
  73. with:
  74. name: "${{ github.sha }}-00-coverage"
  75. if: env.GIT_DIFF
  76. - uses: actions/download-artifact@v2
  77. with:
  78. name: "${{ github.sha }}-01-coverage"
  79. if: env.GIT_DIFF
  80. - uses: actions/download-artifact@v2
  81. with:
  82. name: "${{ github.sha }}-02-coverage"
  83. if: env.GIT_DIFF
  84. - uses: actions/download-artifact@v2
  85. with:
  86. name: "${{ github.sha }}-03-coverage"
  87. if: env.GIT_DIFF
  88. - run: |
  89. cat ./*profile.out | grep -v "mode: atomic" >> coverage.txt
  90. if: env.GIT_DIFF
  91. - uses: codecov/codecov-action@v1.0.14
  92. with:
  93. file: ./coverage.txt
  94. if: env.GIT_DIFF