Skip to content

Commit

Permalink
Hindcast Test: Conda python version (#318)
Browse files Browse the repository at this point in the history
- 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`
  • Loading branch information
ssolson committed May 3, 2024
1 parent 9ef0151 commit dff434d
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 36 deletions.
84 changes: 48 additions & 36 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ jobs:
steps:
- id: set-matrix
run: |
if [[ "${{ github.base_ref }}" == "develop" ]]; then
echo "matrix_os=[\"ubuntu-latest\"]" >> $GITHUB_OUTPUT
if [[ "${{ github.event_name }}" == "pull_request" && "${{ github.base_ref }}" == "develop" ]]; then
echo "matrix_os=[\"ubuntu-latest\"]" >> $GITHUB_OUTPUT
else
echo "matrix_os=[\"windows-latest\", \"ubuntu-latest\", \"macos-latest\"]" >> $GITHUB_OUTPUT
fi
Expand Down Expand Up @@ -107,14 +107,14 @@ jobs:
miniconda-version: 'latest'
auto-update-conda: true
activate-environment: TEST
python-version: ${{ matrix.python-version }}
python-version: ${{ env.PYTHON_VER }}
use-only-tar-bz2: true

- name: Setup Conda environment
shell: bash -l {0}
run: |
conda install numpy cython pip pytest hdf5 libnetcdf cftime netcdf4 coverage --strict-channel-priority
pip install -e . --no-deps --force-reinstall
pip install -e . --force-reinstall

- name: Install dependencies
shell: bash -l {0}
Expand Down Expand Up @@ -149,7 +149,7 @@ jobs:
miniconda-version: 'latest'
auto-update-conda: true
activate-environment: TEST
python-version: ${{ matrix.python-version }}
python-version: ${{ env.PYTHON_VER }}
use-only-tar-bz2: true

- name: Setup Conda environment
Expand Down Expand Up @@ -195,41 +195,36 @@ jobs:
with:
miniconda-version: 'latest'
auto-update-conda: true
environment-file: environment.yml
activate-environment: TEST
python-version: ${{ matrix.python-version }}
use-only-tar-bz2: true
use-only-tar-bz2: false

- name: Create and setup Conda environment
shell: bash -l {0}
run: |
conda install numpy cython pip hdf5 libnetcdf cftime netcdf4 --strict-channel-priority
pip install -e . --no-deps --force-reinstall

- name: Install dependencies
shell: bash -l {0}
run: |
python -m pip install --upgrade pip wheel
pip install coverage pytest coveralls .
conda install -c conda-forge pytest coverage=7.5.0 coveralls --strict-channel-priority
pip install -e . --force-reinstall

- name: Download data from artifact
uses: actions/download-artifact@v4
with:
name: data
path: ~/.cache/mhkit

- name: Run pytest
- name: Run pytest & generate coverage report
shell: bash -l {0}
run: |
coverage run --rcfile=.github/workflows/.coveragerc --source=./mhkit/ -m pytest -c .github/workflows/pytest.ini
coverage lcov

- name: Upload coverage data to coveralls.io
shell: bash -l {0}
run: |
coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_FLAG_NAME: ${{ matrix.python-version }}
COVERALLS_PARALLEL: true
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
flag-name: ${{ matrix.python-version }}
parallel: true
path-to-lcov: ./coverage.lcov

pip-build:
name: pip-${{ matrix.os }}/${{ matrix.python-version }}
Expand All @@ -249,6 +244,21 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install HDF5 (macOS with Python 3.8)
if: startsWith(runner.os, 'macOS') && matrix.python-version == '3.8'
run: brew install hdf5

- name: Install NetCDF (macOS with Python 3.8)
if: startsWith(runner.os, 'macOS') && matrix.python-version == '3.8'
run: brew install netcdf

- name: Set environment variables (macOS with Python 3.8)
if: startsWith(runner.os, 'macOS') && matrix.python-version == '3.8'
run: |
echo "HDF5_DIR=$(brew --prefix hdf5)" >> $GITHUB_ENV
echo "NETCDF4_DIR=$(brew --prefix netcdf)" >> $GITHUB_ENV
echo "PKG_CONFIG_PATH=$(brew --prefix hdf5)/lib/pkgconfig:$(brew --prefix netcdf)/lib/pkgconfig:$PKG_CONFIG_PATH" >> $GITHUB_ENV

- name: Set up Git repository
uses: actions/checkout@v4

Expand All @@ -264,17 +274,19 @@ jobs:
python -m pip install --upgrade pip wheel
pip install coverage pytest coveralls .

- name: Run pytest
- name: Run pytest & generate coverage report
shell: bash -l {0}
run: |
coverage run --rcfile=.github/workflows/.coveragerc --source=./mhkit/ -m pytest -c .github/workflows/pytest.ini
coverage run --rcfile=.github/workflows/.coveragerc --source=./mhkit/ -m pytest -c .github/workflows/pytest.ini
coverage lcov

- name: Upload coverage data to coveralls.io
run: coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_FLAG_NAME: ${{ matrix.python-version }}
COVERALLS_PARALLEL: true
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
flag-name: ${{ matrix.python-version }}
parallel: true
path-to-lcov: ./coverage.lcov

hindcast-calls:
name: hindcast-${{ matrix.os }}/${{ matrix.python-version }}
Expand Down Expand Up @@ -338,15 +350,15 @@ jobs:
python -m pip install --upgrade pip wheel
pip install coveralls .
coverage run --rcfile=.github/workflows/.coveragehindcastrc -m pytest -c .github/workflows/pytest-hindcast.ini
coverage lcov

- name: Upload coverage data to coveralls.io
shell: bash -l {0}
run: |
coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_FLAG_NAME: ${{ matrix.python-version }}
COVERALLS_PARALLEL: true
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
flag-name: ${{ matrix.python-version }}
parallel: true
path-to-lcov: ./coverage.lcov

coveralls:
name: Indicate completion to coveralls.io
Expand Down
25 changes: 25 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: myenv
channels:
- conda-forge
- defaults
dependencies:
- python>=3.8
- pandas>=1.0.0
- numpy>=1.21.0
- scipy
- matplotlib
- requests
- lxml
- scikit-learn
- statsmodels
- bottleneck
- beautifulsoup4
- xarray
- h5py>=3.6.0
- netcdf4>=1.5.8
- pip:
- pecos>=0.3.0
- fatpack
- NREL-rex>=0.2.63
- h5pyd>=0.7.0
- six>=1.13.0

0 comments on commit dff434d

Please sign in to comment.