---
name: Test-Linux

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

jobs:
  test-make-test:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: ["3.10",3.9,3.8,3.7]
    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'
    - name: Set up Python ${{ matrix.python-version }}
      if: '!steps.skip-docs.outputs.skip'
      uses: actions/setup-python@v4
      with:
        python-version: ${{ matrix.python-version }}
    - name: Install dependencies
      if: '!steps.skip-docs.outputs.skip'
      run: |
        sudo apt install librsync-dev libacl1-dev rdiff asciidoctor
        sudo pip3 install --upgrade -r requs/base.txt -r requs/optional.txt -r requs/test.txt
    - name: Execute tests ${{ matrix.test-step }}
      if: '!steps.skip-docs.outputs.skip'
      run: |
        export RUN_COMMAND=
        export SUDO=sudo
        make test
      # the empty RUN_COMMAND avoids using docker
