Day 5: CI for Win32-Wlan Perl module
Tags: opensource, beginners, programming, perl
Published: 2022-12-04 22:50:00

---
title: Day 5: CI for Win32-Wlan Perl module
published: true
description: 
tags: opensource, beginners, programming, perl
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
published_at: 2022-12-04 22:50 +0000
canonical_url: https://code-maven.com/ci-for-win32-wlan-perl-module
series: ci-2022-12
---

I found [Win32-Wlan](https://metacpan.org/dist/Win32-Wlan) on [CPAN Digger](https://cpan-digger.perlmaven.com/) as a Perl package that does not have CI configured in its [GitHub repository](https://github.com/Corion/Win32-Wlan/).


While the indicates that this is a Windows-related thing, there are a number of packages on [CPAN] (https://metacpan.org/) that are in the [`Win32`](https://metacpan.org/search?size=50&q=Win32) namespace, but also work on Linux. This one, it seems does not. It seems at least one of its dependencies, the [Win32-API](https://metacpan.org/dist/Win32-API) does not work on anything else besides Windows.

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

```perl
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
    ;
```

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](https://github.com/Corion/Win32-Wlan/pull/4)

## GitHub Actions

```yaml
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
```

## Conclusion

Sometimes you need Windows.