Skip to content

Commit dff434d

Browse files
authored
Hindcast Test: Conda python version (#318)
- Uses python version correctly - Installs MHKiT dependencies in conda build - Use coverage actions instead of coverage CLI - Uses an updated coverage version with lcov support - Adds an `environment.yaml` file for conda environment install - Special case for MacOS-latest (macos 14) and Py 3.8 - CI test job `set-os` logic modified to now run all OS on push to `develop`
1 parent 9ef0151 commit dff434d

File tree

2 files changed

+73
-36
lines changed

2 files changed

+73
-36
lines changed

.github/workflows/main.yml

Lines changed: 48 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ jobs:
1717
steps:
1818
- id: set-matrix
1919
run: |
20-
if [[ "${{ github.base_ref }}" == "develop" ]]; then
21-
echo "matrix_os=[\"ubuntu-latest\"]" >> $GITHUB_OUTPUT
20+
if [[ "${{ github.event_name }}" == "pull_request" && "${{ github.base_ref }}" == "develop" ]]; then
21+
echo "matrix_os=[\"ubuntu-latest\"]" >> $GITHUB_OUTPUT
2222
else
2323
echo "matrix_os=[\"windows-latest\", \"ubuntu-latest\", \"macos-latest\"]" >> $GITHUB_OUTPUT
2424
fi
@@ -107,14 +107,14 @@ jobs:
107107
miniconda-version: 'latest'
108108
auto-update-conda: true
109109
activate-environment: TEST
110-
python-version: ${{ matrix.python-version }}
110+
python-version: ${{ env.PYTHON_VER }}
111111
use-only-tar-bz2: true
112112

113113
- name: Setup Conda environment
114114
shell: bash -l {0}
115115
run: |
116116
conda install numpy cython pip pytest hdf5 libnetcdf cftime netcdf4 coverage --strict-channel-priority
117-
pip install -e . --no-deps --force-reinstall
117+
pip install -e . --force-reinstall
118118
119119
- name: Install dependencies
120120
shell: bash -l {0}
@@ -149,7 +149,7 @@ jobs:
149149
miniconda-version: 'latest'
150150
auto-update-conda: true
151151
activate-environment: TEST
152-
python-version: ${{ matrix.python-version }}
152+
python-version: ${{ env.PYTHON_VER }}
153153
use-only-tar-bz2: true
154154

155155
- name: Setup Conda environment
@@ -195,41 +195,36 @@ jobs:
195195
with:
196196
miniconda-version: 'latest'
197197
auto-update-conda: true
198+
environment-file: environment.yml
198199
activate-environment: TEST
199200
python-version: ${{ matrix.python-version }}
200-
use-only-tar-bz2: true
201+
use-only-tar-bz2: false
201202

202203
- name: Create and setup Conda environment
203204
shell: bash -l {0}
204205
run: |
205-
conda install numpy cython pip hdf5 libnetcdf cftime netcdf4 --strict-channel-priority
206-
pip install -e . --no-deps --force-reinstall
207-
208-
- name: Install dependencies
209-
shell: bash -l {0}
210-
run: |
211-
python -m pip install --upgrade pip wheel
212-
pip install coverage pytest coveralls .
206+
conda install -c conda-forge pytest coverage=7.5.0 coveralls --strict-channel-priority
207+
pip install -e . --force-reinstall
213208
214209
- name: Download data from artifact
215210
uses: actions/download-artifact@v4
216211
with:
217212
name: data
218213
path: ~/.cache/mhkit
219214

220-
- name: Run pytest
215+
- name: Run pytest & generate coverage report
221216
shell: bash -l {0}
222217
run: |
223218
coverage run --rcfile=.github/workflows/.coveragerc --source=./mhkit/ -m pytest -c .github/workflows/pytest.ini
219+
coverage lcov
224220
225221
- name: Upload coverage data to coveralls.io
226-
shell: bash -l {0}
227-
run: |
228-
coveralls --service=github
229-
env:
230-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
231-
COVERALLS_FLAG_NAME: ${{ matrix.python-version }}
232-
COVERALLS_PARALLEL: true
222+
uses: coverallsapp/github-action@master
223+
with:
224+
github-token: ${{ secrets.GITHUB_TOKEN }}
225+
flag-name: ${{ matrix.python-version }}
226+
parallel: true
227+
path-to-lcov: ./coverage.lcov
233228

234229
pip-build:
235230
name: pip-${{ matrix.os }}/${{ matrix.python-version }}
@@ -249,6 +244,21 @@ jobs:
249244
with:
250245
python-version: ${{ matrix.python-version }}
251246

247+
- name: Install HDF5 (macOS with Python 3.8)
248+
if: startsWith(runner.os, 'macOS') && matrix.python-version == '3.8'
249+
run: brew install hdf5
250+
251+
- name: Install NetCDF (macOS with Python 3.8)
252+
if: startsWith(runner.os, 'macOS') && matrix.python-version == '3.8'
253+
run: brew install netcdf
254+
255+
- name: Set environment variables (macOS with Python 3.8)
256+
if: startsWith(runner.os, 'macOS') && matrix.python-version == '3.8'
257+
run: |
258+
echo "HDF5_DIR=$(brew --prefix hdf5)" >> $GITHUB_ENV
259+
echo "NETCDF4_DIR=$(brew --prefix netcdf)" >> $GITHUB_ENV
260+
echo "PKG_CONFIG_PATH=$(brew --prefix hdf5)/lib/pkgconfig:$(brew --prefix netcdf)/lib/pkgconfig:$PKG_CONFIG_PATH" >> $GITHUB_ENV
261+
252262
- name: Set up Git repository
253263
uses: actions/checkout@v4
254264

@@ -264,17 +274,19 @@ jobs:
264274
python -m pip install --upgrade pip wheel
265275
pip install coverage pytest coveralls .
266276
267-
- name: Run pytest
277+
- name: Run pytest & generate coverage report
268278
shell: bash -l {0}
269279
run: |
270-
coverage run --rcfile=.github/workflows/.coveragerc --source=./mhkit/ -m pytest -c .github/workflows/pytest.ini
280+
coverage run --rcfile=.github/workflows/.coveragerc --source=./mhkit/ -m pytest -c .github/workflows/pytest.ini
281+
coverage lcov
271282
272283
- name: Upload coverage data to coveralls.io
273-
run: coveralls --service=github
274-
env:
275-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
276-
COVERALLS_FLAG_NAME: ${{ matrix.python-version }}
277-
COVERALLS_PARALLEL: true
284+
uses: coverallsapp/github-action@master
285+
with:
286+
github-token: ${{ secrets.GITHUB_TOKEN }}
287+
flag-name: ${{ matrix.python-version }}
288+
parallel: true
289+
path-to-lcov: ./coverage.lcov
278290

279291
hindcast-calls:
280292
name: hindcast-${{ matrix.os }}/${{ matrix.python-version }}
@@ -338,15 +350,15 @@ jobs:
338350
python -m pip install --upgrade pip wheel
339351
pip install coveralls .
340352
coverage run --rcfile=.github/workflows/.coveragehindcastrc -m pytest -c .github/workflows/pytest-hindcast.ini
353+
coverage lcov
341354
342355
- name: Upload coverage data to coveralls.io
343-
shell: bash -l {0}
344-
run: |
345-
coveralls --service=github
346-
env:
347-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
348-
COVERALLS_FLAG_NAME: ${{ matrix.python-version }}
349-
COVERALLS_PARALLEL: true
356+
uses: coverallsapp/github-action@master
357+
with:
358+
github-token: ${{ secrets.GITHUB_TOKEN }}
359+
flag-name: ${{ matrix.python-version }}
360+
parallel: true
361+
path-to-lcov: ./coverage.lcov
350362

351363
coveralls:
352364
name: Indicate completion to coveralls.io

environment.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: myenv
2+
channels:
3+
- conda-forge
4+
- defaults
5+
dependencies:
6+
- python>=3.8
7+
- pandas>=1.0.0
8+
- numpy>=1.21.0
9+
- scipy
10+
- matplotlib
11+
- requests
12+
- lxml
13+
- scikit-learn
14+
- statsmodels
15+
- bottleneck
16+
- beautifulsoup4
17+
- xarray
18+
- h5py>=3.6.0
19+
- netcdf4>=1.5.8
20+
- pip:
21+
- pecos>=0.3.0
22+
- fatpack
23+
- NREL-rex>=0.2.63
24+
- h5pyd>=0.7.0
25+
- six>=1.13.0

0 commit comments

Comments
 (0)