Skip to content

Commit

Permalink
Merge pull request #140 from MODFLOW-USGS/v1.4.0
Browse files Browse the repository at this point in the history
Release 1.4.0
  • Loading branch information
wpbonelli authored Feb 19, 2024
2 parents 2e9adad + d05f607 commit 5182e3b
Show file tree
Hide file tree
Showing 26 changed files with 283 additions and 268 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ on:
push:
paths-ignore:
- '**.md'
- '.github/workflows/release.yml'
- '.gitignore'
pull_request:
branches:
- main
- develop
paths-ignore:
- '**.md'
- '.github/workflows/release.yml'
- '.gitignore'
jobs:
lint:
name: Lint
Expand Down Expand Up @@ -150,8 +154,8 @@ jobs:
- name: Build modflow6 example models
if: steps.cache-examples.outputs.cache-hit != 'true'
working-directory: modflow6-examples/etc
run: python ci_build_files.py
working-directory: modflow6-examples/autotest
run: pytest -v -n auto test_scripts.py --init

- name: Run local tests
working-directory: modflow-devtools/autotest
Expand Down
67 changes: 1 addition & 66 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ jobs:
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 patch version number.
The release can be approved by merging this pull request into `main`. This will trigger a job to publish the release to PyPI.
## Changelog
Expand Down Expand Up @@ -200,68 +200,3 @@ jobs:

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

reset:
name: Draft reset PR
if: ${{ github.event_name == 'release' }}
runs-on: ubuntu-22.04
permissions:
contents: write
pull-requests: write
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
cache: 'pip'
cache-dependency-path: pyproject.toml

- name: Install Python dependencies
run: |
pip install --upgrade pip
pip install .
pip install ".[lint, test]"
- name: Get release tag
uses: oprypin/find-latest-tag@v1
id: latest_tag
with:
repository: ${{ github.repository }}
releases-only: true

- name: Draft pull request
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
# create reset branch from main
reset_branch="post-release-${{ steps.latest_tag.outputs.tag }}-reset"
git switch -c $reset_branch
# increment minor version
major_version=$(echo "${{ steps.latest_tag.outputs.tag }}" | cut -d. -f1)
minor_version=$(echo "${{ steps.latest_tag.outputs.tag }}" | cut -d. -f2)
version="$major_version.$((minor_version + 1)).0.dev0"
python scripts/update_version.py -v "$version"
python scripts/lint.py
# commit and push reset branch
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): update to development version $version"
git push -u origin $reset_branch
# create PR into develop
body='
# Reinitialize for development
Updates the `develop` branch from `main` following a successful release. Increments the patch version number.
'
gh pr create -B "develop" -H "$reset_branch" --title "Reinitialize develop branch" --draft --body "$body"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,5 @@ app
# in case developer installs modflow executables in the project root
bin

**.DS_Store
data_backup
18 changes: 18 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
### Version 1.4.0

#### New features

