DEV Community

Yuki Kimoto
Yuki Kimoto

Posted on

4 1

How to Write Tests using Github Actions

I explain how to write tests using Github Actions. This tests are run on Windows, Linux/Ubuntu(64bit, 32bit), Mac, and support Perl 5.8. Dependent CPAN modules can be used.

This article is originally How to Write Tests using Github Actions - Perl ABC

Examples of Tests using Github Actions

See examples at first.

Examples

Downloading cpanm

Download cpanm into your home direcotry of your product and add excutable permission to it.

curl -L http://cpanmin.us > cpanm
chmod +x cpanm

Github Actions Definitions

These are Github Actions.

Linux - Ubuntu - 64bit*Ubuntrulinux-ubuntu-latest.yml*

name: linux-ubuntu-latest

on:
  push:
    branches:
      - '*'
    tags-ignore:
      - '*'
  pull_request:

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - run: perl -V
      - run: perl -MConfig -MData::Dumper -e 'local $Data::Dumper::Sortkeys = 1;warn Dumper \%Config;'
      - run: perl cpanm -L ~/mylib -n SPVM
      - run: echo "PERL5LIB=$HOME/mylib/lib/perl5/"$(perl -MConfig -e 'print $Config{archname}') >> $GITHUB_ENV
      - run: perl Makefile.PL
      - run: make
      - run: make disttest

Linux - Ubuntu - 32bit

linux-ubuntu-latest-32bit.yml

name: linux-ubuntu-latest-32bit

on:
  push:
    branches:
      - '*'
    tags-ignore:
      - '*'
  pull_request:

jobs:
  build:
    runs-on: ubuntu-latest
    container:
      image: i386/ubuntu:latest
    steps:
      - run: |
          apt update
          apt install -y libperl-dev build-essential
      - uses: actions/checkout@v1
      - run: perl -V
      - run: perl -MConfig -MData::Dumper -e 'local $Data::Dumper::Sortkeys = 1;warn Dumper \%Config;'
      - run: perl cpanm -L ~/mylib -n SPVM
      - run: echo "PERL5LIB=$HOME/mylib/lib/perl5/"$(perl -MConfig -e 'print $Config{archname}') >> $GITHUB_ENV
      - run: perl Makefile.PL
      - run: make
      - run: make disttest

Linux - Ubuntu - 64bit - Perl 5.8

linux-ubuntu-latest-perl-5.8.9.yml

name: linux-ubuntu-latest-perl-5.8.9

on:
  push:
    branches:
      - '*'
    tags-ignore:
      - '*'
  pull_request:

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: shogo82148/actions-setup-perl@v1
        with:
          perl-version: '5.8.9'
      - run: perl -V
      - run: perl -MConfig -MData::Dumper -e 'local $Data::Dumper::Sortkeys = 1;warn Dumper \%Config;'
      - run: perl cpanm ExtUtils::CBuilder
      - run: perl cpanm -L ~/mylib -n SPVM
      - run: echo "PERL5LIB=$HOME/mylib/lib/perl5/"$(perl -MConfig -e 'print $Config{archname}') >> $GITHUB_ENV
      - run: perl Makefile.PL
      - run: make
      - run: make disttest

Mac

macos-latest.yml

name: macos-latest

on:
  push:
    branches:
      - '*'
    tags-ignore:
      - '*'
  pull_request:

jobs:
  build:
    runs-on: macos-latest
    steps:
      - uses: actions/checkout@v1
      - run: brew install perl
      - run: perl -V
      - run: perl -MConfig -MData::Dumper -e 'local $Data::Dumper::Sortkeys = 1;warn Dumper \%Config;'
      - run: perl cpanm -L ~/mylib -n SPVM
      - run: echo "PERL5LIB=$HOME/mylib/lib/perl5/"$(perl -MConfig -e 'print $Config{archname}') >> $GITHUB_ENV
      - run: perl Makefile.PL
      - run: make
      - run: make disttest

Windows Server 2019

windows-2019.yml

name: windows-2019

on:
  push:
    branches:
      - '*'
    tags-ignore:
      - '*'
  pull_request:

jobs:
  perl:
    runs-on: windows-2019
    steps:
      - uses: actions/checkout@master
      - run: perl -V
      - run: perl -MConfig -MData::Dumper -e 'local $Data::Dumper::Sortkeys = 1;warn Dumper \%Config;'
      - run: perl cpanm -n SPVM
      - run: perl Makefile.PL
      - run: gmake
      - run: gmake disttest

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay