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.

123 lines
3.4 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. build-linux:
  35. name: Build
  36. runs-on: ubuntu-latest
  37. strategy:
  38. fail-fast: false
  39. matrix:
  40. goarch: ["arm", "amd64"]
  41. timeout-minutes: 5
  42. steps:
  43. - uses: actions/setup-go@v2
  44. with:
  45. go-version: "^1.15.4"
  46. - uses: actions/checkout@v2
  47. - uses: technote-space/get-diff-action@v4
  48. with:
  49. PATTERNS: |
  50. **/**.go
  51. go.mod
  52. go.sum
  53. - name: install
  54. run: GOOS=linux GOARCH=${{ matrix.goarch }} make build
  55. if: "env.GIT_DIFF != ''"
  56. tests:
  57. runs-on: ubuntu-latest
  58. needs: split-test-files
  59. strategy:
  60. fail-fast: false
  61. matrix:
  62. part: ["00", "01", "02", "03"]
  63. steps:
  64. - uses: actions/setup-go@v2
  65. with:
  66. go-version: "^1.15.4"
  67. - uses: actions/checkout@v2
  68. - uses: technote-space/get-diff-action@v4
  69. with:
  70. PATTERNS: |
  71. **/**.go
  72. go.mod
  73. go.sum
  74. - uses: actions/download-artifact@v2
  75. with:
  76. name: "${{ github.sha }}-${{ matrix.part }}"
  77. if: env.GIT_DIFF
  78. - name: test & coverage report creation
  79. run: |
  80. cat pkgs.txt.part.${{ matrix.part }} | xargs go test -mod=readonly -timeout 8m -race -coverprofile=${{ matrix.part }}profile.out -covermode=atomic
  81. if: env.GIT_DIFF
  82. - uses: actions/upload-artifact@v2
  83. with:
  84. name: "${{ github.sha }}-${{ matrix.part }}-coverage"
  85. path: ./${{ matrix.part }}profile.out
  86. upload-coverage-report:
  87. runs-on: ubuntu-latest
  88. needs: tests
  89. steps:
  90. - uses: actions/checkout@v2
  91. - uses: technote-space/get-diff-action@v4
  92. with:
  93. PATTERNS: |
  94. **/**.go
  95. go.mod
  96. go.sum
  97. - uses: actions/download-artifact@v2
  98. with:
  99. name: "${{ github.sha }}-00-coverage"
  100. if: env.GIT_DIFF
  101. - uses: actions/download-artifact@v2
  102. with:
  103. name: "${{ github.sha }}-01-coverage"
  104. if: env.GIT_DIFF
  105. - uses: actions/download-artifact@v2
  106. with:
  107. name: "${{ github.sha }}-02-coverage"
  108. if: env.GIT_DIFF
  109. - uses: actions/download-artifact@v2
  110. with:
  111. name: "${{ github.sha }}-03-coverage"
  112. if: env.GIT_DIFF
  113. - run: |
  114. cat ./*profile.out | grep -v "mode: atomic" >> coverage.txt
  115. if: env.GIT_DIFF
  116. - uses: codecov/codecov-action@v1.0.13
  117. with:
  118. file: ./coverage.txt
  119. if: env.GIT_DIFF