go-check.yml 1.66 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 Checks
web3-bot's avatar
web3-bot committed
6 7 8 9

jobs:
  unit:
    runs-on: ubuntu-latest
web3-bot's avatar
web3-bot committed
10
    name: All
web3-bot's avatar
web3-bot committed
11 12
    steps:
      - uses: actions/checkout@v2
web3-bot's avatar
web3-bot committed
13 14
        with:
          submodules: recursive
web3-bot's avatar
web3-bot committed
15 16 17 18
      - uses: actions/setup-go@v2
        with:
          go-version: "1.16.x"
      - name: Install staticcheck
web3-bot's avatar
web3-bot committed
19
        run: go install honnef.co/go/tools/cmd/staticcheck@434f5f3816b358fe468fa83dcba62d794e7fe04b # 2021.1 (v0.2.0)
web3-bot's avatar
web3-bot committed
20
      - name: Check that go.mod is tidy
web3-bot's avatar
web3-bot committed
21 22 23 24 25 26 27 28 29
        uses: protocol/multiple-go-modules@v1.0
        with:
          run: |
            go mod tidy
            if [[ -n $(git ls-files --other --exclude-standard --directory -- go.sum) ]]; then
              echo "go.sum was added by go mod tidy"
              exit 1
            fi
            git diff --exit-code -- go.sum go.mod
web3-bot's avatar
web3-bot committed
30 31 32 33 34 35 36 37
      - name: gofmt
        if: ${{ success() || failure() }} # run this step even if the previous one failed
        run: |
          out=$(gofmt -s -l .)
          if [[ -n "$out" ]]; then
            echo $out | awk '{print "::error file=" $0 ",line=0,col=0::File is not gofmt-ed."}'
            exit 1
          fi
web3-bot's avatar
web3-bot committed
38 39
      - name: go vet
        if: ${{ success() || failure() }} # run this step even if the previous one failed
web3-bot's avatar
web3-bot committed
40 41 42
        uses: protocol/multiple-go-modules@v1.0
        with:
          run: go vet ./...
web3-bot's avatar
web3-bot committed
43 44
      - name: staticcheck
        if: ${{ success() || failure() }} # run this step even if the previous one failed
web3-bot's avatar
web3-bot committed
45 46 47 48 49
        uses: protocol/multiple-go-modules@v1.0
        with:
          run: |
            set -o pipefail
            staticcheck ./... | sed -e 's@\(.*\)\.go@./\1.go@g'
web3-bot's avatar
web3-bot committed
50