github.com/Finschia/ostracon@v1.1.5/.github/workflows/coverage.yml (about)

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