github.com/Oyster-zx/tendermint@v0.34.24-fork/.github/workflows/coverage.yml (about)

     1  name: Test Coverage
     2  on:
     3    pull_request:
     4    push:
     5      branches:
     6        - master
     7        - release/**
     8  
     9  jobs:
    10    split-test-files:
    11      runs-on: ubuntu-latest
    12      steps:
    13        - uses: actions/checkout@v3
    14        - name: Create a file with all the pkgs
    15          run: go list ./... > pkgs.txt
    16        - name: Split pkgs into 4 files
    17          run: split -d -n l/4 pkgs.txt pkgs.txt.part.
    18        # cache multiple
    19        - uses: actions/upload-artifact@v3
    20          with:
    21            name: "${{ github.sha }}-00"
    22            path: ./pkgs.txt.part.00
    23        - uses: actions/upload-artifact@v3
    24          with:
    25            name: "${{ github.sha }}-01"
    26            path: ./pkgs.txt.part.01
    27        - uses: actions/upload-artifact@v3
    28          with:
    29            name: "${{ github.sha }}-02"
    30            path: ./pkgs.txt.part.02
    31        - uses: actions/upload-artifact@v3
    32          with:
    33            name: "${{ github.sha }}-03"
    34            path: ./pkgs.txt.part.03
    35  
    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@v3
    46          with:
    47            go-version: "1.18"
    48        - uses: actions/checkout@v3
    49        - uses: technote-space/get-diff-action@v6
    50          with:
    51            PATTERNS: |
    52              **/**.go
    53              go.mod
    54              go.sum
    55        - name: install
    56          run: GOOS=linux GOARCH=${{ matrix.goarch }} make build
    57          if: "env.GIT_DIFF != ''"
    58  
    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@v3
    68          with:
    69            go-version: "1.18"
    70        - uses: actions/checkout@v3
    71        - uses: technote-space/get-diff-action@v6
    72          with:
    73            PATTERNS: |
    74              **/**.go
    75              go.mod
    76              go.sum
    77        - uses: actions/download-artifact@v3
    78          with:
    79            name: "${{ github.sha }}-${{ matrix.part }}"
    80          if: env.GIT_DIFF
    81        - name: test & coverage report creation
    82          run: |
    83            cat pkgs.txt.part.${{ matrix.part }} | xargs go test -mod=readonly -timeout 8m -race -coverprofile=${{ matrix.part }}profile.out -covermode=atomic
    84          if: env.GIT_DIFF
    85        - uses: actions/upload-artifact@v3
    86          with:
    87            name: "${{ github.sha }}-${{ matrix.part }}-coverage"
    88            path: ./${{ matrix.part }}profile.out
    89  
    90    upload-coverage-report:
    91      runs-on: ubuntu-latest
    92      needs: tests
    93      steps:
    94        - uses: actions/checkout@v3
    95        - uses: technote-space/get-diff-action@v6
    96          with:
    97            PATTERNS: |
    98              **/**.go
    99              go.mod
   100              go.sum
   101        - uses: actions/download-artifact@v3
   102          with:
   103            name: "${{ github.sha }}-00-coverage"
   104          if: env.GIT_DIFF
   105        - uses: actions/download-artifact@v3
   106          with:
   107            name: "${{ github.sha }}-01-coverage"
   108          if: env.GIT_DIFF
   109        - uses: actions/download-artifact@v3
   110          with:
   111            name: "${{ github.sha }}-02-coverage"
   112          if: env.GIT_DIFF
   113        - uses: actions/download-artifact@v3
   114          with:
   115            name: "${{ github.sha }}-03-coverage"
   116          if: env.GIT_DIFF
   117        - run: |
   118            cat ./*profile.out | grep -v "mode: atomic" >> coverage.txt
   119          if: env.GIT_DIFF
   120        - uses: codecov/codecov-action@v3
   121          with:
   122            file: ./coverage.txt
   123          if: env.GIT_DIFF