name: Test
on: [push, pull_request]
jobs:
  build:
    strategy:
      matrix:
        go-version: [1.23.x, 1.25.x]
        platform: [windows-latest]
    runs-on: ${{ matrix.platform }}
    steps:
      - name: Install Go
        uses: actions/setup-go@v3
        with:
          go-version: ${{ matrix.go-version }}
      - name: Checkout code
        uses: actions/checkout@v2
      - name: Build
        run: |
          go build ./...
      - name: Run Windows Unit Tests
        run: |
          $env:GH_ACTION="TRUE"
          go test -v -race ./mount/...
  test:
    strategy:
      matrix:
        go-version: [1.23.x, 1.25.x]
        platform: [ubuntu-latest, macos-latest]
    runs-on: ${{ matrix.platform }}
    steps:
    - name: Install Go
      uses: actions/setup-go@v3
      with:
        go-version: ${{ matrix.go-version }}
    - name: Checkout code
      uses: actions/checkout@v2
    - name: Test
      run: |
        make test
  verify-go-directive:
    strategy:
      matrix:
        go-version: [1.23.x, 1.25.x]
        platform: [ubuntu-latest, macos-latest]
    runs-on: ${{ matrix.platform }}
    steps:
    - name: Install Go
      uses: actions/setup-go@v3
      with:
        go-version: ${{ matrix.go-version }}
    - name: Checkout code
      uses: actions/checkout@v2
    - name: Verify go directive
      run: |
        make verify-go-directive
  lint:
    runs-on: ubuntu-latest
    steps:
      - name: Install Go
        uses: actions/setup-go@v6
        with:
          go-version: v1.23
      - name: Checkout code
        uses: actions/checkout@v5
      - name: Lint
        uses: golangci/golangci-lint-action@v6
        with:
          version: v1.60.1
          args: --disable-all -v -E govet -E misspell -E gofmt -E ineffassign -E revive
  apidiff:
    runs-on: ubuntu-latest
    if: github.base_ref
    steps:
      - name: Install Go
        uses: actions/setup-go@v3
        with:
          go-version: 1.23.x
      - name: Add GOBIN to PATH
        run: echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
      - name: Install dependencies
        run: go install golang.org/x/exp/cmd/apidiff@latest
      - name: Checkout old code
        uses: actions/checkout@v2
        with:
          ref: ${{ github.base_ref }}
          path: "old"
      - name: Checkout new code
        uses: actions/checkout@v2
        with:
          path: "new"
      - name: APIDiff
        run: ./hack/verify-apidiff.sh -d ../old
        working-directory: "new"
