Skip to content

Commit

Permalink
Merge pull request #40 from MODFLOW-USGS/v0.2.0
Browse files Browse the repository at this point in the history
Release 0.2.0
  • Loading branch information
wpbonelli authored Feb 8, 2024
2 parents 400780e + 9de3c7f commit 31e90fd
Show file tree
Hide file tree
Showing 24 changed files with 819 additions and 1,411 deletions.
56 changes: 48 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,58 @@ jobs:
- name: Install modflow executables
uses: modflowpy/install-modflow-action@v1
with:
path: ~/work/modflowapi/modflowapi/autotest
path: ${{ github.workspace }}/autotest
repo: modflow6-nightly-build

- name: Run autotests
working-directory: ./autotest
shell: bash -l {0}
run: pytest -v -n auto -m "not mf6"

autotest_preidm_extensions:
name: modflowapi pre-idm extensions autotests
needs: lint
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
python-version: [ 3.8, 3.9, "3.10", "3.11" ]
defaults:
run:
shell: bash

steps:
# check out repo
- name: Checkout repo
uses: actions/checkout@v3

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: pyproject.toml

- name: Install Python dependencies
run: |
# chmod a+x libmf6*
pytest -n auto -m "not mf6"
python -m pip install --upgrade pip
pip install git+https://[email protected]/Deltares/xmipy@develop
pip install git+https://[email protected]/MODFLOW-USGS/modflow-devtools@develop
pip install .[test]
- name: Install modflow executables
uses: modflowpy/install-modflow-action@v1
with:
path: ${{ github.workspace }}/autotest
repo: executables
tag: "14.0"

- name: Run autotests
working-directory: ./autotest
shell: bash -l {0}
run: pytest -v -n auto -m "not mf6"

autotest_mf6_examples:
name: modflowapi mf6 examples autotests
needs: lint
Expand Down Expand Up @@ -173,12 +215,10 @@ jobs:
- name: Install modflow executables
uses: modflowpy/install-modflow-action@v1
with:
path: ~/work/modflowapi/modflowapi/autotest
path: ${{ github.workspace }}/autotest
repo: modflow6-nightly-build

- name: Run autotests
working-directory: ./autotest
shell: bash -l {0}
run: |
# chmod a+x libmf6*
pytest -n auto -m "mf6 and not extensions"
run: pytest -v -n auto -m "mf6 and not extensions"
207 changes: 207 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
name: Release
on:
push:
branches:
- main
- v[0-9]+.[0-9]+.[0-9]+*
release:
types:
- published
jobs:
prep:
name: Prepare release
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' && github.ref_name != 'main' }}
permissions:
contents: write
pull-requests: write
defaults:
run:
shell: bash
steps:

- name: Checkout release branch
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.8
cache: 'pip'
cache-dependency-path: pyproject.toml

- name: Install Python dependencies
run: |
pip install --upgrade pip
pip install build twine
pip install .
pip install ".[lint, test]"
- name: Update version
id: version
run: |
ref="${{ github.ref_name }}"
version="${ref#"v"}"
python scripts/update_version.py -v "$version"
python -c "import modflowapi; print('Version: ', modflowapi.__version__)"
echo "version=$version" >> $GITHUB_OUTPUT
- name: Touch changelog
run: touch HISTORY.md

- name: Generate changelog
id: cliff
uses: orhun/git-cliff-action@v1
with:
config: cliff.toml
args: --verbose --unreleased --tag ${{ steps.version.outputs.version }}
env:
OUTPUT: CHANGELOG.md

- name: Update changelog
run: |
# substitute full group names
sed -i 's/#### Ci/#### Continuous integration/' CHANGELOG.md
sed -i 's/#### Feat/#### New features/' CHANGELOG.md
sed -i 's/#### Fix/#### Bug fixes/' CHANGELOG.md
sed -i 's/#### Refactor/#### Refactoring/' CHANGELOG.md
sed -i 's/#### Test/#### Testing/' CHANGELOG.md
# prepend release changelog to cumulative changelog
clog="HISTORY.md"
temp="temp.md"
echo "$(tail -n +2 $clog)" > $clog
cat CHANGELOG.md $clog > $temp
sudo mv $temp $clog
sed -i '1i # Changelog' $clog
- name: Upload changelog
uses: actions/upload-artifact@v3
with:
name: changelog
path: CHANGELOG.md

