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.

133 lines
3.6 KiB

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