on: [push, pull_request]

jobs:
  check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-go@v3
        with:
          skip-pkg-cache: true
          go-version: "1.20.x"
      - name: Check that no non-test files import Ginkgo or Gomega
        run: .github/workflows/no_ginkgo.sh
      - name: Check that go.mod is tidied
        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: Check that go mod vendor works
        run: |
          cd integrationtests/gomodvendor
          go mod vendor
  golangci-lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-go@v3
        with:
          go-version: "1.20.x"
      - name: golangci-lint (Linux)
        uses: golangci/golangci-lint-action@v3
        with:
          skip-pkg-cache: true
          args: --timeout=3m
          version: v1.52.2
      - name: golangci-lint (Windows)
        if: success() || failure() # run this step even if the previous one failed
        uses: golangci/golangci-lint-action@v3
        env:
          GOOS: "windows"
        with:
          skip-pkg-cache: true
          args: --timeout=3m
          version: v1.52.2
      - name: golangci-lint (OSX)
        if: success() || failure() # run this step even if the previous one failed
        uses: golangci/golangci-lint-action@v3
        env:
          GOOS: "darwin"
        with:
          skip-pkg-cache: true
          args: --timeout=3m
          version: v1.52.2
      - name: golangci-lint (FreeBSD)
        if: success() || failure() # run this step even if the previous one failed
        uses: golangci/golangci-lint-action@v3
        env:
          GOOS: "freebsd"
        with:
          skip-pkg-cache: true
          args: --timeout=3m
          version: v1.52.2
      - name: golangci-lint (others)
        if: success() || failure() # run this step even if the previous one failed
        uses: golangci/golangci-lint-action@v3
        env:
          GOOS: "solaris" # some OS that we don't have any build tags for
        with:
          skip-pkg-cache: true
          args: --timeout=3m
          version: v1.52.2