- name: Format Python files
run: python scripts/pull_request_prepare.py

- name: Push release branch
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
ver="${{ steps.version.outputs.version }}"
changelog=$(cat CHANGELOG.md | grep -v "### Version $ver")
# remove this release's changelog so we don't commit it
# the changes have already been prepended to HISTORY.md
rm -f CHANGELOG.md
# commit and push changes
git config core.sharedRepository true
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add -A
git commit -m "ci(release): set version to ${{ steps.version.outputs.version }}, update changelog"
git push origin "${{ github.ref_name }}"
title="Release $ver"
body='
# Release '$ver'
The release can be approved by merging this pull request into `main`. This will trigger jobs to publish the release to PyPI and reset `develop` from `main`, incrementing the minor version number.
## Changelog
'$changelog'
'
gh pr create -B "main" -H "${{ github.ref_name }}" --title "$title" --draft --body "$body"
release:
name: Draft release
# runs only when changes are merged to main
if: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:

- name: Checkout repo
uses: actions/checkout@v3
with:
ref: main

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.8

- name: Install Python dependencies
run: |
pip install --upgrade pip
pip install .
pip install ".[test]"
# actions/download-artifact won't look at previous workflow runs but we need to in order to get changelog
- name: Download artifacts
uses: dawidd6/action-download-artifact@v2

- name: Draft release
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
version=$(python scripts/update_version.py -g)
title="modflowapi $version"
notes=$(cat "changelog/CHANGELOG.md" | grep -v "### Version $version")
gh release create "$version" \
--target main \
--title "$title" \
--notes "$notes" \
--draft \
--latest
publish:
name: Publish package
# runs only after release is published (manually promoted from draft)
if: github.event_name == 'release' && github.repository_owner == 'MODFLOW-USGS'
runs-on: ubuntu-22.04
permissions:
contents: write
pull-requests: write
id-token: write
environment: # requires a 'release' environment in repo settings
name: release
url: https://pypi.org/p/modflowapi
steps:

- name: Checkout main branch
uses: actions/checkout@v3
with:
ref: main

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.8

- name: Install Python dependencies
run: |
pip install --upgrade pip
pip install build twine
pip install .
- name: Build package
run: python -m build

