generated from NOAA-OWP/owp-open-source-project-template
-
Notifications
You must be signed in to change notification settings - Fork 63
/
action.yaml
210 lines (194 loc) · 7.87 KB
/
action.yaml
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
name: 'Checkout and build tests'
description: 'This action checks out the commit, sets up Ngen environemnt.'
author: 'hellkite500'
inputs:
targets:
required: false
description: 'Build targets'
default: 'all'
build-cores:
required: false
description: 'Number of cores to use for parallel builds'
default: '1'
build-dir:
required: false
description: 'Name of the build directory to run cmake in'
default: 'cmake_build'
bmi_c:
required: false
description: 'Activate C BMI library support'
default: 'OFF'
bmi_fortran:
required: false
description: 'Activate Fortran BMI library support'
default: 'OFF'
use_python:
required: false
description: 'Activate Python integration and BMI support'
#A lot of things oddly fail when this is not on by default...
default: 'OFF'
additional_python_requirements:
required: false
description: 'Path to additional requirements.txt for python packages'
default: ''
use_udunits:
required: false
description: 'Use UDUNITS2 for unit conversion'
default: 'ON'
use_netcdf:
required: false
description: 'Activate NetCDF Lumped Forcing Support'
default: 'ON'
use_sqlite:
required: false
description: 'Activate SQLite3 suppport for GeoPackage'
default: 'ON'
use_troute:
required: false
description: 'Enable t-route integration support'
default: 'OFF'
use_mpi:
required: false
description: 'Enable mpi support, only available for Linux runners'
default: 'OFF'
outputs:
build-dir:
description: "Directory build was performed in"
value: ${{ steps.cmake_init.outputs.build-dir }}
runs:
using: 'composite'
steps:
- name: Install MPI
#Only use this step if Linux/ubuntu is being used
if: |
inputs.use_mpi != 'OFF' &&
runner.os == 'Linux'
id: install-mpi
run: |
sudo apt-get update
sudo apt-get install -y --fix-missing libopenmpi-dev openmpi-bin openmpi-common
shell: bash
- name: Install NetCDF
run: |
if [ ${{ runner.os }} == 'Linux' ]
then
sudo apt-get update
sudo apt-get install -y --fix-missing libnetcdf-dev libnetcdff-dev libnetcdf-c++4-1 libnetcdf-c++4-dev
echo "NETCDF=/usr" >> $GITHUB_ENV
elif [ ${{ runner.os }} == 'macOS' ]
then
brew install netcdf netcdf-cxx netcdf-fortran
echo "LIBRARY_PATH=/usr/local/lib/:$LIBRARY_PATH" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=/usr/local/lib/:$LD_LIBRARY_PATH" >> $GITHUB_ENV
echo "LDFLAGS=-L/usr/local/lib" >> $GITHUB_ENV
echo "LIB=$LD_LIBRARY_PATH" >> $GITHUB_ENV
echo "NETCDF=/usr/local" >> $GITHUB_ENV
fi
shell: bash
- name: Install UDUNITS
run: |
if [ ${{ runner.os }} == 'Linux' ]
then
sudo apt-get update
sudo apt-get install -y --fix-missing libudunits2-dev
elif [ ${{ runner.os }} == 'macOS' ]
then
brew install udunits
fi
shell: bash
- name: Init Submodules
run: git submodule update --init --recursive
shell: bash
- name: Cache Boost Dependency
id: cache-boost-dep
uses: actions/cache@v3
with:
path: boost_1_79_0
key: unix-boost-dep
- name: Get Boost Dependency
if: steps.cache-boost-dep.outputs.cache-hit != 'true'
run: |
curl -L -o boost_1_79_0.tar.bz2 https://sourceforge.net/projects/boost/files/boost/1.79.0/boost_1_79_0.tar.bz2/download
tar xjf boost_1_79_0.tar.bz2
shell: bash
- name: Cache Python Dependencies
id: cache-py3-dependencies
uses: actions/cache@v3
with:
path: .venv
key: ${{ runner.os }}-python-deps
- name: Get Numpy Python Dependency
# Tried conditioning the cache/install of python with an extra check:
# inputs.use_python != 'OFF' &&
# but what happens is that a runner not requiring python will create an empty cache
# and future runners will pull that and then fail...
# What we could do is try to create a master `requirements.txt`
# and/or a `test_requirements.txt` file that we can build the hash key from
# and read it from the repo...but we still have to always initialize the cache
# regardless of whether a given runner uses it, to avoid another runner failing to
# find it. Or just initialize this minimum requirement of numpy, and let the venv
# grow based on other runners needs, effectively building the cache with each new addition
if: |
steps.cache-py3-dependencies.outputs.cache-hit != 'true'
run: |
python3 -m venv .venv
. .venv/bin/activate
pip install pip
pip install numpy
deactivate
shell: bash
- name: Init Additional Python Dependencies
# Don't condition additonal installs on a cache hit
# What will happen, however, is that the venv will get updated
# and thus the cache will get updated
# so any pip install will find modules already installed...
# if: |
# inputs.additional_python_requirements != '' &&
# steps.cache-py3-dependencies.outputs.cache-hit != 'true'
if: |
inputs.additional_python_requirements != ''
run: |
python3 -m venv .venv
. .venv/bin/activate
pip install -r ${{ inputs.additional_python_requirements }}
deactivate
shell: bash
- name: Setup Fortran Compiler
if: ${{ inputs.bmi_fortran == 'ON' && runner.os == 'macOS' }}
run: echo "FC=gfortran-13" >> $GITHUB_ENV
shell: bash
- name: Setup macOS Default Compiler Includes
if: runner.os == 'macOS'
run: |
echo "C_INCLUDE_PATH=/usr/local/include" >> $GITHUB_ENV
echo "CPLUS_INCLUDE_PATH=/usr/local/include" >> $GITHUB_ENV
shell: bash
- name: Cmake Initialization
id: cmake_init
run: |
export BOOST_ROOT="$(pwd)/boost_1_79_0"
export CFLAGS="-fsanitize=address -O1 -g -fno-omit-frame-pointer"
export CXXFLAGS="-fsanitize=address -O1 -g -fno-omit-frame-pointer -pedantic-errors"
. .venv/bin/activate
[ ! -d "$BOOST_ROOT" ] && echo "Error: no Boost root found at $BOOST_ROOT" && exit 1
cmake -B ${{ inputs.build-dir }} \
-DBMI_C_LIB_ACTIVE:BOOL=${{ inputs.bmi_c }} \
-DNGEN_ACTIVATE_PYTHON:BOOL=${{ inputs.use_python }} \
-DUDUNITS_ACTIVE:BOOL=${{ inputs.use_udunits }} \
-DBMI_FORTRAN_ACTIVE:BOOL=${{ inputs.bmi_fortran }} \
-DNGEN_ACTIVATE_ROUTING:BOOL=${{ inputs.use_troute }} \
-DNETCDF_ACTIVE:BOOL=${{ inputs.use_netcdf }} \
-DNGEN_WITH_SQLITE:BOOL=${{ inputs.use_sqlite }} \
-DMPI_ACTIVE:BOOL=${{ inputs.use_mpi }} -S .
echo "build-dir=$(echo ${{ inputs.build-dir }})" >> $GITHUB_OUTPUT
shell: bash
- name: Build Targets
#cmake >= 3.15 can build multiple targets
run: |
# Build Targets
# Disable leak detection during test enumeration
export ASAN_OPTIONS=detect_leaks=false
# Activate venv so that test discovery run during build works
. .venv/bin/activate
cmake --build ${{ inputs.build-dir }} --target ${{ inputs.targets }} -- -j ${{ inputs.build-cores }}
shell: bash