go-test.yml 3.03 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.19.x","1.20.x"]
web3-bot's avatar
web3-bot committed
14 15
    env:
      COVERAGES: ""
web3-bot's avatar
web3-bot committed
16
    runs-on: ${{ fromJSON(vars[format('UCI_GO_TEST_RUNNER_{0}', matrix.os)] || format('"{0}-latest"', matrix.os)) }}
web3-bot's avatar
web3-bot committed
17
    name: ${{ matrix.os }} (go ${{ matrix.go }})
web3-bot's avatar
web3-bot committed
18
    steps:
web3-bot's avatar
web3-bot committed
19
      - uses: actions/checkout@v3
web3-bot's avatar
web3-bot committed
20 21
        with:
          submodules: recursive
web3-bot's avatar
web3-bot committed
22 23
      - id: config
        uses: protocol/.github/.github/actions/read-config@master
web3-bot's avatar
web3-bot committed
24
      - uses: actions/setup-go@v3
web3-bot's avatar
web3-bot committed
25 26 27 28 29 30
        with:
          go-version: ${{ matrix.go }}
      - name: Go information
        run: |
          go version
          go env
web3-bot's avatar
web3-bot committed
31
      - name: Use msys2 on windows
web3-bot's avatar
web3-bot committed
32
        if: matrix.os == 'windows'
web3-bot's avatar
web3-bot committed
33 34 35 36 37 38
        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
39 40 41
      - 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
42
      - name: Run tests
web3-bot's avatar
web3-bot committed
43
        if: contains(fromJSON(steps.config.outputs.json).skipOSes, matrix.os) == false
web3-bot's avatar
web3-bot committed
44
        uses: protocol/multiple-go-modules@v1.2
web3-bot's avatar
web3-bot committed
45
        with:
web3-bot's avatar
web3-bot committed
46 47 48
          # 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%.
web3-bot's avatar
web3-bot committed
49
          run: go test -v -shuffle=on -coverprofile=module-coverage.txt -coverpkg=./... ./...
web3-bot's avatar
web3-bot committed
50
      - name: Run tests (32 bit)
web3-bot's avatar
web3-bot committed
51 52 53 54
        # can't run 32 bit tests on OSX.
        if: matrix.os != 'macos' &&
          fromJSON(steps.config.outputs.json).skip32bit != true &&
          contains(fromJSON(steps.config.outputs.json).skipOSes, matrix.os) == false
web3-bot's avatar
web3-bot committed
55
        uses: protocol/multiple-go-modules@v1.2
web3-bot's avatar
web3-bot committed
56 57
        env:
          GOARCH: 386
web3-bot's avatar
web3-bot committed
58
        with:
web3-bot's avatar
web3-bot committed
59
          run: |
web3-bot's avatar
web3-bot committed
60
            export "PATH=$PATH_386:$PATH"
web3-bot's avatar
web3-bot committed
61
            go test -v -shuffle=on ./...
web3-bot's avatar
web3-bot committed
62
      - name: Run tests with race detector
web3-bot's avatar
web3-bot committed
63 64 65
        # speed things up. Windows and OSX VMs are slow
        if: matrix.os == 'ubuntu' &&
          contains(fromJSON(steps.config.outputs.json).skipOSes, matrix.os) == false
web3-bot's avatar
web3-bot committed
66
        uses: protocol/multiple-go-modules@v1.2
web3-bot's avatar
web3-bot committed
67 68
        with:
          run: go test -v -race ./...
web3-bot's avatar
web3-bot committed
69 70 71
      - 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
72
      - name: Upload coverage to Codecov
web3-bot's avatar
web3-bot committed
73
        uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1
web3-bot's avatar
web3-bot committed
74
        with:
web3-bot's avatar
web3-bot committed
75
          files: '${{ env.COVERAGES }}'
web3-bot's avatar
web3-bot committed
76
          env_vars: OS=${{ matrix.os }}, GO=${{ matrix.go }}