- name: Check package
run: twine check --strict dist/*

- name: Upload package
uses: actions/upload-artifact@v4
with:
name: dist
path: dist

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ message: If you use this software, please cite both the article from preferred-c
and the software itself.
type: software
title: MODFLOW API
version: 0.1.0
version: 0.2.0
date-released: '2023-04-19'
abstract: An extension to xmipy for the MODFLOW API.
repository-artifact: https://pypi.org/project/modflowapi
Expand Down
67 changes: 67 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Changelog
### Version 0.2.0

#### Refactoring

* [refactor(rhs, hcof)](https://github.com/MODFLOW-USGS/modflowapi/commit/c0f681c5b7525388ead4df8c6363c1b4514d6de6): Updates to allow setting values when rhs and hcof have not yet had pointers set.. Committed by Joshua Larsen on 2023-04-28.
* [refactor(Quickstart.ipynb)](https://github.com/MODFLOW-USGS/modflowapi/commit/3b6675aa687f5af01813abfdb143c7ddd4343646): Fix error in callback_function. Committed by Joshua Larsen on 2023-07-17.
* [refactor(rhs, hcof)](https://github.com/MODFLOW-USGS/modflowapi/commit/ce4e50286d66da51c6b05f0de29c7c646344f6ce): Allow setting rhs and hcof when pointers have not been previously set. Committed by Joshua Larsen on 2023-07-17.
* [refactor](https://github.com/MODFLOW-USGS/modflowapi/commit/e693282611d5863bafeece362230a4aadd02311f): Update libmf6 path handling (#27). Committed by w-bonelli on 2023-08-03.
* [refactor(_ptr_to_recarray)](https://github.com/MODFLOW-USGS/modflowapi/commit/5a631592f2da57bf1564c263e9602c46e5a5a50c): Slice pointers prior to setting data to recarray. Committed by Joshua Larsen on 2023-08-08.
* [refactor(_ptr_to_recarray)](https://github.com/MODFLOW-USGS/modflowapi/commit/959fe31abda263a52d01262af7dc4c2a878eadb5): Slice pointers prior to setting data to recarray. Committed by Joshua Larsen on 2023-08-08.
* [refactor(extensions)](https://github.com/MODFLOW-USGS/modflowapi/commit/c97339d06e7386055e486f6354825ec15cea4638): Add support for IDM changes. Committed by Joshua Larsen on 2023-12-21.
* [refactor(extensions)](https://github.com/MODFLOW-USGS/modflowapi/commit/de0aff9c21d5d925235f306fd2b3d148c3281efa): Add support for IDM changes. Committed by Joshua Larsen on 2023-12-21.

### Version 0.1.0

* Fix typo in README (https://github.com/MODFLOW-USGS/modflowapi/pull/4)
* modflowapi interface (https://github.com/MODFLOW-USGS/modflowapi/pull/8)
* update package: manual variable address assembly updated to use xmipy get_variable_addr()
* update additional manual variable address assembly statements
* Refactor code and added functionality:
* add stress_period_start, stress_period_end Callbacks
* fix ApiModel __repr__
* added Exchanges, TDIS, ATS, and SLN support
* added ScalarInput and ScalarPackage support
* update autotests
* added parallel testing support through pytest-xdist
* updated markers and split the extensions tests from the mf6 examples tests
* added a test for ATS
* update setup.cfg
* update ci.yml
* update(ListInput): add auxvar to stress_period_data when auxiliary variables are used
* Allow None to be passed to stress_period_data.values to disable stresses for a package
* updates: ApiModel, ApiSimulation, run_simulation
* added a `totim` property on `ApiSimulation` and `ApiModel`
* added docstrings to ApiModel property methods
* updated termination message in run_simulation
* added a finalize callback to Callbacks and run_simulation
* add support for AUXNAME_CST
* add(Head Monitor Example): Add a head monitor example application
* ApiModel: adjust X based on nodetouser
* ApiPackage: enforce lower cased variable names in get_advanced_var
* ArrayPointer: trap for arrays that are not adjusted by reduced node numbers (ex. idomain)
* update setup.cfg
* try reformatting the xmipy installation instructions
* fix(get value): fixed error handling when modflowapi fails to get a pointer to a value from the API (https://github.com/MODFLOW-USGS/modflowapi/pull/9)
Co-authored-by: scottrp <[email protected]>
* update(rhs, hcof, AdvancedInput): bug fixes for setting variable values for advanced inputs
* update rhs and hcof to copy values to pointer instead of overwriting the pointer
* add a check for AdvancedInput variables that do not have pointer support in xmipy
* update setting routine for AdvancedInput
* refactor(EOL): change CRLF to LF line endings for source files (https://github.com/MODFLOW-USGS/modflowapi/pull/12)
* Use pyproject.toml for project metadata, add citation info (https://github.com/MODFLOW-USGS/modflowapi/pull/11)
* add(test_rhs_hcof_advanced): add additional test (https://github.com/MODFLOW-USGS/modflowapi/pull/13)
* added test for getting and setting rhs, hcof, and advanced variable values
* update project to use unix line separators
* use np.testing.assert_allclose() instead of AssertionError
* Add missing RIV support to modflowapi (https://github.com/MODFLOW-USGS/modflowapi/pull/16)
* add(test_rhs_hcof_advanced): add additional test
* added test for getting and setting rhs, hcof, and advanced variable values
* update project to use unix line separators
* use np.testing.assert_allclose() instead of AssertionError
* Add missing riv package to modflowapi

### Version 0.0.1

Initial release.
2 changes: 1 addition & 1 deletion autotest/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# init file for pytest
# init file for pytest
1 change: 1 addition & 0 deletions autotest/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def get_mf6_examples_path() -> Path:
finally:
__mf6_examples_lock.release()


def is_nested(namfile) -> bool:
p = Path(namfile)
if not p.is_file() or not p.name.endswith(".nam"):
Expand Down
Loading

0 comments on commit 31e90fd

Please sign in to comment.