name: Test Matrix

on: workflow_dispatch

jobs:
  test-docker-versions-failing:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        docker_version:
          - "20.10.3"
    steps:
      - uses: actions/checkout@v3
      - name: Setup Docker
        uses: docker-practice/actions-setup-docker@master
      - name: Test Docker Version expected to fail
        run: |
          echo "Running test with docker version ${{matrix.docker_version}}"
          docker info
          set +e
          make e2e \
            -e E2E_DIND_VERSION=${{matrix.docker_version}} \
            -e E2E_INCLUDE=test_basic
          if [[ $? == 0 ]]; then
            echo "ATTENTION: Test passed while it was expected to fail!"
            exit 1
          fi
          set -e

  test-docker-versions:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        docker_version:
          - "20.10.5"
          - "20.10.12"
          - "20.10.17"
    steps:
      - uses: actions/checkout@v3
      - name: Setup Docker
        uses: docker-practice/actions-setup-docker@master
      - name: Test Docker Version expected to pass
        run: |
          echo "Running test with docker version ${{matrix.docker_version}}"
          docker info
          make e2e \
            -e E2E_DIND_VERSION=${{matrix.docker_version}} \
            -e E2E_INCLUDE=test_basic

  test-k3s-versions-failing:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        k3s_channel:
          - "v1.17" 
    steps:
      - uses: actions/checkout@v3
      - name: Setup Docker
        uses: docker-practice/actions-setup-docker@master
      - name: Test K3s Version expected to fail
        run: |
          echo "Running test with docker version ${{matrix.k3s_channel}}"
          docker info
          set +e
          make e2e \
            -e E2E_K3S_VERSION=+${{matrix.k3s_channel}} \
            -e E2E_INCLUDE=test_full_lifecycle
          if [[ $? == 0 ]]; then
            echo "ATTENTION: Test passed while it was expected to fail!"
            exit 1
          fi
          set -e

  test-k3s-versions:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        k3s_channel:
          - "v1.22"
          - "v1.23"
          - "v1.24"
          - "v1.25"
          - "v1.26"
    steps:
      - uses: actions/checkout@v3
      - name: Setup Docker
        uses: docker-practice/actions-setup-docker@master
      - name: Test K3s Version expected to pass
        run: |
          echo "Running test with K3s version ${{matrix.k3s_channel}}"
          make e2e \
            -e E2E_K3S_VERSION=+${{matrix.k3s_channel}} \
            -e E2E_INCLUDE=test_full_lifecycle
