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