go-check.yml 1.31 KB
Newer Older
web3-bot's avatar
web3-bot committed
1 2
# File managed by web3-bot. DO NOT EDIT.
# See https://github.com/protocol/.github/ for details.
ipldbot's avatar
ipldbot committed
3 4 5 6 7 8 9 10 11

on: [push, pull_request]

jobs:
  unit:
    runs-on: ubuntu-latest
    name: Go checks
    steps:
      - uses: actions/checkout@v2
web3-bot's avatar
web3-bot committed
12
      - uses: actions/setup-go@v2
ipldbot's avatar
ipldbot committed
13
        with:
web3-bot's avatar
web3-bot committed
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
          go-version: "1.16.x"
      - name: Install staticcheck
        run: go install honnef.co/go/tools/cmd/staticcheck@be534f007836a777104a15f2456cd1fffd3ddee8 # v2020.2.2
      - name: Check that go.mod is tidy
        run: |
          cp go.mod go.mod.orig
          cp go.sum go.sum.orig
          go mod tidy
          diff go.mod go.mod.orig
          diff go.sum go.sum.orig
      - 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
      - name: go vet
        if: ${{ success() || failure() }} # run this step even if the previous one failed
        run: go vet ./...
      - name: staticcheck
        if: ${{ success() || failure() }} # run this step even if the previous one failed
        run: |
          set -o pipefail
          staticcheck ./... | sed -e 's@\(.*\)\.go@./\1.go@g'