Skip to content

build and test

build and test #2030

---
name: build and test
on:
schedule:
- cron: '0 6 * * *'
push:
branches:
- master
tags-ignore:
- '*'
pull_request:
workflow_dispatch:
env:
PERL_CPANM_OPT: "--quiet --notest"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Extract author information
run: |
echo AUTHOR_NAME="$(git log -1 ${GITHUB_REF} --pretty='%aN')" >> $GITHUB_ENV
echo AUTHOR_EMAIL="$(git log -1 ${GITHUB_REF} --pretty='%aE')" >> $GITHUB_ENV
- name: Setup Perl
id: perl
uses: shogo82148/actions-setup-perl@v1
- name: Get build timestamp
run: echo BUILD_TIMESTAMP="$(date +%FT%T)" >> $GITHUB_ENV
- name: Cache build dependencies
uses: actions/cache@v4
with:
path: local
key: cache-build-deps-${{ steps.perl.outputs.perl-hash }}-${{ env.BUILD_TIMESTAMP }}
restore-keys: cache-build-deps-${{ steps.perl.outputs.perl-hash }}-
- name: Install Dist::Zilla
run: cpanm --local-lib ${GITHUB_WORKSPACE}/local Dist::Zilla
- name: Configure Dist::Zilla
run: |
mkdir ~/.dzil
echo "[%User]" > ~/.dzil/config.ini
echo "name = ${AUTHOR_NAME}" >> ~/.dzil/config.ini
echo "email = ${AUTHOR_EMAIL}" >> ~/.dzil/config.ini
cat ~/.dzil/config.ini
- name: Install author dependencies
run: dzil authordeps | cpanm --local-lib ${GITHUB_WORKSPACE}/local
- name: Install App::cpanoutdated
run: cpanm --local-lib ${GITHUB_WORKSPACE}/local App::cpanoutdated
- name: Upgrade CPAN modules
run: cpan-outdated -p | cpanm --local-lib ${GITHUB_WORKSPACE}/local
- name: Build dist
run: dzil build --no-tgz --in build
- name: Create build tarball
run: tar cvf build.tar -C build .
- name: Upload build results
uses: actions/upload-artifact@v4
with:
name: build.tar
path: build.tar
coverage:
if: ${{ github.event_name != 'schedule' }}
needs: build
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Download build results
uses: actions/download-artifact@v4
with:
name: build.tar
- name: Extract build tarball
run: tar xvf build.tar
- name: Install packages
run: sudo apt-get install -y augeas-tools libaugeas-dev
- name: Setup Perl
id: perl
uses: shogo82148/actions-setup-perl@v1
- name: Get build timestamp
run: echo BUILD_TIMESTAMP="$(date +%FT%T)" >> $GITHUB_ENV
- name: Cache coverage dependencies
uses: actions/cache@v4
with:
path: local
key: cache-coverage-deps-${{ steps.perl.outputs.perl-hash }}-${{ env.BUILD_TIMESTAMP }}
restore-keys: cache-coverage-deps-${{ steps.perl.outputs.perl-hash }}-
- name: Install dependencies
run: cpanm --local-lib ${GITHUB_WORKSPACE}/local --installdeps --with-develop --with-all-features --with-recommends --with-suggests .
- name: Install coverage dependencies
run: cpanm --local-lib ${GITHUB_WORKSPACE}/local Devel::Cover::Report::Coveralls Pod::Coverage::CountParents
- name: Install App::cpanoutdated
run: cpanm --local-lib ${GITHUB_WORKSPACE}/local App::cpanoutdated
- name: Upgrade CPAN modules
run: cpan-outdated -p | cpanm --local-lib ${GITHUB_WORKSPACE}/local
- name: Run tests with coverage
env:
HARNESS_PERL_SWITCHES: -MDevel::Cover=+ignore,^local/
run: prove --timer --lib --recurse --jobs $(nproc) --shuffle t/
- name: Report coverage info to Coveralls
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: cover -report coveralls
extra-tests:
needs: build
runs-on: ubuntu-latest
env:
AUTHOR_TESTING: 1
EXTENDED_TESTING: 1
RELEASE_TESTING: 1
steps:
- name: Download build results
uses: actions/download-artifact@v4
with:
name: build.tar
- name: Extract build tarball
run: tar xvf build.tar
- name: Install packages
run: sudo apt-get install -y aspell libaugeas-dev
- name: Setup Perl
id: perl
uses: shogo82148/actions-setup-perl@v1
- name: Get build timestamp
run: echo BUILD_TIMESTAMP="$(date +%FT%T)" >> $GITHUB_ENV
- name: Cache extra-tests dependencies
uses: actions/cache@v4
with:
path: local
key: cache-extra-tests-deps-${{ steps.perl.outputs.perl-hash }}-${{ env.BUILD_TIMESTAMP }}
restore-keys: cache-extra-tests-deps-${{ steps.perl.outputs.perl-hash }}-
- name: Install dependencies
run: cpanm --local-lib ${GITHUB_WORKSPACE}/local --installdeps --with-develop .
- name: Install App::cpanoutdated
run: cpanm --local-lib ${GITHUB_WORKSPACE}/local App::cpanoutdated
- name: Upgrade CPAN modules
run: cpan-outdated -p | cpanm --local-lib ${GITHUB_WORKSPACE}/local
- name: Cache perlcritic history
uses: actions/cache@v4
with:
path: /tmp/cache/.perlcritic-history
key: cache-perlcritic-history-${{ env.BUILD_TIMESTAMP }}
restore-keys: cache-perlcritic-history-
- name: Run extra tests
run: prove --timer --lib --recurse --jobs $(nproc) --shuffle xt/
tests:
needs: build
strategy:
fail-fast: false
matrix:
os:
- ubuntu
- macos
- windows
perl:
- latest
- '5.38'
- '5.36'
- '5.34'
- '5.32'
- '5.30'
- '5.28'
- '5.26'
- '5.24'
- '5.22'
- '5.20'
- '5.18'
- '5.16'
- '5.14'
- '5.12'
exclude:
- os: windows
perl: '5.34' # not released yet
- os: windows
perl: '5.12' # no 64-bit portable binaries
runs-on: ${{ matrix.os }}-latest
steps:
- name: Download build results
uses: actions/download-artifact@v4
with:
name: build.tar
- name: Extract build tarball
run: tar xvf build.tar
- name: Setup Perl
id: perl
uses: shogo82148/actions-setup-perl@v1
with:
perl-version: ${{ matrix.perl }}
distribution: ${{ matrix.os == 'windows' && 'strawberry' || 'default' }}
- name: Disable LWP for cpanm on older Strawberry Perls
run: echo "PERL_CPANM_OPT=$env:PERL_CPANM_OPT --no-lwp" >> $env:GITHUB_ENV
if: matrix.os == 'windows' && matrix.perl <= 5.22
- name: Install dependencies
uses: carlkidcrypto/[email protected]
with:
macos: cpanm --installdeps --with-all-features --with-recommends .
linux: cpanm --installdeps --with-all-features --with-recommends .
windows: cpanm --installdeps --with-all-features --without-feature=custom_output --without-feature=rsync --with-recommends .
- name: Get number of processors
id: cores
uses: SimenB/github-actions-cpu-cores@v2
- name: Run tests
run: prove --timer --lib --recurse --jobs ${{ steps.cores.outputs.count }} --shuffle t/