steps:
  info: &info
    image: golang:alpine
    environment:
      CGO_ENABLED: "0"
    commands:
      - go version
      - go env
    when:
      - event: [tag, push, pull_request, release, manual]
  lint:
    << : *info
    commands:
      - go install honnef.co/go/tools/cmd/staticcheck@latest
      - go install github.com/securego/gosec/v2/cmd/gosec@latest
      - go install mellium.im/checkmd@latest
      - go install mellium.im/checkdoc@latest
      - export PATH=$(go env GOPATH)/bin:$PATH
      - go vet ./...
      - gofmt -s -l . && [ -z "$(gofmt -s -l .)" ]
      # See: https://staticcheck.io/docs/checks
      - staticcheck -checks inherit,ST1000,ST1003,ST1016,ST1020,ST1021,ST1022,ST1023 ./...
      - gosec ./...
      - |
        checkdoc -fileheader.pattern='-' ./... <<EOF
        Copyright \d\d\d\d The (Mellium Contributors|Go Authors)\.( All rights reserved.)?
        Use of this source code is governed by (the BSD 2-clause|a BSD-style)
        license that can be found in the LICENSE file\.
        EOF
      - checkmd .
  validate:
    << : *info
    commands:
      - apk add git
      - go mod tidy
      - git diff --exit-code -- go.mod go.sum

depends_on:
  - dco
