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.

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