-
Notifications
You must be signed in to change notification settings - Fork 25
189 lines (159 loc) · 6.98 KB
/
ci.yml
File metadata and controls
189 lines (159 loc) · 6.98 KB
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# -----------------------------------------------------------------------------
#
# Copyright (c) 2017-2025 Sam Cox, Roberto Sommariva, James Allsopp
#
# This file is part of the AtChem2 software package.
#
# This file is licensed under the MIT license, which can be found in the file
# `LICENSE` at the top level of the AtChem2 distribution.
#
# -----------------------------------------------------------------------------
# -------------------------------------------------------------------- #
# Workflow for the continuous integration (CI) of AtChem2, using
# Github Actions and Codecov
# -------------------------------------------------------------------- #
name: AtChem2 CI
# ------------------------------ EVENTS ------------------------------ #
# Controls when the workflow is activated
on:
# Triggers when a pull request targeting the master branch is
# created or updated
pull_request:
branches: [ master ]
# Triggers when a push is made to the master branch by merging a
# pull request (direct commits to master are disabled)
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 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, with
# three versions of gnu fortran
#
# RUNNERS: https://github.com/actions/runner-images
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04, ubuntu-24.04] # NB: macos testing temporarily deactivated
fortran: [11, 12, 13]
# compiler versions not available for specific runners
exclude:
- os: ubuntu-22.04
fortran: 13
fail-fast: false
permissions:
contents: read
# -------------------------------------------------------------
# Sequence of tasks to be executed as part of the `ci_testing` job:
# 1. Checkout repository
# 2. Install gfortran, if not available
# 3. Install AtChem2 dependencies
# 4. Build AtChem2
# 5. Run Testsuite with default settings
# 6. Recompile AtChem2, run Testsuite for Codecov
steps:
# -------------------------------------------------------------
# (1) Checkout the repository under $GITHUB_WORKSPACE
#
# ACTION: https://github.com/marketplace/actions/checkout
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 2
# -------------------------------------------------------------
# (2) Install gfortran, if not supplied with the runner
# gfortran on ubuntu
- name: Install gfortran-11 (ubuntu-24.04)
if: matrix.os == 'ubuntu-24.04' && matrix.fortran == 11
run: sudo apt-get install gfortran-11
# gfortran on macos
- name: Install gfortran-10 and gfortran-11 (macos-13)
if: matrix.os == 'macos-13' && (matrix.fortran == 10 || matrix.fortran == 11)
run: brew install gcc@${{ matrix.fortran }}
# -------------------------------------------------------------
# (3) Install the AtChem2 dependencies: CVODE, openlibm, numdiff, FRUIT
#
# NB: the current version of FRUIT (v3.4.3) does not work with the most
# recent versions of Ruby; as a temporary fix, Ruby v3.0 is used for
# all unit tests in this workflow
#
# ACTION: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
- 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: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.0'
- name: Install FRUIT
run: ./tools/install/install_fruit.sh $PWD
- name: Install Python and Fortran formatters
run: pip install black fprettify
# -------------------------------------------------------------
# (4) Build AtChem2 using the standard compilation flags
- name: Build AtChem2
env:
FORT_VERSION: ${{ matrix.fortran }}
run: |
cp tools/install/Makefile.skel Makefile
./build/build_atchem2.sh --mechanism=./model/mechanism.fac --shared_lib=./model/sharedlib --configuration=./model/configuration --mcm=v3.3.1
# 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
# -------------------------------------------------------------
# (5) Run the Testsuite using the standard compilation flags and the
# default model settings, then upload the log files as artifacts
#
# ACTION: https://github.com/marketplace/actions/upload-a-build-artifact
- name: Indent and Style tests
run: |
make indenttest
make styletest
make pythontest
- name: Unit and Model tests
env:
FORT_VERSION: ${{ matrix.fortran }}
# continue-on-error: true
run: |
export PATH=$PATH:$PWD/numdiff/bin
make unittests
make oldtests # NB: oldtests will eventually be merged into modeltests
make modeltests
- name: Save log files
uses: actions/upload-artifact@v4
with:
name: testsuite_${{ matrix.os }}_fortran-${{ matrix.fortran }}.log
path: tests/*.log
# -------------------------------------------------------------
# (6) Recompile AtChem2 using the code coverage compilation flags,
# run the Testsuite and upload the gcov files to Codecov
#
# ACTION: https://github.com/marketplace/actions/codecov
- name: Unit and Model tests (x Codecov)
if: matrix.os == 'ubuntu-24.04' && matrix.fortran == 13
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* ./ # for gcc>=11 handling of *.gcda, *.gcna files
# model tests
make modeltests CCOV=true # run only the new Testsuite
find ./ -name "*.gc*"
- name: Upload coverage reports to Codecov
if: matrix.os == 'ubuntu-24.04' && matrix.fortran == 13
uses: codecov/codecov-action@v5