* [feat(Executables)](https://github.com/MODFLOW-USGS/modflow-devtools/commit/3129417dae2de3aece80c8056a2ac50eede56b91): Support collection-style membership test (#131). Committed by wpbonelli on 2023-12-18.
* [feat](https://github.com/MODFLOW-USGS/modflow-devtools/commit/6728859a984a3080f8fd4f1135de36bc17454098): Add latex and plot style utilities (#132). Committed by wpbonelli on 2024-01-09.
* [feat(misc)](https://github.com/MODFLOW-USGS/modflow-devtools/commit/a9b801932866a26a996ed3a45f16048b15246472): Parse literals from environment variables (#135). Committed by wpbonelli on 2024-01-21.
* [feat(ostags)](https://github.com/MODFLOW-USGS/modflow-devtools/commit/0ad10751ea6ce752e59d83e8cd6275906d73fa70): Apple silicon (#139). Committed by wpbonelli on 2024-02-18.

#### Bug fixes

* [fix](https://github.com/MODFLOW-USGS/modflow-devtools/commit/fd215000c6215b0891e78ee621e40abb2a20b28a): Drop plot styles (already in flopy) (#133). Committed by wpbonelli on 2024-01-09.

#### Refactoring

* [refactor](https://github.com/MODFLOW-USGS/modflow-devtools/commit/9356e067ea813aeeeda2582cf7ec174c11d80159): Remove executables module/class (#136). Committed by wpbonelli on 2024-01-25.
* [refactor(fixtures)](https://github.com/MODFLOW-USGS/modflow-devtools/commit/613ad010ff6fc782f231b7fa21d1cc660732e7be): Support pytest>=8, drop pytest-cases dependency (#137). Committed by wpbonelli on 2024-01-31.

### Version 1.3.1

#### Refactoring
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ Python development tools for MODFLOW 6.

This is a small toolkit for developing MODFLOW 6, FloPy, and related projects. It includes standalone utilities and optional [Pytest](https://github.com/pytest-dev/pytest) extensions.

The former include a very minimal GitHub API client for retrieving release information and downloading assets, a `ZipFile` subclass that [preserves file permissions](https://stackoverflow.com/questions/39296101/python-zipfile-removes-execute-permissions-from-binaries) (workaround for [Python #15795](https://bugs.python.org/issue15795)), and other release/distribution-related tools.
Utilities include:

* a minimal GitHub API client for retrieving release information and downloading assets
* a `ZipFile` subclass that [preserves file permissions](https://stackoverflow.com/questions/39296101/python-zipfile-removes-execute-permissions-from-binaries) (workaround for [Python #15795](https://bugs.python.org/issue15795))
* other release/distribution-related tools

Pytest features include:

Expand Down
28 changes: 0 additions & 28 deletions autotest/test_executables.py

This file was deleted.

2 changes: 1 addition & 1 deletion autotest/test_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def test_keep_session_scoped_tmpdir(tmp_path, arg, request):
]
assert pytest.main(args) == ExitCode.OK
assert Path(
tmp_path / f"{request.session.name}0" / test_keep_fname
tmp_path / f"{request.config.rootpath.name}0" / test_keep_fname
).is_file()


Expand Down
Empty file added autotest/test_latex.py
Empty file.
23 changes: 23 additions & 0 deletions autotest/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import pytest

from modflow_devtools.misc import (
get_env,
get_model_paths,
get_namefile_paths,
get_packages,
Expand Down Expand Up @@ -280,3 +281,25 @@ def sleep1dec():
cap = capfd.readouterr()
print(cap.out)
assert re.match(r"sleep1dec took \d+\.\d+ ms", cap.out)


def test_get_env():
assert get_env("NO_VALUE") is None

with set_env(TEST_VALUE=str(True)):
assert get_env("NO_VALUE", True) == True
assert get_env("TEST_VALUE") == True
assert get_env("TEST_VALUE", default=False) == True
assert get_env("TEST_VALUE", default=1) == 1

with set_env(TEST_VALUE=str(1)):
assert get_env("NO_VALUE", 1) == 1
assert get_env("TEST_VALUE") == 1
assert get_env("TEST_VALUE", default=2) == 1
assert get_env("TEST_VALUE", default=2.1) == 2.1

with set_env(TEST_VALUE=str(1.1)):
assert get_env("NO_VALUE", 1.1) == 1.1
assert get_env("TEST_VALUE") == 1.1
assert get_env("TEST_VALUE", default=2.1) == 1.1
assert get_env("TEST_VALUE", default=False) == False
17 changes: 9 additions & 8 deletions autotest/test_ostags.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
from platform import system
from platform import processor, system

import pytest

from modflow_devtools.ostags import (
OSTag,
convert_ostag,
get_binary_suffixes,
get_github_ostag,
get_modflow_ostag,
)

_system = system()
_processor = processor()


def test_get_modflow_ostag():
Expand All @@ -19,7 +20,7 @@ def test_get_modflow_ostag():
elif _system == "Linux":
assert t == "linux"
elif _system == "Darwin":
assert t == "mac"
assert t == "macarm" if _processor == "arm" else "mac"
else:
pytest.skip(reason="Unsupported platform")

Expand All @@ -35,17 +36,17 @@ def test_get_github_ostag():


@pytest.mark.parametrize(
"cvt,tag,exp",
"map,tag,exp",
[
("py2mf", "Windows", "win64"),
("mf2py", "win64", "Windows"),
("py2mf", "Darwin", "mac"),
("py2mf", "Darwin", "macarm" if _processor == "arm" else "mac"),
("mf2py", "mac", "Darwin"),
("py2mf", "Linux", "linux"),
("mf2py", "linux", "Linux"),
("gh2mf", "Windows", "win64"),
("mf2gh", "win64", "Windows"),
("gh2mf", "macOS", "mac"),
("gh2mf", "macOS", "macarm" if _processor == "arm" else "mac"),
("mf2gh", "mac", "macOS"),
("gh2mf", "Linux", "linux"),
("mf2gh", "linux", "Linux"),
Expand All @@ -57,8 +58,8 @@ def test_get_github_ostag():
("gh2py", "Linux", "Linux"),
],
)
def test_ostag_convert(cvt, tag, exp):
assert OSTag.convert(tag, cvt) == exp
def test_convert_ostag(map, tag, exp):
assert convert_ostag(tag, map) == exp


def test_get_binary_suffixes():
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

project = "modflow-devtools"
author = "MODFLOW Team"
release = "1.3.1"
release = "1.4.0"

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ The `modflow-devtools` package provides a set of tools for developing and testin
:maxdepth: 2
:caption: Test fixtures

md/executables.md
md/fixtures.md
md/markers.md

Expand All @@ -29,6 +28,7 @@ The `modflow-devtools` package provides a set of tools for developing and testin
:caption: Miscellaneous

md/download.md
md/latex.md
md/ostags.md
md/zip.md
md/timed.md
Expand Down
33 changes: 0 additions & 33 deletions docs/md/executables.md

This file was deleted.

2 changes: 1 addition & 1 deletion docs/md/fixtures.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def test_example_scenario(tmp_path, example_scenario):
# ...
```

**Note**: example models must first be built by running the `ci_build_files.py` script in `modflow6-examples/etc` before running tests using the `example_scenario` fixture. See the [install docs](https://modflow-devtools.readthedocs.io/en/latest/md/install.html) for more info.
**Note**: example models must first be built by running `pytest -v -n auto test_scripts.py --init` in `modflow6-examples/autotest` before running tests using the `example_scenario` fixture. See the [install docs](https://modflow-devtools.readthedocs.io/en/latest/md/install.html) for more info.

### Filtering

Expand Down
6 changes: 3 additions & 3 deletions docs/md/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ cd modflow6-examples/etc
pip install -r requirements.pip.txt
```

Then, still from the `etc` folder, run:
Then, from the `autotest` folder, run:

```shell
python ci_build_files.py
pytest -v -n auto test_scripts.py --init
```

This will build the examples for subsequent use by the tests.
This will build the examples for subsequent use by the tests. To save time, models will not be run — to run the models too, omit `--init`.
3 changes: 3 additions & 0 deletions docs/md/latex.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# LaTeX utilities

The `modflow_devtools.latex` module provides utility functions for building LaTeX tables from arrays.
5 changes: 3 additions & 2 deletions docs/md/ostags.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Python3's `platform.system()` returns "Linux", "Darwin", and "Windows", respecti

GitHub Actions (e.g. `runner.os` context) use "Linux", "macOS" and "Windows".

MODFLOW 6 release asset names end with "linux", "mac" or "win64".
MODFLOW 6 release asset names end with "linux", "mac" (Intel), "macarm", "win32", or "win64".

## Getting tags

Expand All @@ -37,7 +37,8 @@ Conversion functions are available for each direction:
Alternatively:

```python
OSTag.convert(platform.system(), "py2mf")
convert_ostag(platform.system(), "py2mf") # prints linux, mac, macarm, win32, or win64
convert_ostag(platform.system(), "py2mf") # prints Linux, macOS, or Windows
```

The second argument specifies the mapping in format `<source>2<target>`, where `<source>` and `<target>` may take values `py`, `mf`, or `gh`.
Expand Down
4 changes: 2 additions & 2 deletions modflow_devtools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
__author__ = "Joseph D. Hughes"
__date__ = "Nov 21, 2023"
__version__ = "1.3.1"
__date__ = "Feb 19, 2024"
__version__ = "1.4.0"
__maintainer__ = "Joseph D. Hughes"
__email__ = "jdhughes@usgs.gov"
__status__ = "Production"
Expand Down
Loading

0 comments on commit 5182e3b

Please sign in to comment.