|
| 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 | + GOTESTFLAGS: -shuffle=on -cover -coverprofile=module-coverage.txt -coverpkg=./... |
| 16 | + GO386FLAGS: -shuffle=on |
| 17 | + GORACEFLAGS: -shuffle=on |
| 18 | + runs-on: ${{ fromJSON(vars[format('UCI_GO_TEST_RUNNER_{0}', matrix.os)] || format('"{0}-latest"', matrix.os)) }} |
| 19 | + name: ${{ matrix.os }} (go ${{ matrix.go }}) |
| 20 | + steps: |
| 21 | + - uses: actions/checkout@v3 |
| 22 | + with: |
| 23 | + submodules: recursive |
| 24 | + - id: config |
| 25 | + uses: protocol/.github/.github/actions/read-config@master |
| 26 | + - uses: actions/setup-go@v3 |
| 27 | + with: |
| 28 | + go-version: ${{ matrix.go }} |
| 29 | + - name: Go information |
| 30 | + run: | |
| 31 | + go version |
| 32 | + go env |
| 33 | + - name: Use msys2 on windows |
| 34 | + if: matrix.os == 'windows' |
| 35 | + shell: bash |
| 36 | + # The executable for msys2 is also called bash.cmd |
| 37 | + # https://github.com/actions/virtual-environments/blob/main/images/win/Windows2019-Readme.md#shells |
| 38 | + # If we prepend its location to the PATH |
| 39 | + # subsequent 'shell: bash' steps will use msys2 instead of gitbash |
| 40 | + run: echo "C:/msys64/usr/bin" >> $GITHUB_PATH |
| 41 | + - name: Run repo-specific setup |
| 42 | + uses: ./.github/actions/go-test-setup |
| 43 | + if: hashFiles('./.github/actions/go-test-setup') != '' |
| 44 | + - name: Run tests |
| 45 | + if: contains(fromJSON(steps.config.outputs.json).skipOSes, matrix.os) == false |
| 46 | + |
| 47 | + env: |
| 48 | + GOFLAGS: ${{ format('{0} {1}', env.GOTESTFLAGS, env.GOFLAGS) }} |
| 49 | + with: |
| 50 | + run: go test -v ./... |
| 51 | + - name: Run tests (32 bit) |
| 52 | + # can't run 32 bit tests on OSX. |
| 53 | + if: matrix.os != 'macos' && |
| 54 | + fromJSON(steps.config.outputs.json).skip32bit != true && |
| 55 | + contains(fromJSON(steps.config.outputs.json).skipOSes, matrix.os) == false |
| 56 | + |
| 57 | + env: |
| 58 | + GOARCH: 386 |
| 59 | + GOFLAGS: ${{ format('{0} {1}', env.GO386FLAGS, env.GOFLAGS) }} |
| 60 | + with: |
| 61 | + run: | |
| 62 | + export "PATH=$PATH_386:$PATH" |
| 63 | + go test -v ./... |
| 64 | + - name: Run tests with race detector |
| 65 | + # speed things up. Windows and OSX VMs are slow |
| 66 | + if: matrix.os == 'ubuntu' && |
| 67 | + contains(fromJSON(steps.config.outputs.json).skipOSes, matrix.os) == false |
| 68 | + |
| 69 | + env: |
| 70 | + GOFLAGS: ${{ format('{0} {1}', env.GORACEFLAGS, env.GOFLAGS) }} |
| 71 | + with: |
| 72 | + run: go test -v -race ./... |
| 73 | + - name: Collect coverage files |
| 74 | + id: coverages |
| 75 | + shell: bash |
| 76 | + run: echo "files=$(find . -type f -name 'module-coverage.txt' | tr -s '\n' ',' | sed 's/,$//')" >> $GITHUB_OUTPUT |
| 77 | + - name: Upload coverage to Codecov |
| 78 | + uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1 |
| 79 | + with: |
| 80 | + files: ${{ steps.coverages.outputs.files }} |
| 81 | + env_vars: OS=${{ matrix.os }}, GO=${{ matrix.go }} |
0 commit comments