# This is a basic workflow to help you get started with Actions

name: Release Tests

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the main branch
on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]
  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  ubuntu:
    name: Release Tests on Ubuntu 20.04
    runs-on: ubuntu-20.04
    steps:
      - name: Checkout the repository
        uses: actions/checkout@v4
      - name: Cache CPAN packages
        uses: actions/cache@v2
        with:
          path: |
            ~/.perl-cpm/cache
            ~/.perl-cpm/builds
            **/local/
          key: ${{ runner.os }}-ubuntu-20.04
          restore-keys: |
            ${{ runner.os }}-ubuntu-20.04
      - name: apt install
        run: |
          sudo apt-get update
          sudo apt-get -y dist-upgrade
          sudo apt-get install --ignore-hold --allow-downgrades -y \
           apache2 \
           mariadb-client-10.3 \
           netcat \
           build-essential \
           libapache2-mod-perl2 \
           libapache2-mod-perl2-dev \
           perlmagick \
           graphviz \
           curl libssl-dev zlib1g-dev openssl \
           libexpat-dev cmake git libcairo-dev \
           unzip wget 
      - name: cpm install
        run: |
          perl Makefile.PL
          #make cpanfile GEN_CPANFILE_ARGS='-A'
          perl -I$GITHUB_WORKSPACE/.github/cpm/lib/perl5 $GITHUB_WORKSPACE/.github/cpm/bin/cpm install \
          && tar -C $GITHUB_WORKSPACE \
              --exclude 'local/cache/*' \
              --exclude 'local/man/*' \
              --exclude '*.pod' \
              -zcvf local-lib.tar.gz local
      - name: Save dependencies
        uses: actions/upload-artifact@v2
        with:
          name: ubuntu-20.04-local-lib.tar.gz
          path: local-lib.tar.gz
      - name: Run Makefile.PL
        run: 'perl Makefile.PL'
      - name: Run checksetup
        run: 'perl checksetup.pl --no-database --default-localconfig --no-templates'
      - name: Run tests
        run: 'prove -Ilocal/lib/perl5 t'
