Github Actions for Module::Install and showing error log on Linux, Mac OSX, and Windows
Earlier we saw how to create GitHub Actions to run on Linux, Windows, and Mac OSX. I used that idea on an old module of I maintain that is uses Module::Install for packaging.
At first it failed due to missing Module::Install, and even though I had a guess of the source of the problem, I thought it would be a good opportunity to check how could I see the content of the cpanm log files after a failing installation.
This is what I cam up with. It is used in the repository of the Math-RPN module.
examples/workflows/perl-os-matrix-show-logs.yml
name: CI on: push: branches: '*' pull_request: branches: '*' jobs: perl-job: strategy: fail-fast: false matrix: runner: [ubuntu-latest, macos-latest, windows-latest] perl: [ '5.32', '5.30' ] runs-on: ${{matrix.runner}} name: OS ${{matrix.runner}} Perl ${{matrix.perl}} steps: - uses: actions/checkout@v2 - name: Set up perl uses: shogo82148/actions-setup-perl@v1 with: perl-version: ${{ matrix.perl }} #distribution: strawberry - name: Install dependencies run: | cpanm --notest Module::Install cpanm --installdeps --notest . - name: Show content of log files on Linux if: ${{ failure() && startsWith( matrix.runner, 'ubuntu-' ) }} run: cat /home/runner/.cpanm/work/*/build.log - name: Show content of log files on Mac if: ${{ failure() && startsWith( matrix.runner, 'macos-' ) }} run: cat /Users/runner/.cpanm/work/*/build.log - name: Show content of log files on Windows if: ${{ failure() && startsWith( matrix.runner, 'windows-' ) }} run: cat C:/Users/RUNNER~1/.cpanm/work/*/build.log - name: Regular Tests run: | perl Makefile.PL make make test
The thing that is new here, compared to the annotated example is that we have 3 conditional steps. They all run only if one of the previous steps failed. Each one will run on a particular Operating system.
Each one will show the content of all the log-files created by cpanm in the respecive location on the specific Operating System.
The actual running of the tests come after it as we don't want to see the installation logs if the problem was only in running our own tests.
We also had to install Module::Install before we tried to install any of our dependencies as that's what developers who use Module::Install need to do.
Actually the use of Module::Install is discouraged by its current maintainer, but if you are already using it and don't want to change it now, then this is what you need to do.
Published on 2020-11-16