Day 5: CI for Win32-Wlan Perl module

Gabor Szabo - Dec 4 '22 - - Dev Community

I found Win32-Wlan on CPAN Digger as a Perl package that does not have CI configured in its GitHub repository.

While the indicates that this is a Windows-related thing, there are a number of packages on CPAN that are in the Win32 namespace, but also work on Linux. This one, it seems does not. It seems at least one of its dependencies, the Win32-API does not work on anything else besides Windows.

In the Makefile.PL of Win32-API I saw this code:

my $running_on_windows = $^O eq 'MSWin32' || $^O eq 'cygwin' || $^O eq 'msys';
die qq(OS unsupported\n)
    unless $running_on_windows
    or $ENV{WIN32_API_BUILD}     # So I can build it on Linux too
    ;
Enter fullscreen mode Exit fullscreen mode

So it can also work on cygwin and msys and it can be packaged on Linux as well.

We might be able to setup a Linux machine to build the distribution of the module and then we can run the tests on various versions of Perl on Windows. However I did not want to invest that much time before I even see that it would be interesting to the maintainer of the package.

The setup was quite simple as you can see from the GitHub Action config file below.

I had to remove the two most recent versions of Perl as it seems they are not available in the GitHub Action I used. That could be improved.

The Pull-Request

GitHub Actions

name: CI

on:
  push:
  pull_request:
  workflow_dispatch:
  schedule:
    - cron: '42 5 * * *'

jobs:
  test:
    strategy:
      fail-fast: false
      matrix:
        runner: [windows-latest]
        perl: [ '5.30', '5.32' ] # It seems that perl 5.34 and 5.36 are not available

    runs-on: ${{matrix.runner}}
    name: OS ${{matrix.runner}} Perl ${{matrix.perl}}

    steps:
    - uses: actions/checkout@v3

    - name: Set up perl
      uses: shogo82148/actions-setup-perl@v1
      with:
          perl-version: ${{ matrix.perl }}
          distribution: ${{ ( startsWith( matrix.runner, 'windows-' ) && 'strawberry' ) || 'default' }}

    - name: Show Perl Version
      run: |
        perl -v

    - name: Install Modules
      run: |
        cpanm -v
        cpanm --installdeps --notest .

    - name: Show Errors on Windows
      if:  ${{ failure() && startsWith( matrix.runner, 'windows-')}}
      run: |
         ls -l C:/Users/
         ls -l C:/Users/RUNNER~1/
         cat C:/Users/runneradmin/.cpanm/work/*/build.log

    - name: Run tests
      env:
        AUTHOR_TESTING: 1
        RELEASE_TESTING: 1
      run: |
        perl Makefile.PL
        make
        make test
Enter fullscreen mode Exit fullscreen mode

Conclusion

Sometimes you need Windows.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .