name: Test
on:
  pull_request:
  push: { branches: master }

jobs:
  test:
    name: Run test suite with docker
    runs-on: ubuntu-latest
    env:
      COMPOSE_FILE: docker-compose.yml

    steps:
    - name: Checkout code
      uses: actions/checkout@v4

    - name: Build docker images
      run: docker compose build

    - name: Run ruby 2.6
      run: docker compose run ruby-2.6

    - name: Run ruby 2.7
      run: docker compose run ruby-2.7

    - name: Run ruby 3.0
      run: docker compose run ruby-3.0

    - name: Run ruby 3.1
      run: docker compose run ruby-3.1

  test_openssl3:
    name: Run test suite with docker and openssl 3.0
    runs-on: ubuntu-latest

    steps:
    - name: Checkout code
      uses: actions/checkout@v4

    - name: Build docker images
      run: docker build -t netssh_openssl3 -f Dockerfile.openssl3 .

    - name: Run ruby 3.0 with openssl3
      run: docker run --rm netssh_openssl3

  test_zlib_ng:
    name: Run test suite with docker and zlib-ng
    runs-on: ubuntu-latest

    steps:
    - name: Checkout code
      uses: actions/checkout@v4

    - name: Build docker images
      run: docker build -t netssh_zlib_ng -f Dockerfile.zlib_ng .

    - name: Run ruby with zlib-ng
      run: docker run --rm netssh_zlib_ng
