github.com/ipld/go-ipld-prime@v0.21.0/.github/workflows/go-check.yml (about)

     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 Checks
     6  
     7  jobs:
     8    unit:
     9      runs-on: ubuntu-latest
    10      name: All
    11      steps:
    12        - uses: actions/checkout@v3
    13          with:
    14            submodules: recursive
    15        - id: config
    16          uses: protocol/.github/.github/actions/read-config@master
    17        - uses: actions/setup-go@v3
    18          with:
    19            go-version: 1.20.x
    20        - name: Run repo-specific setup
    21          uses: ./.github/actions/go-check-setup
    22          if: hashFiles('./.github/actions/go-check-setup') != ''
    23        - name: Install staticcheck
    24          run: go install honnef.co/go/tools/cmd/staticcheck@4970552d932f48b71485287748246cf3237cebdf # 2023.1 (v0.4.0)
    25        - name: Check that go.mod is tidy
    26          uses: protocol/multiple-go-modules@v1.2
    27          with:
    28            run: |
    29              go mod tidy
    30              if [[ -n $(git ls-files --other --exclude-standard --directory -- go.sum) ]]; then
    31                echo "go.sum was added by go mod tidy"
    32                exit 1
    33              fi
    34              git diff --exit-code -- go.sum go.mod
    35        - name: gofmt
    36          if: success() || failure() # run this step even if the previous one failed
    37          run: |
    38            out=$(gofmt -s -l .)
    39            if [[ -n "$out" ]]; then
    40              echo $out | awk '{print "::error file=" $0 ",line=0,col=0::File is not gofmt-ed."}'
    41              exit 1
    42            fi
    43        - name: go vet
    44          if: success() || failure() # run this step even if the previous one failed
    45          uses: protocol/multiple-go-modules@v1.2
    46          with:
    47            run: go vet ./...
    48        - name: staticcheck
    49          if: success() || failure() # run this step even if the previous one failed
    50          uses: protocol/multiple-go-modules@v1.2
    51          with:
    52            run: |
    53              set -o pipefail
    54              staticcheck ./... | sed -e 's@\(.*\)\.go@./\1.go@g'
    55        - name: go generate
    56          uses: protocol/multiple-go-modules@v1.2
    57          if: (success() || failure()) && fromJSON(steps.config.outputs.json).gogenerate == true
    58          with:
    59            run: |
    60              git clean -fd # make sure there aren't untracked files / directories
    61              go generate -x ./...
    62              # check if go generate modified or added any files
    63              if ! $(git add . && git diff-index HEAD --exit-code --quiet); then
    64                echo "go generated caused changes to the repository:"
    65                git status --short
    66                exit 1
    67              fi