name: Biber CI

env:
  URL: https://www.cpan.org/src/5.0/perl-5.32.0.tar.gz
  MAKEFLAGS: -j2
  BIBER_DEV_TESTS: 1
  
# Controls when the action will run. 
on:
  schedule:
   - cron: "0 2 * * *"

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
       - name: Install Perl
         run: |
           echo Downloading and compiling in [$PWD] from [$URL]

           mkdir perlsource
           wget -nc $URL
           tar -xf $(basename $URL) --strip-components=1 --directory=perlsource

           pushd perlsource
           bash +x ./Configure -sde -Dprefix="$RUNNER_WORKSPACE/localperl"
           test -f Makefile
           make
           make install
           popd

       - name: Set ENV
         run: |
           echo "$RUNNER_WORKSPACE/localperl/bin" >> $GITHUB_PATH
           echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$RUNNER_WORKSPACE/localperl/lib" >> $GITHUB_ENV

       - name: Checkout
         uses: actions/checkout@v2

       - name: Install Biber Dependencies Without Test
         run: |
           cpan -T Module::Build
           perl Build.PL
           ./Build installdeps --cpan_client "cpan -T"

       - name: Run biber tests
         run: |
           ./Build test
