go-test.yml 2.55 KB
Newer Older
web3-bot's avatar
web3-bot committed
1 2 3 4
# File managed by web3-bot. DO NOT EDIT.
# See https://github.com/protocol/.github/ for details.

on: [push, pull_request]
web3-bot's avatar
web3-bot committed
5
name: Go Test
web3-bot's avatar
web3-bot committed
6 7 8 9 10 11 12

jobs:
  unit:
    strategy:
      fail-fast: false
      matrix:
        os: [ "ubuntu", "windows", "macos" ]
web3-bot's avatar
web3-bot committed
13
        go: [ "1.17.x", "1.18.x" ]
web3-bot's avatar
web3-bot committed
14 15
    env:
      COVERAGES: ""
web3-bot's avatar
web3-bot committed
16 17
    runs-on: ${{ format('{0}-latest', matrix.os) }}
    name: ${{ matrix.os }} (go ${{ matrix.go }})
web3-bot's avatar
web3-bot committed
18 19
    steps:
      - uses: actions/checkout@v2
web3-bot's avatar
web3-bot committed
20 21
        with:
          submodules: recursive
web3-bot's avatar
web3-bot committed
22 23 24 25 26 27 28
      - uses: actions/setup-go@v2
        with:
          go-version: ${{ matrix.go }}
      - name: Go information
        run: |
          go version
          go env
web3-bot's avatar
web3-bot committed
29 30 31 32 33 34 35 36
      - name: Use msys2 on windows
        if: ${{ matrix.os == 'windows' }}
        shell: bash
        # The executable for msys2 is also called bash.cmd
        #   https://github.com/actions/virtual-environments/blob/main/images/win/Windows2019-Readme.md#shells
        # If we prepend its location to the PATH
        #   subsequent 'shell: bash' steps will use msys2 instead of gitbash
        run: echo "C:/msys64/usr/bin" >> $GITHUB_PATH
web3-bot's avatar
web3-bot committed
37 38 39
      - name: Run repo-specific setup
        uses: ./.github/actions/go-test-setup
        if: hashFiles('./.github/actions/go-test-setup') != ''
web3-bot's avatar
web3-bot committed
40
      - name: Run tests
web3-bot's avatar
web3-bot committed
41
        uses: protocol/multiple-go-modules@v1.2
web3-bot's avatar
web3-bot committed
42
        with:
web3-bot's avatar
web3-bot committed
43 44 45 46
          # Use -coverpkg=./..., so that we include cross-package coverage.
          # If package ./A imports ./B, and ./A's tests also cover ./B,
          # this means ./B's coverage will be significantly higher than 0%.
          run: go test -v -coverprofile=module-coverage.txt -coverpkg=./... ./...
web3-bot's avatar
web3-bot committed
47 48
      - name: Run tests (32 bit)
        if: ${{ matrix.os != 'macos' }} # can't run 32 bit tests on OSX.
web3-bot's avatar
web3-bot committed
49
        uses: protocol/multiple-go-modules@v1.2
web3-bot's avatar
web3-bot committed
50 51
        env:
          GOARCH: 386
web3-bot's avatar
web3-bot committed
52
        with:
web3-bot's avatar
web3-bot committed
53 54 55
          run: |
            export "PATH=${{ env.PATH_386 }}:$PATH"
            go test -v ./...
web3-bot's avatar
web3-bot committed
56 57
      - name: Run tests with race detector
        if: ${{ matrix.os == 'ubuntu' }} # speed things up. Windows and OSX VMs are slow
web3-bot's avatar
web3-bot committed
58
        uses: protocol/multiple-go-modules@v1.2
web3-bot's avatar
web3-bot committed
59 60
        with:
          run: go test -v -race ./...
web3-bot's avatar
web3-bot committed
61 62 63
      - name: Collect coverage files
        shell: bash
        run: echo "COVERAGES=$(find . -type f -name 'module-coverage.txt' | tr -s '\n' ',' | sed 's/,$//')" >> $GITHUB_ENV
web3-bot's avatar
web3-bot committed
64
      - name: Upload coverage to Codecov
web3-bot's avatar
web3-bot committed
65
        uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
web3-bot's avatar
web3-bot committed
66
        with:
web3-bot's avatar
web3-bot committed
67
          files: '${{ env.COVERAGES }}'
web3-bot's avatar
web3-bot committed
68
          env_vars: OS=${{ matrix.os }}, GO=${{ matrix.go }}