name: Test-Windows

on:
  push:
    branches: ['*_']
    tags:
    - '*_'  # ending underscore for trying things
    - 'v[0-9]+.[0-9]+.[0-9]+'  # final version
    - 'v[0-9]+.[0-9]+.[0-9]+[abrc]+[0-9]+'  # alpha, beta, release candidate (rc)
    - 'v[0-9]+.[0-9]+.[0-9]+.dev[0-9]+'  # development versions
  pull_request:
  #  paths-ignore: ['docs/**']  # we can't use it and enforce some checks

# necessary for Windows
defaults:
  run:
    shell: bash

env:
  WIN_PYTHON_VERSION: 3.10.7
  WIN_LIBRSYNC_VERSION: v2.3.2

jobs:
  test-tox-win:
    runs-on: windows-latest
    strategy:
      matrix:
        arch: [x86, x64]
    steps:
    - name: skip workflow if only docs PR
      id: skip-docs # id used for referencing step
      uses: saulmaldonado/skip-workflow@v1.1.1
      with:
        phrase: '[DOC]'
        search: '["pull_request"]'
        github-token: ${{ secrets.GITHUB_TOKEN }}
    - uses: actions/checkout@v3
      if: '!steps.skip-docs.outputs.skip'
      with:
        fetch-depth: 0  # to have the correct version
    - name: Set up Python ${{ env.WIN_PYTHON_VERSION }}
      if: '!steps.skip-docs.outputs.skip'
      uses: actions/setup-python@v4
      with:
        python-version: ${{ env.WIN_PYTHON_VERSION }}
        architecture: ${{ matrix.arch }}
    - name: Install dependencies
      if: '!steps.skip-docs.outputs.skip'
      run: tools/win_provision.sh asciidoc
    - name: Build librsync
      if: '!steps.skip-docs.outputs.skip'
      run: tools/win_build_librsync.sh ${{ matrix.arch }} ${WIN_LIBRSYNC_VERSION}
    - name: Test rdiff-backup
      if: '!steps.skip-docs.outputs.skip'
      run: tools/win_test_rdiffbackup.sh ${{ matrix.arch }} ${WIN_PYTHON_VERSION}
