GitHub CI updates #193
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: [push, pull_request] | |
jobs: | |
Build: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
build: [fpm, meson] | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
gcc: [13] # Version of GFortran we want to use. | |
build-type: [debug] | |
include: | |
- build: meson | |
os: ubuntu-latest | |
gcc: 13 | |
build-type: coverage | |
defaults: | |
run: | |
shell: ${{ contains(matrix.os, 'windows') && 'powershell' || 'bash -l {0}' }} | |
env: | |
FC: gfortran | |
CC: gcc | |
FPM_FC: gfortran | |
FPM_CC: gcc | |
steps: | |
- name: Checkout code | |
uses: actions/[email protected] | |
with: | |
submodules: recursive | |
- name: Cache GFortran install | |
if: ${{ contains(matrix.os, 'windows') }} | |
id: cache | |
uses: actions/[email protected] | |
with: | |
path: ./mingw-w64 | |
key: gcc-${{ matrix.gcc }}-${{ matrix.os }} | |
- name: Install GFortran (MacOS) | |
if: ${{ contains(matrix.os, 'macos') }} | |
run: | | |
brew install gcc@${{ matrix.gcc }} | |
ln -s /usr/local/bin/gfortran-${{ matrix.gcc }} /usr/local/bin/gfortran | |
ln -s /usr/local/bin/gcc-${{ matrix.gcc }} /usr/local/bin/gcc | |
- name: Install GFortran (Linux) | |
if: ${{ contains(matrix.os, 'ubuntu') }} | |
run: | | |
sudo update-alternatives \ | |
--install /usr/bin/gcc gcc /usr/bin/gcc-${{ matrix.gcc }} 100 \ | |
--slave /usr/bin/gfortran gfortran /usr/bin/gfortran-${{ matrix.gcc }} \ | |
--slave /usr/bin/gcov gcov /usr/bin/gcov-${{ matrix.gcc }} | |
- name: Install GFortran (Windows) | |
if: ${{ contains(matrix.os, 'windows') && steps.cache.outputs.cache-hit != 'true' }} | |
run: | | |
Invoke-WebRequest -Uri ${{ env.DOWNLOAD }} -OutFile mingw-w64.zip | |
Expand-Archive mingw-w64.zip | |
echo "$pwd\mingw-w64\mingw64\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append | |
shell: pwsh | |
env: | |
DOWNLOAD: "https://github.com/brechtsanders/winlibs_mingw/releases/download/13.3.0posix-11.0.1-ucrt-r1/winlibs-x86_64-posix-seh-gcc-13.3.0-mingw-w64ucrt-11.0.1-r1.zip" | |
- name: Install dependencies | |
uses: mamba-org/[email protected] | |
with: | |
environment-file: config/ci/${{ matrix.build }}-env.yaml | |
create-args: ${{ matrix.build-type == 'coverage' && 'gcovr' || '' }} | |
- name: Compile (fpm) | |
if: ${{ matrix.build == 'fpm' }} | |
run: fpm build --profile release | |
- name: Run test (fpm) | |
if: ${{ matrix.build == 'fpm' }} | |
run: fpm test | |
- name: Run examples (fpm) | |
if: ${{ matrix.build == 'fpm' }} | |
run: fpm run --example --all | |
- name: Setup build (meson) | |
if: ${{ matrix.build == 'meson' }} | |
run: >- | |
meson setup _build | |
--libdir=lib | |
--prefix=${{ contains(matrix.os, 'windows') && '$pwd\_dist' || '$PWD/_dist' }} | |
${{ matrix.build-type == 'coverage' && '-Db_coverage=true' || '' }} | |
- name: Compile project (meson) | |
if: ${{ matrix.build == 'meson' }} | |
run: meson compile -C _build | |
- name: Run testsuite (meson) | |
if: ${{ matrix.build == 'meson' }} | |
run: | | |
meson test -C _build --no-rebuild --print-errorlogs | |
${{ matrix.build-type == 'coverage' && 'ninja -C _build coverage' || '' }} | |
- name: Install project (meson) | |
if: ${{ matrix.build == 'meson' }} | |
run: meson install -C _build --no-rebuild | |
- name: Create package (Unix) | |
if: ${{ matrix.build == 'meson' && ! contains(matrix.os, 'windows') }} | |
run: | | |
tar cvf ${{ env.OUTPUT }} _dist | |
xz -T0 ${{ env.OUTPUT }} | |
echo "MINPACK_OUTPUT=${{ env.OUTPUT }}.xz" >> $GITHUB_ENV | |
env: | |
OUTPUT: minpack-${{ matrix.os }}.tar | |
- name: Create package (Windows) | |
if: ${{ matrix.build == 'meson' && contains(matrix.os, 'windows') }} | |
run: | | |
tar cvf ${{ env.OUTPUT }} _dist | |
xz -T0 ${{ env.OUTPUT }} | |
echo "MINPACK_OUTPUT=${{ env.OUTPUT }}.xz" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
env: | |
OUTPUT: minpack-${{ matrix.os }}.tar | |
- name: Upload package | |
if: ${{ matrix.build == 'meson' && matrix.build-type != 'coverage' }} | |
uses: actions/[email protected] | |
with: | |
name: ${{ env.MINPACK_OUTPUT }} | |
path: ${{ env.MINPACK_OUTPUT }} | |
- name: Upload coverage report | |
if: ${{ matrix.build-type == 'coverage' }} | |
uses: codecov/[email protected] | |
Python: | |
needs: | |
- Build | |
runs-on: ${{ matrix.os }} | |
defaults: | |
run: | |
shell: ${{ contains(matrix.os, 'windows') && 'powershell' || 'bash -l {0}' }} | |
strategy: | |
fail-fast: false | |
matrix: | |
build: [meson] | |
os: [ubuntu-latest, macos-latest] | |
gcc: [13] | |
python: ['3.10', '3.11', '3.12'] | |
# Additional test for setuptools build | |
include: | |
- build: setuptools | |
os: ubuntu-latest | |
gcc: 13 | |
python: '3.12' | |
env: | |
FC: gfortran | |
CC: gcc | |
MINPACK_OUTPUT: minpack-${{ matrix.os }}.tar.xz | |
steps: | |
- name: Checkout code | |
uses: actions/[email protected] | |
- name: Cache GFortran install | |
if: ${{ contains(matrix.os, 'windows') }} | |
id: cache | |
uses: actions/[email protected] | |
with: | |
path: ./mingw-w64 | |
key: gcc-${{ matrix.gcc }}-${{ matrix.os }} | |
- name: Install dependencies | |
uses: mamba-org/[email protected] | |
with: | |
environment-file: config/ci/python-env.yaml | |
create-args: python=${{ matrix.python }} | |
- name: Install GFortran (MacOS) | |
if: ${{ contains(matrix.os, 'macos') }} | |
run: | | |
brew install gcc@${{ matrix.gcc }} | |
ln -s /usr/local/bin/gfortran-${{ matrix.gcc }} /usr/local/bin/gfortran | |
ln -s /usr/local/bin/gcc-${{ matrix.gcc }} /usr/local/bin/gcc | |
- name: Install GFortran (Linux) | |
if: ${{ contains(matrix.os, 'ubuntu') }} | |
run: | | |
sudo update-alternatives \ | |
--install /usr/bin/gcc gcc /usr/bin/gcc-${{ matrix.gcc }} 100 \ | |
--slave /usr/bin/gfortran gfortran /usr/bin/gfortran-${{ matrix.gcc }} \ | |
--slave /usr/bin/gcov gcov /usr/bin/gcov-${{ matrix.gcc }} | |
- name: Install GFortran (Windows) | |
if: ${{ contains(matrix.os, 'windows') && steps.cache.outputs.cache-hit != 'true' }} | |
run: | | |
Invoke-WebRequest -Uri ${{ env.DOWNLOAD }} -OutFile mingw-w64.zip | |
Expand-Archive mingw-w64.zip | |
echo "$pwd\mingw-w64\mingw64\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append | |
shell: pwsh | |
env: | |
DOWNLOAD: "https://github.com/brechtsanders/winlibs_mingw/releases/download/13.3.0posix-11.0.1-ucrt-r1/winlibs-x86_64-posix-seh-gcc-13.3.0-mingw-w64ucrt-11.0.1-r1.zip" | |
- name: Download package | |
uses: actions/[email protected] | |
with: | |
name: ${{ env.MINPACK_OUTPUT }} | |
- name: Unpack package (Unix) | |
if: ${{ ! contains(matrix.os, 'windows') }} | |
run: | | |
tar xvf ${{ env.MINPACK_OUTPUT }} | |
echo "MINPACK_PREFIX=$PWD/_dist" >> $GITHUB_ENV | |
- name: Unpack package (Windows) | |
if: ${{ contains(matrix.os, 'windows') }} | |
run: | | |
tar xvf ${{ env.MINPACK_OUTPUT }} | |
echo "MINPACK_OUTPUT=${{ env.OUTPUT }}.xz" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
- name: Install Python extension module (pip) | |
if: ${{ matrix.build == 'setuptools' }} | |
run: pip3 install . -vv | |
working-directory: python | |
env: | |
PKG_CONFIG_PATH: ${{ env.PKG_CONFIG_PATH }}:${{ env.MINPACK_PREFIX }}/lib/pkgconfig | |
LD_RUNPATH_SEARCH_PATH: ${{ env.MINPACK_PREFIX }}/lib | |
- name: Install Python extension module (meson) | |
if: ${{ matrix.build == 'meson' }} | |
run: | | |
set -ex | |
meson setup _build --prefix=$CONDA_PREFIX --libdir=lib | |
meson compile -C _build | |
meson install -C _build | |
working-directory: python | |
env: | |
PKG_CONFIG_PATH: ${{ env.PKG_CONFIG_PATH }}:${{ env.MINPACK_PREFIX }}/lib/pkgconfig | |
- name: Test Python API | |
run: pytest --doctest-modules --pyargs minpack --cov=minpack -vv | |
env: | |
LD_LIBRARY_PATH: ${{ env.LD_LIBRARY_PATH }}:${{ env.MINPACK_PREFIX }}/lib | |
DYLD_LIBRARY_PATH: ${{ env.DYLD_LIBRARY_PATH }}:${{ env.MINPACK_PREFIX }}/lib | |
- name: Upload coverage report | |
uses: codecov/[email protected] | |
Docs: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
shell: bash -l {0} | |
steps: | |
- id: deploy-on-push | |
run: | |
echo "::set-output name=result::${{ env.DEPLOY_BRANCH }}" | |
env: | |
DEPLOY_BRANCH: ${{ secrets.DEPLOY_BRANCH && contains(github.ref, secrets.DEPLOY_BRANCH) && 1 || 0 }} | |
- name: Checkout code | |
uses: actions/[email protected] | |
with: | |
submodules: recursive | |
- name: Install dependencies | |
uses: mamba-org/[email protected] | |
with: | |
environment-file: config/ci/docs-env.yaml | |
- name: Build documentation | |
run: ford ./minpack.md | |
- name: Deploy Documentation | |
if: ${{ github.event_name == 'push' && steps.deploy-on-push.outputs.result != 0 }} | |
uses: JamesIves/[email protected] | |
with: | |
branch: gh-pages # The branch the action should deploy to. | |
folder: doc # The folder the action should deploy. | |
single-commit: true |