-
Notifications
You must be signed in to change notification settings - Fork 23
160 lines (138 loc) · 6.2 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
155
156
157
158
159
160
# -----------------------------------------------------------------------------
#
# 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 the 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 `ci_testing` which
# compiles the AtChem2 model, runs the Testsuite, and checks the code
# coverage using Codecov (https://app.codecov.io/gh/AtChem/AtChem2)
jobs:
ci_testing:
# The job runs on two versions of 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-20.04, ubuntu-22.04, macos-11, macos-12]
fortran: [9, 10, 11]
exclude: # TODO: gfortran-9 does not work on macos-12
- os: macos-12
fortran: 9
fail-fast: false
# -------------------------------------------------------------
# Sequence of tasks to be executed as part of the `ci_testing` job:
# 1. Checkout the repository
# 2. Install gfortran, AtChem2 dependencies
# 3. Compile AtChem2
# 4. Run the Testsuite with default settings
# 5. Recompile AtChem2, run unit and model tests for Codecov
steps:
# -------------------------------------------------------------
# (1) Checkout the repository under $GITHUB_WORKSPACE
- name: Checkout repo
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 ubuntu
- name: Install gfortran-11 (ubuntu-20.04)
if: matrix.os == 'ubuntu-20.04' && matrix.fortran == 11
run: sudo apt-get install gfortran-11
# gfortran on macos
- name: Install gfortran-9 (macos-11)
if: matrix.os == 'macos-11' && matrix.fortran == 9
run: brew install gcc@${{ matrix.fortran }}
- 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`, which is
# called by the `build_atchem2.sh` script
env:
FORT_VERSION: ${{ matrix.fortran }}
run: |
cp tools/install/Makefile.skel Makefile
./build/build_atchem2.sh ./model/mechanism.fac ./model/configuration/ ./mcm/
# 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 the Testsuite using the standard compilation flags and
# default settings: indent, style, unit, model tests
- 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 # TODO: temporarily deactivated (pass on linux, fail on macos)
# -------------------------------------------------------------
# (5) Recompile AtChem2 using the code coverage compilation
# 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
# unit tests
make unittests CCOV=true
mv tests/unit_tests/*.gc* ./ # needed for GCC-11 handling of *.gcda, *.gcna files
# model tests
make modeltests CCOV=true # run only the new Testsuite
- name: Upload coverage reports to Codecov
if: matrix.os == 'ubuntu-22.04' && matrix.fortran == 11
uses: codecov/codecov-action@v3
with:
gcov: true