on: [push, pull_request]
jobs:
  test_linux:
    strategy:
      matrix:
        go: [1.11, 1.17]
    runs-on: ubuntu-latest
    steps:
    - uses: actions/setup-go@v3
      with:
        go-version: ${{ matrix.go }}
    - uses: actions/checkout@v3
    - run: |
        sudo apt install -y samba
        sudo groupadd smbgroup
        sudo useradd smbuser -G smbgroup
        (echo Smbpasswd12345; echo Smbpasswd12345) | sudo smbpasswd -a -s smbuser
        sudo cp ./.github/smb.conf /etc/samba/smb.conf
        sudo smbd
    - uses: actions/cache@v2
      with:
        path: |
          ~/go/pkg/mod
          ~/.cache/go-build
          ~/Library/Caches/go-build
          ~\AppData\Local\go-build
        key: ${{ runner.os }}-go-${{ matrix.go }}-${{ hashFiles('**/go.sum') }}
        restore-keys: ${{ runner.os }}-go-${{ matrix.go }}-
    - run: |
        cp ./.github/client_conf.json ./
        go test -v -race ./...
  test_windows:
    strategy:
      matrix:
        go: [1.11, 1.17]
    runs-on: windows-latest
    steps:
    - uses: actions/setup-go@v3
      with:
        go-version: ${{ matrix.go }}
    - uses: actions/checkout@v3
    - run: |
        mkdir C:\tmp
        net user smbuser Smbpasswd12345 /add
        net share tmp="C:\tmp" /GRANT:smbuser,full
        net share tmp2="C:\tmp" /GRANT:smbuser,read
    - uses: actions/cache@v2
      with:
        path: |
          ~/go/pkg/mod
          ~/.cache/go-build
          ~/Library/Caches/go-build
          ~\AppData\Local\go-build
        key: ${{ runner.os }}-go-${{ matrix.go }}-${{ hashFiles('**/go.sum') }}
        restore-keys: ${{ runner.os }}-go-${{ matrix.go }}-
    - run: |
        cp ./.github/client_conf.json ./
        go test -v -race ./...
