github.com/ipld/go-ipld-prime@v0.21.0/.github/workflows/go-test.yml (about)

     1  # File managed by web3-bot. DO NOT EDIT.
     2  # See https://github.com/protocol/.github/ for details.
     3  
     4  on: [push, pull_request]
     5  name: Go Test
     6  
     7  jobs:
     8    unit:
     9      strategy:
    10        fail-fast: false
    11        matrix:
    12          os: [ "ubuntu", "windows", "macos" ]
    13          go: ["1.19.x","1.20.x"]
    14      env:
    15        COVERAGES: ""
    16      runs-on: ${{ fromJSON(vars[format('UCI_GO_TEST_RUNNER_{0}', matrix.os)] || format('"{0}-latest"', matrix.os)) }}
    17      name: ${{ matrix.os }} (go ${{ matrix.go }})
    18      steps:
    19        - uses: actions/checkout@v3
    20          with:
    21            submodules: recursive
    22        - id: config
    23          uses: protocol/.github/.github/actions/read-config@master
    24        - uses: actions/setup-go@v3
    25          with:
    26            go-version: ${{ matrix.go }}
    27        - name: Go information
    28          run: |
    29            go version
    30            go env
    31        - name: Use msys2 on windows
    32          if: matrix.os == 'windows'
    33          shell: bash
    34          # The executable for msys2 is also called bash.cmd
    35          #   https://github.com/actions/virtual-environments/blob/main/images/win/Windows2019-Readme.md#shells
    36          # If we prepend its location to the PATH
    37          #   subsequent 'shell: bash' steps will use msys2 instead of gitbash
    38          run: echo "C:/msys64/usr/bin" >> $GITHUB_PATH
    39        - name: Run repo-specific setup
    40          uses: ./.github/actions/go-test-setup
    41          if: hashFiles('./.github/actions/go-test-setup') != ''
    42        - name: Run tests
    43          if: contains(fromJSON(steps.config.outputs.json).skipOSes, matrix.os) == false
    44          uses: protocol/multiple-go-modules@v1.2
    45          with:
    46            # Use -coverpkg=./..., so that we include cross-package coverage.
    47            # If package ./A imports ./B, and ./A's tests also cover ./B,
    48            # this means ./B's coverage will be significantly higher than 0%.
    49            run: go test -v -shuffle=on -coverprofile=module-coverage.txt -coverpkg=./... ./...
    50        - name: Run tests (32 bit)
    51          # can't run 32 bit tests on OSX.
    52          if: matrix.os != 'macos' &&
    53            fromJSON(steps.config.outputs.json).skip32bit != true &&
    54            contains(fromJSON(steps.config.outputs.json).skipOSes, matrix.os) == false
    55          uses: protocol/multiple-go-modules@v1.2
    56          env:
    57            GOARCH: 386
    58          with:
    59            run: |
    60              export "PATH=$PATH_386:$PATH"
    61              go test -v -shuffle=on ./...
    62        - name: Run tests with race detector
    63          # speed things up. Windows and OSX VMs are slow
    64          if: matrix.os == 'ubuntu' &&
    65            contains(fromJSON(steps.config.outputs.json).skipOSes, matrix.os) == false
    66          uses: protocol/multiple-go-modules@v1.2
    67          with:
    68            run: go test -v -race ./...
    69        - name: Collect coverage files
    70          shell: bash
    71          run: echo "COVERAGES=$(find . -type f -name 'module-coverage.txt' | tr -s '\n' ',' | sed 's/,$//')" >> $GITHUB_ENV
    72        - name: Upload coverage to Codecov
    73          uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1
    74          with:
    75            files: '${{ env.COVERAGES }}'
    76            env_vars: OS=${{ matrix.os }}, GO=${{ matrix.go }}