Skip to content

Commit

Permalink
Use conda env file in all tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ssolson committed Nov 13, 2024
1 parent 9e0d63d commit 03c9552
Showing 1 changed file with 71 additions and 34 deletions.
105 changes: 71 additions & 34 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,28 @@ jobs:
activate-environment: TESTconda
use-only-tar-bz2: true

- name: Setup Conda environment
- name: Create MHKiT Conda environment
shell: bash -l {0}
run: |
conda install numpy cython pip hdf5 libnetcdf cftime netcdf4 --strict-channel-priority
pip install -e . --force-reinstall
conda env create -f environment.yml
conda activate mhkit-env

- name: Install dependencies
- name: Install testing dependencies
shell: bash -l {0}
run: |
python -m pip install --upgrade pip wheel
pip install coverage pytest coveralls .
conda activate mhkit-env
conda install -y pytest coverage coveralls

- name: Install mhkit
shell: bash -l {0}
run: |
conda activate mhkit-env
pip install -e . --no-deps

- name: Prepare non-hindcast API data
shell: bash -l {0}
run: |
conda activate mhkit-env
pytest mhkit/tests/river/test_io_usgs.py
pytest mhkit/tests/tidal/test_io.py
pytest mhkit/tests/wave/io/test_cdip.py
Expand Down Expand Up @@ -111,21 +118,28 @@ jobs:
python-version: ${{ env.PYTHON_VER }}
use-only-tar-bz2: true

- name: Setup Conda environment
- name: Create MHKiT Conda environment
shell: bash -l {0}
run: |
conda install numpy cython pip pytest hdf5 libnetcdf cftime netcdf4 coverage --strict-channel-priority
pip install -e . --force-reinstall
conda env create -f environment.yml
conda activate mhkit-env

- name: Install dependencies
- name: Install testing dependencies
shell: bash -l {0}
run: |
python -m pip install --upgrade pip wheel
pip install coverage pytest coveralls .
conda activate mhkit-env
conda install -y pytest coverage coveralls

- name: Install mhkit
shell: bash -l {0}
run: |
conda activate mhkit-env
pip install -e . --no-deps

- name: Prepare Wave Hindcast data
shell: bash -l {0}
run: |
conda activate mhkit-env
pytest mhkit/tests/wave/io/hindcast/test_hindcast.py

- name: Upload Wave Hindcast data as artifact
Expand Down Expand Up @@ -208,21 +222,28 @@ jobs:
python-version: ${{ matrix.python-version }}
use-only-tar-bz2: false

- name: Create and setup Conda environment
- name: Create MHKiT Conda environment
shell: bash -l {0}
run: |
conda install -c conda-forge pytest coverage=7.5.0 coveralls --strict-channel-priority
pip install -e . --force-reinstall
conda env create -f environment.yml
conda activate mhkit-env

- name: Download data from artifact
uses: actions/download-artifact@v4
with:
name: data
path: ~/.cache/mhkit
- name: Install testing dependencies
shell: bash -l {0}
run: |
conda activate mhkit-env
conda install -y pytest coverage coveralls

- name: Install mhkit
shell: bash -l {0}
run: |
conda activate mhkit-env
pip install -e . --no-deps

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

Expand Down Expand Up @@ -317,11 +338,23 @@ jobs:
python-version: ${{ matrix.python-version }}
use-only-tar-bz2: false

- name: Setup Conda environment
- name: Create MHKiT Conda environment
shell: bash -l {0}
run: |
conda env create -f environment.yml
conda activate mhkit-env

- name: Install testing dependencies
shell: bash -l {0}
run: |
conda install -c conda-forge pytest coverage=7.5.0 coveralls --strict-channel-priority
pip install -e . --force-reinstall
conda activate mhkit-env
conda install -y pytest coverage coveralls

- name: Install mhkit
shell: bash -l {0}
run: |
conda activate mhkit-env
pip install -e . --no-deps

- name: Download Wave Hindcast data from artifact
uses: actions/download-artifact@v4
Expand All @@ -342,9 +375,10 @@ jobs:
mv ~/.cache/mhkit/wind-hindcast/hindcast/* ~/.cache/mhkit/hindcast/
shell: bash

- name: Install MHKiT and run pytest
- name: Run hindcast pytest
shell: bash -l {0}
run: |
conda activate mhkit-env
coverage run --rcfile=.github/workflows/.coveragehindcastrc -m pytest -c .github/workflows/pytest-hindcast.ini
coverage lcov

Expand Down Expand Up @@ -425,21 +459,23 @@ jobs:
activate-environment: TESTconda
use-only-tar-bz2: true

- name: Install dependencies
- name: Create MHKiT Conda environment
shell: bash -l {0}
run: |
conda install numpy cython pip hdf5 libnetcdf cftime netcdf4 --strict-channel-priority
pip install -e . --force-reinstall
python -m pip install --upgrade pip wheel
pip install nbval jupyter
pip install utm folium
conda env create -f environment.yml
conda activate mhkit-env

- name: Ensure Conda environment is activated
- name: Install notebook testing dependencies
shell: bash -l {0}
run: |
echo "source ~/miniconda3/etc/profile.d/conda.sh" >> ~/.bashrc
echo "conda activate TESTconda" >> ~/.bashrc
source ~/.bashrc
conda activate mhkit-env
conda install -y pytest coverage coveralls nbval jupyter utm folium

- name: Install mhkit
shell: bash -l {0}
run: |
conda activate mhkit-env
pip install -e . --no-deps

- name: Download non-hindcast data
uses: actions/download-artifact@v4
Expand Down Expand Up @@ -477,6 +513,7 @@ jobs:
- name: Run notebook
shell: bash -l {0}
run: |
conda activate mhkit-env
if [[ "${{ matrix.notebook }}" == "examples/metocean_example.ipynb" || "${{ matrix.notebook }}" == "examples/WPTO_hindcast_example.ipynb" ]]; then
if [[ "${{ needs.check-changes.outputs.should-run-hindcast }}" == 'true' ]]; then
jupyter nbconvert --to notebook --execute --inplace --ExecutePreprocessor.timeout=${{ matrix.timeout }} "${{ matrix.notebook }}"
Expand Down

0 comments on commit 03c9552

Please sign in to comment.