name: linux

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

jobs:
  perl:

    runs-on: ubuntu-latest

    env:
       PERL_USE_UNSAFE_INC: 0
       AUTHOR_TESTING: 1
       AUTOMATED_TESTING: 1
       RELEASE_TESTING: 1
       PERL_CARTON_PATH: $GITHUB_WORKSPACE/local

    strategy:
      fail-fast: false
      matrix:
        perl-version:
          - '5.32'
          - '5.30'
          - '5.28'
          - '5.26'
          - '5.24'
          - '5.22'
          - '5.20'
          - '5.18'
          - '5.16'
          - '5.14'
#          - '5.12'
#          - '5.10'
#          - '5.8'

    container:
      image: perldocker/perl-tester:${{ matrix.perl-version }}

    steps:
      - uses: actions/checkout@v2
      - name: perl -V
        run: perl -V
      - name: Install Dependencies
        run: cpanm --notest --installdeps .
      - name: perl Makefile.PL
        run: perl Makefile.PL
      - name: make
        run: make
      - name: Run Tests (no coverage)
        if: matrix.perl-version != '5.32'
        run: prove -wlvmb t
      - name: Install optional test modules
        if: matrix.perl-version == '5.32'
        run: cpanm --notest Linux::Seccomp IO::Pty
      - name: Run tests (with coverage)
        if: matrix.perl-version == '5.32'
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          cpanm --notest Devel::Cover::Report::Coveralls
          `perl -MConfig -E'print $Config::Config{"sitebin"}'`/cover -test -report Coveralls