build and test #2900
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| 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@v7 | |
| - 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@v6 | |
| 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@v7 | |
| 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@v7 | |
| - name: Download build results | |
| uses: actions/download-artifact@v8 | |
| 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 libmagic-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@v6 | |
| 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@v8 | |
| 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 libmagic-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@v6 | |
| 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@v6 | |
| 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.40' | |
| - '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' | |
| runs-on: ${{ matrix.os }}-latest | |
| steps: | |
| - name: Download build results | |
| uses: actions/download-artifact@v8 | |
| 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/os-specific-runner@v2.3.1 | |
| 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@v3 | |
| - name: Run tests | |
| run: prove --timer --lib --recurse --jobs ${{ steps.cores.outputs.count }} --shuffle t/ | |
| tests-extra-runners: | |
| needs: build | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: | |
| - dragonflybsd | |
| - freebsd | |
| - netbsd | |
| - openbsd | |
| - solaris | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 20 | |
| steps: | |
| - name: Download build results | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: build.tar | |
| - name: Extract build tarball | |
| run: tar xvf build.tar | |
| - name: Set environment variables based on OS | |
| id: env_cmd | |
| run: | | |
| echo COMMAND=${{ case( | |
| matrix.os == 'dragonflybsd', 'export LANG=C', | |
| matrix.os == 'solaris', 'export PATH=/usr/perl5/bin:/usr/gnu/bin:$PATH', | |
| 'echo Using default environment' | |
| ) }} >> $GITHUB_OUTPUT | |
| - name: Select install command based on OS | |
| id: install_cmd | |
| run: | | |
| echo COMMAND=${{ case( | |
| matrix.os == 'netbsd', '/usr/sbin/pkg_add -u', | |
| matrix.os == 'openbsd', 'pkg_add', | |
| matrix.os == 'solaris', 'pkg install --no-backup-be --accept -v', | |
| 'pkg install -y' | |
| ) }} >> $GITHUB_OUTPUT | |
| - name: Set install command as environment variable | |
| run: echo 'VM_INSTALL_CMD=${{ steps.install_cmd.outputs.COMMAND }}' >> $GITHUB_ENV | |
| - name: Set system setup command based on OS | |
| id: system_cmd | |
| run: | | |
| echo COMMAND=${{ case( | |
| matrix.os == 'solaris', '$VM_INSTALL_CMD developer/gcc/gcc-c developer/versioning/git system/management/augeas', | |
| '$VM_INSTALL_CMD augeas git' | |
| ) }} >> $GITHUB_OUTPUT | |
| - name: Set cpanm setup command based on OS | |
| id: cpanm_cmd | |
| run: | | |
| echo COMMAND=${{ case( | |
| matrix.os == 'openbsd', 'cpan install App::cpanminus', | |
| matrix.os == 'solaris', 'cpan install App::cpanminus', | |
| '$VM_INSTALL_CMD p5-App-cpanminus' | |
| ) }} >> $GITHUB_OUTPUT | |
| - name: Run tests on ${{ matrix.os }} | |
| uses: jenseng/dynamic-uses@v1 | |
| with: | |
| uses: vmactions/${{ matrix.os }}-vm@v1 | |
| with: | | |
| { | |
| "envs": "LANG PERL_CPANM_OPT VM_INSTALL_CMD", | |
| "prepare": "cd $GITHUB_WORKSPACE; ${{ steps.env_cmd.outputs.COMMAND }}; ${{ steps.system_cmd.outputs.COMMAND }}; ${{ steps.cpanm_cmd.outputs.COMMAND }}; cpanm --installdeps --with-all-features .; cpanm Parallel::ForkManager", | |
| "run": "cd $GITHUB_WORKSPACE; ${{ steps.env_cmd.outputs.COMMAND }}; prove --timer --lib --recurse --jobs 4 --shuffle t/" | |
| } |