Skip to content

Test on macos

Test on macos #322

Workflow file for this run

# -----------------------------------------------------------------------------
#
# Copyright (c) 2017 Sam Cox, Roberto Sommariva
#
# This file is part of the AtChem2 software package.
#
# This file is covered by the MIT license which can be found in the file
# LICENSE.md at the top level of the AtChem2 distribution.
#
# -----------------------------------------------------------------------------
# Workflow for continuous integration (CI) of AtChem2,
# using Github Actions and Codecov
#
# Acknowledgements: J. Allsopp
# ----------------------------------------------------- #
name: AtChem2 CI
# ------------------------------ EVENTS ------------------------------ #
# Controls when the workflow is activated
on:
# Triggers when a pull request is created or updated (only on the
# master branch)
pull_request:
branches: [ master ]
# Triggers when a push is made to the master branch (either by
# merging a pull request, or by direct commit)
push:
branches:
- master
# Run manually from the Actions tab
workflow_dispatch:
# ------------------------------ JOBS ------------------------------ #
# This workflow contains a single job called `testing`, which compiles
# the AtChem2 model, runs the Testsuite, and checks the Testsuite code
# coverage using Codecov
jobs:
testing:
# The job runs on both linux (ubuntu) and macos runner images,
# with three versions of gnu fortran -- the runner images are
# described here: https://github.com/actions/runner-images
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-11] #, macos-12]
fortran: [9, 10, 11]
# exclude: #TODO: fortran9 does not work on macos12
# - os: macos-12
# fortran: 9
fail-fast: false
# -------------------------------------------------------------
# Sequence of tasks to be executed as part of the `testing` job:
# 1. checkout the repository
# 2. install gfortran, AtChem2 dependencies
# 3. compile AtChem2
# 4. run all tests (indent, style, unit, model)
# 5. recompile AtChem2, run unit and model tests for Codecov
steps:
# -------------------------------------------------------------
# (1) Checkout the repository under $GITHUB_WORKSPACE
- uses: actions/checkout@v3
with:
fetch-depth: 2
# -------------------------------------------------------------
# (2) Install gfortran, if not supplied with the runner image,
# and the AtChem2 dependencies (CVODE, openlibm, numdiff, FRUIT)
# gfortran on macos-11
- name: Install gfortran-9 (macos-11)
if: matrix.os == 'macos-11' && matrix.fortran == 9
run: brew install gcc@${{ matrix.fortran }}
# gfortran on macos-12
- name: Install gfortran-9 and gfortran-10 (macos-12)
if: matrix.os == 'macos-12' && (matrix.fortran == 9 || matrix.fortran == 10)
run: brew install gcc@${{ matrix.fortran }}
# AtChem2 dependencies
- name: Install CVODE
run: ./tools/install/install_cvode.sh $PWD $(which gfortran-${{ matrix.fortran }})
- name: Install openlibm
run: ./tools/install/install_openlibm.sh $PWD
- name: Install numdiff
run: ./tools/install/install_numdiff.sh $PWD
- name: Install FRUIT
run: sudo ./tools/install/install_fruit.sh $PWD
# -------------------------------------------------------------
# (3) Compile AtChem2 using the standard compilation flags
- name: Build AtChem2
# Set $FORT_VERSION for use with the `Makefile`, called from
# the `build_atchem2.sh` script
env:
FORT_VERSION: ${{ matrix.fortran }}
run: |
cp tools/install/Makefile.skel Makefile
./build/build_atchem2.sh ./model/mechanism.fac
# macos only
if [ $RUNNER_OS != "Linux" ] ; then
install_name_tool -change libopenlibm.4.dylib $PWD/openlibm-0.8.1/libopenlibm.4.dylib atchem2 ;
install_name_tool -change @rpath/libsundials_cvode.2.dylib $PWD/cvode/lib/libsundials_cvode.dylib atchem2 ;
install_name_tool -change @rpath/libsundials_fnvecserial.2.dylib $PWD/cvode/lib/libsundials_fnvecserial.dylib atchem2 ;
install_name_tool -change @rpath/libsundials_nvecserial.2.dylib $PWD/cvode/lib/libsundials_nvecserial.dylib atchem2 ;
fi
# -------------------------------------------------------------
# (4) Run all tests: indent, style, unit, model
- name: Indent and Style tests
run: |
make indenttest
make styletest
- name: Unit and Model tests
# Set $FORT_VERSION for use with the `Makefile`
env:
FORT_VERSION: ${{ matrix.fortran }}
run: |
export PATH=$PATH:$PWD/numdiff/bin
#make unittests
#make oldtests # NB: oldtests will eventually be merged into modeltests
make modeltests # NB: modeltests are temporarily deactivated (pass on linux, fail on macos)
# -------------------------------------------------------------
# (5) Recompile AtChem2 using the code coverage flags, then
# upload the gcov files to Codecov
# - name: Unit and Model tests (x Codecov)
# if: matrix.os == 'ubuntu-22.04' && matrix.fortran == 11
# # Set $FORT_VERSION for use with the `Makefile`
# env:
# FORT_VERSION: ${{ matrix.fortran }}
# run: |
# export PATH=$PATH:$PWD/numdiff/bin
# make clean
# make unittests CCOV=true
# mv tests/unit_tests/*.gc* ./ # Needed to deal with gcc11 changing the way it handles gcda and gcna files
# make modeltests CCOV=true # Run only the new model Testsuite
- name: Upload coverage reports to Codecov
if: matrix.os == 'ubuntu-22.04' && matrix.fortran == 11
uses: codecov/codecov-action@v3
with:
gcov: true