diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 57c3e03eb..fdd4a1651 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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 @@ -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} @@ -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 @@ -195,21 +195,16 @@ 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 @@ -217,19 +212,19 @@ jobs: 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 }} @@ -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 @@ -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 }} @@ -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 diff --git a/environment.yml b/environment.yml new file mode 100644 index 000000000..92b603f09 --- /dev/null +++ b/environment.yml @@ -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