-
Notifications
You must be signed in to change notification settings - Fork 23
154 lines (132 loc) · 5.81 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# -----------------------------------------------------------------------------
#
# 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: [ubuntu-22.04, 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@v4
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