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.

132 lines
3.5 KiB

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