name: Windows Unit Tests
on:
    pull_request: {}
    push: {}

jobs:
  build:
    strategy:
      matrix:
        go-versions: [1.16.x]
        platform: [windows-latest]
    runs-on: ${{ matrix.platform }}
    steps:
      - name: Set up Go 1.x
        uses: actions/setup-go@v5
        with:
          go-version: ^1.16
        id: go
      - name: Checkout code
        uses: actions/checkout@v4
      - name: Build Test
        run: |
          make smb-windows
      - name: Run Windows Unit Tests
        run: |
          # start the CSI Proxy before running tests on windows
          Start-Job -Name CSIProxy -ScriptBlock {
            Invoke-WebRequest https://acs-mirror.azureedge.net/csi-proxy/v1.1.1/binaries/csi-proxy-v1.1.1.tar.gz -OutFile csi-proxy.tar.gz;
            tar -xvf csi-proxy.tar.gz
            .\bin\csi-proxy.exe --kubelet-path $pwd --v=5
          };

          Start-Sleep -Seconds 30;

          Write-Output "getting named pipes"
          [System.IO.Directory]::GetFiles("\\.\\pipe\\")

          go test -v -race ./pkg/...