---
name: testsuite

on:
  push:
    branches:
      - "*"
    tags-ignore:
      - "*"
  pull_request:

jobs:
  ubuntu:
    name: 'Initial Linux w/author tests'
    env:
      PERL_USE_UNSAFE_INC: 0

    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v3
      - name: perl -V
        run: perl -V
      - name: Install Dependencies
        uses: perl-actions/install-with-cpm@stable
        with:
          cpanfile: "cpanfile"
      - name: Build.PL
        run: perl -I$(pwd) Build.PL
      - name: Full author test
        run: ./Build authortest

  linux:
    name: "Linux with Perl ${{ matrix.perl-version }}"
    needs: [ubuntu]
    runs-on: ubuntu-latest

    env:
      PERL_USE_UNSAFE_INC: 0

    strategy:
      fail-fast: false
      matrix:
        # See https://www.reddit.com/r/perl/comments/1dg1fur/
        os:
          - ubuntu-22.04
        perl-version:
          - latest
          - 5.40-bookworm
          - 5.38-bookworm
          - 5.36-bookworm
          - 5.34-bullseye
          - 5.32-bullseye
          - 5.30-bullseye
          - 5.28-buster
          - 5.26-buster
          - 5.24-buster
          - 5.22-buster
          - 5.20-buster
          - 5.18-buster
          - 5.16-buster
          - 5.14-buster
          - 5.12-buster
          - 5.10-buster
    container:
      image: "perl:${{ matrix.perl-version }}"

    steps:
      - uses: actions/checkout@v3
      - name: perl -V
        run: perl -V
      - name: Install Dependencies
        uses: perl-actions/install-with-cpm@stable
        with:
          sudo: false
          cpanfile: "cpanfile"
      - run: perl Build.PL
      - name: Full author test
        run: ./Build authortest

  macOS:
    needs: [ubuntu, linux]
    runs-on: macOS-latest

    env:
      PERL_USE_UNSAFE_INC: 0

    steps:
      - uses: actions/checkout@v3
      - name: Set up Perl
        run: brew install perl
      - name: perl -V
        run: perl -V
      - name: Install Dependencies
        uses: perl-actions/install-with-cpm@stable
        with:
          sudo: false
          cpanfile: "cpanfile"
      - run: perl Build.PL
      - name: Full author test
        run: ./Build authortest

  windows:
    needs: [ubuntu, linux]
    runs-on: windows-latest

    steps:
      - uses: actions/checkout@v3
      - name: Set up Perl
        run: |
          choco install strawberryperl
          echo 'PATH=C:\strawberry\c\bin;C:\strawberry\perl\site\bin;C:\strawberry\perl\bin' >> $GITHUB_ENV
      - name: perl -V
        run: perl -V
      - name: Install Dependencies
        uses: perl-actions/install-with-cpm@stable
        with:
          sudo: false
          cpanfile: "cpanfile"
      - name: perl Build.PL
        run: perl Build.PL
      - name: Full author test
        run: ./Build authortest
