Skip to content

Add GitHub action for windows #189

Add GitHub action for windows

Add GitHub action for windows #189

Workflow file for this run

name: linux-build-dist
on:
push:
branches:
- '*'
pull_request:
branches:
- '*'
workflow_dispatch:
jobs:
build-perls:
runs-on: ${{ matrix.os }}
strategy:
matrix:
perl: [40, 38, 36, 34, 32]
os: [ubuntu-latest, macos-latest]
# include:
# - os: macos-latest
# - perl: 34
steps:
- uses: actions/checkout@v4
- name: set environment variables
env:
PERL_NAME: perl-5.${{ matrix.perl }}.0
GHA_OS: ${{ matrix.os }}
PERL_DIR: ~/perl/${{ runner.os }}/5.${{ matrix.perl }}
run: |
./.github/scripts/set_environment_variables.sh
- name: perl cache
env:
CACHE_KEY: ${{ runner.os }}-perl2-${{ matrix.perl }}
id: cache-perl
uses: actions/cache@v4
with:
path: ${{ env.PERL_DIR }}
key: ${{ env.CACHE_KEY }}
- name: install perl
if: steps.cache-perl.outputs.cache-hit != 'true'
run: |
./.github/scripts/install_perl.sh
build-gsl:
runs-on: ${{ matrix.os }}
strategy:
matrix:
gsl: [2.8, 2.7, 2.6, 2.5, 2.4, 2.3]
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v4
- name: set environment variables
env:
GSL_NAME: gsl-${{ matrix.gsl }}
GSL_DIR: ~/gsl/${{ runner.os }}/gsl-${{ matrix.gsl }}
run: |
./.github/scripts/set_environment_variables.sh
- name: gsl cache
env:
CACHE_KEY: ${{ runner.os }}-gsl4-${{ matrix.gsl }}
id: cache-gsl
uses: actions/cache@v4
with:
path: ${{ env.GSL_DIR }}
key: ${{ env.CACHE_KEY }}
- name: install gsl
if: steps.cache-gsl.outputs.cache-hit != 'true'
run: |
./.github/scripts/install_gsl.sh
build-dist:
runs-on: ${{ matrix.os }}
needs: [build-gsl, build-perls]
strategy:
matrix:
gsl: [2.8]
perl: [40]
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v4
- name: set environment variables
env:
GSL_NAME: gsl-${{ matrix.gsl }}
GSL_DIR: ~/gsl/${{ runner.os }}/gsl-${{ matrix.gsl }}
PERL_NAME: perl-5.${{ matrix.perl }}.0
PERL_DIR: ~/perl/${{ runner.os }}/5.${{ matrix.perl }}
run: |
./.github/scripts/set_environment_variables.sh
- name: perl cache
env:
CACHE_KEY: ${{ runner.os }}-perl2-${{ matrix.perl }}
id: cache-perl
uses: actions/cache@v4
with:
path: ${{ env.PERL_DIR }}
key: ${{ env.CACHE_KEY }}
- name: gsl cache
env:
CACHE_KEY: ${{ runner.os }}-gsl4-${{ matrix.gsl }}
id: cache-gsl
uses: actions/cache@v4
with:
path: ${{ env.GSL_DIR }}
key: ${{ env.CACHE_KEY }}
- name: install packages
run: |
# NOTE: The following packages are already installed in "ubuntu-latest" :
# build-essential curl g++ git wget libssl-dev libz-dev
# swig autoconf libtool
#sudo apt-get install swig autoconf libtool
swig -version
- name: install perl modules, build, and test
run: |
./.github/scripts/build_and_test.sh
- name: build dist
run: |
./.github/scripts/build_dist.sh
- name: Save dist as artifact
uses: actions/upload-artifact@v4
with:
name: math_gsl_dist
path: ${{ env.MATH_GSL_DISTNAME }}
- name: Save name of dist as artifact
uses: actions/upload-artifact@v4
with:
name: math_gsl_dist_name
path: math-gsl-dist-name.txt
install-dist-linux:
runs-on: ubuntu-latest
needs: [build-dist]
strategy:
fail-fast: false
matrix:
gsl: [2.8, 2.7, 2.6, 2.5, 2.4, 2.3]
perl: [40, 38, 36, 34, 32]
steps:
- uses: actions/checkout@v4
- name: set environment variables
env:
GSL_NAME: gsl-${{ matrix.gsl }}
GSL_DIR: ~/gsl/${{ runner.os }}/gsl-${{ matrix.gsl }}
PERL_NAME: perl-5.${{ matrix.perl }}.0
PERL_DIR: ~/perl/${{ runner.os }}/5.${{ matrix.perl }}
run: |
./.github/scripts/set_environment_variables.sh
- name: perl cache
env:
CACHE_KEY: ${{ runner.os }}-perl2-${{ matrix.perl }}
id: cache-perl
uses: actions/cache@v4
with:
path: ${{ env.PERL_DIR }}
key: ${{ env.CACHE_KEY }}
- name: gsl cache
env:
CACHE_KEY: ${{ runner.os }}-gsl4-${{ matrix.gsl }}
id: cache-gsl
uses: actions/cache@v4
with:
path: ${{ env.GSL_DIR }}
key: ${{ env.CACHE_KEY }}
- name: Download dist
env:
PERL_NAME: perl-5.${{ matrix.perl }}
PERL_DIR: ~/perl/${{runner.os}}/5.${{ matrix.perl }}
GSL_NAME: gsl-${{ matrix.gsl }}
GSL_DIR: ~/gsl/${{runner.os}}/gsl-${{ matrix.gsl }}
uses: actions/download-artifact@v4
with:
name: math_gsl_dist
- name: Download dist name
uses: actions/download-artifact@v4
with:
name: math_gsl_dist_name
- name: extract dist
run: |
DISTNAME=$(<math-gsl-dist-name.txt)
tar zxvf $DISTNAME
DISTDIR=$(perl -pe 's/\.tar.gz$//' <<<"$DISTNAME")
echo "DISTDIR=$DISTDIR" >> $GITHUB_ENV
- name: install perl modules and build and test
run: |
BASEDIR=$PWD
cd $DISTDIR
$BASEDIR/.github/scripts/build_and_test.sh
install-dist-macos:
runs-on: macos-latest
needs: [build-dist]
strategy:
fail-fast: false
matrix:
perl: [40, 38, 36]
#gsl: [2.7, 2.6]
# NOTE: on macos we will not build against a pre-installed gsl, this will cause
# Build.PL to download the latest gsl version from the internet instead
steps:
- uses: actions/checkout@v4
- name: set environment variables
env:
PERL_NAME: perl-5.${{ matrix.perl }}.0
PERL_DIR: ~/perl/${{ runner.os }}/5.${{ matrix.perl }}
run: |
./.github/scripts/set_environment_variables.sh
- name: perl cache
env:
CACHE_KEY: ${{ runner.os }}-perl2-${{ matrix.perl }}
id: cache-perl
uses: actions/cache@v4
with:
path: ${{ env.PERL_DIR }}
key: ${{ env.CACHE_KEY }}
- name: Download dist
env:
PERL_NAME: perl-5.${{ matrix.perl }}
PERL_DIR: ~/perl/${{runner.os}}/5.${{ matrix.perl }}
uses: actions/download-artifact@v4
with:
name: math_gsl_dist
- name: Download dist name
uses: actions/download-artifact@v4
with:
name: math_gsl_dist_name
- name: extract dist
run: |
DISTNAME=$(<math-gsl-dist-name.txt)
tar zxvf $DISTNAME
DISTDIR=$(perl -pe 's/\.tar.gz$//' <<<"$DISTNAME")
echo "DISTDIR=$DISTDIR" >> $GITHUB_ENV
- name: install perl modules and build and test
# NOTE: This should first download and install libgsl using the Math::GSL::Alien module
run: |
BASEDIR=$PWD
cd $DISTDIR
$BASEDIR/.github/scripts/build_and_test.sh
install-dist-windows:
runs-on: windows-latest
needs: [build-dist]
strategy:
fail-fast: false
matrix:
perl: ["5.38", "5.36", "5.32"]
#gsl: [2.7, 2.6]
# NOTE: on windows we will not build against a pre-installed gsl, this will cause
# Build.PL to download the latest gsl version from the internet instead
steps:
- uses: actions/checkout@v4
- name: Set up perl
uses: shogo82148/actions-setup-perl@v1
with:
perl-version: ${{ matrix.perl }}
distribution: strawberry
- name: Download dist
uses: actions/download-artifact@v4
with:
name: math_gsl_dist
- name: Download dist name
uses: actions/download-artifact@v4
with:
name: math_gsl_dist_name
- name: extract dist
shell: pwsh
run: |
$DISTNAME = Get-Content -Path math-gsl-dist-name.txt
tar -zxvf $DISTNAME
$DISTDIR = $DISTNAME -replace '\.tar\.gz$', ''
echo "DISTDIR=$DISTDIR" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Add Strawberry Perl to PATH
shell: pwsh
run: |
$perlPaths = &where.exe perl
echo "All Perl paths found:"
echo $perlPaths
$perlPath = $perlPaths | Select-String -Pattern "C:\\hostedtoolcache\\windows\\strawberry-perl"
if ($perlPath) {
$perlDir = [System.IO.Path]::GetDirectoryName(($perlPath | Select-Object -First 1).Line)
echo "Strawberry Perl found at $perlDir"
echo "STRAWBERRY_PERL_PATH=$perlDir" >> $env:GITHUB_ENV
} else {
echo "Strawberry Perl not found"
}
- name: Set up MSYS2
uses: msys2/setup-msys2@v2
with:
update: true
install: base-devel mingw-w64-x86_64-toolchain
- name: Update MSYS2 and install m4 package
# Note: adding m4 to the install list in the setup-msys2 action did not work
# so we have to install it manually
run: |
C:\msys64\usr\bin\pacman -Syu --noconfirm
C:\msys64\usr\bin\pacman -S --noconfirm m4
shell: cmd
- name: Add MSYS2 to Path
run: |
echo "C:\msys64\usr\bin" >> $env:GITHUB_PATH
- name: install perl modules and build and test
shell: pwsh
# NOTE: This should first download and install libgsl using the Math::GSL::Alien module
run: |
$env:PATH = "$env:STRAWBERRY_PERL_PATH;$env:PATH"
echo "PATH = $env:PATH"
perl -V
$BASEDIR = $PWD
cd $env:DISTDIR
$env:PERL_ALIEN_MSYS_BIN = "C:\msys64\usr\bin"
&cpanm -vn Alien::MSYS
perl -MAlien::MSYS -E "say Alien::MSYS->msys_path"
&cpanm -vn Net::SSLeay
&cpanm -n Alien::Build
&cpanm -vn Math::GSL::[email protected]
&cpanm -n Module::Build
New-Item -ItemType Directory -Force -Path xs
perl Build.PL
perl .\Build installdeps --cpan_client cpanm
perl .\Build
perl .\Build test