Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
3d309c2
test with python 3.12, drop 3.9
mcflugen Oct 10, 2024
3b22003
add python 3.12 to noxfile, drop 3.9
mcflugen Oct 10, 2024
a5e1529
remove ecmwflibs from requirements
mcflugen Oct 10, 2024
6809e25
change content-type to sausage-case
mcflugen Oct 10, 2024
7ea022e
update actions versions in test workflow
mcflugen Oct 10, 2024
2610ea4
update actions version in lint workflow
mcflugen Oct 10, 2024
ce8ea9a
update actions versions in docs workflow
mcflugen Oct 10, 2024
4c6ba82
mark url-tests as xfail; hurricane helene is causing disruption
mcflugen Oct 10, 2024
975e1a7
rename tests to have _test suffix
mcflugen Oct 10, 2024
f64d802
add hook to ensure proper test file naming
mcflugen Oct 10, 2024
a2e39d0
remove linter, use pre-commit.ci instead
mcflugen Oct 10, 2024
3768e5f
add build-sdist job to test workflow
mcflugen Oct 10, 2024
eb14ad8
set venv backend from mamba to conda
mcflugen Oct 10, 2024
46a7734
split pip and conda tests into separate jobs
mcflugen Oct 10, 2024
1003efe
add check-tag job to see if we're on a release/prerelease tag
mcflugen Oct 10, 2024
e28d8a7
force a python version when testing with pip
mcflugen Oct 10, 2024
6314c78
run only on external prs
mcflugen Oct 10, 2024
cff5d24
remove findlibs requirement from conda
mcflugen Oct 10, 2024
8ff3b8b
pip-install ecmvflibs if on windows
mcflugen Oct 10, 2024
6a490ce
disable windows tests with pip
mcflugen Oct 10, 2024
41d8d67
run check-tag before doing anything else
mcflugen Oct 10, 2024
b7f5521
download sdist artifacts for testing
mcflugen Oct 10, 2024
232d74b
add argument for noxfile to install from an sdist
mcflugen Oct 10, 2024
eb067f0
test the built sdist
mcflugen Oct 10, 2024
fe5b916
add a job to build the docs
mcflugen Oct 10, 2024
8166d39
remove the docs workflow
mcflugen Oct 10, 2024
a45b217
add a publish job that upload to pypi/testpypi of a version tag
mcflugen Oct 10, 2024
934c7a9
require an older towncrier
mcflugen Oct 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 0 additions & 53 deletions .github/workflows/docs.yml

This file was deleted.

27 changes: 0 additions & 27 deletions .github/workflows/flake8.yml

This file was deleted.

154 changes: 135 additions & 19 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,84 @@ name: Test
on: [push, pull_request]

jobs:
build-and-test:
name: Run the tests
# We want to run on external PRs, but not on our own internal PRs as they'll be run
# by the push to the branch. Without this if check, checks are duplicated since
# internal PRs match both the push and pull_request events.
if:
github.event_name == 'push' || github.event.pull_request.head.repo.full_name !=
github.repository
check-tag:
# Run on external PRs, but not on internal PRs, to avoid duplicate runs
if: |
github.event_name == 'push' ||
github.event.pull_request.head.repo.full_name != github.repository

runs-on: ubuntu-latest
outputs:
publish_url: ${{ steps.check-publish.outputs.publish_url }}

steps:
- name: Check if this is a release/prerelease
id: check-publish
run: |
tag_name="${GITHUB_REF#refs/tags/}"
if [[ "$tag_name" =~ ^v[0-9]+\.[0-9]+\.[0-9]+[ab][0-9]+$ ]]; then
publish_url="https://test.pypi.org/legacy/"
elif [[ "$tag_name" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
publish_url="https://upload.pypi.org/legacy/"
else
publish_url="none"
fi
echo "publish_url=$publish_url" >> "$GITHUB_OUTPUT"
echo "tag_name=$tag_name"
echo "publish_url=$publish_url"

build-sdist:
name: Build source distribution
needs: check-tag
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Build sdist
run: pipx run build --sdist

- uses: actions/upload-artifact@v4
with:
name: build-sdist
path: ${{ github.workspace }}/dist/*.tar.gz

test-with-pip:
name: Test with pip
needs: build-sdist
runs-on: ${{ matrix.os }}

defaults:
run:
shell: bash -l {0}

strategy:
matrix:
os: [ubuntu-latest, macos-latest]
python-version: ["3.10", "3.11", "3.12"]
fail-fast: false

steps:
- uses: actions/checkout@v4

- name: Use Python ${{ matrix.python-version}}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- uses: actions/download-artifact@v4
with:
pattern: "build-*"
merge-multiple: true
path: ${{ github.workspace }}/dist

- name: Test package
run: |
pip install nox
nox --verbose --force-python=${{ matrix.python-version }} -s test-with-pip -- dist/*.tar.gz

test-with-conda:
name: Test with conda
needs: build-sdist
runs-on: ${{ matrix.os }}

defaults:
Expand All @@ -21,31 +90,78 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.9", "3.10", "3.11"]
installer: ["pip", "conda"]
exclude:
- python-version: "3.11"
installer: "pip"
- os: windows-latest
installer: "pip"
python-version: ["3.10", "3.11", "3.12"]
fail-fast: false

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: conda-incubator/setup-miniconda@v2
- uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
channels: conda-forge
channel-priority: true

- uses: actions/download-artifact@v4
with:
pattern: "build-*"
merge-multiple: true
path: ${{ github.workspace }}/dist

- name: Show conda installation info
run: |
conda list
conda info
conda install mamba

- name: Test package
run: |
pip install nox
nox --verbose --force-python=${{ matrix.python-version }} -s test-with-${{ matrix.installer }}
nox --verbose --force-python=${{ matrix.python-version }} -s test-with-conda -- dist/*.tar.gz

build-docs:
name: Build the docs
needs: check-tag
runs-on: ubuntu-latest

defaults:
run:
shell: bash -l {0}

steps:
- uses: actions/checkout@v4
- name: Use Python
uses: actions/setup-python@v5
with:
python-version: 3.12

- name: Build documentation
run: |
pip install nox
nox -s docs

publish:
needs:
- check-tag
- test-with-pip
- test-with-conda
- build-docs
name: "Publish to PyPI/TestPyPI"
runs-on: ubuntu-latest

permissions:
id-token: write

steps:
- uses: actions/download-artifact@v4
with:
pattern: "build-*"
merge-multiple: true
path: ${{ github.workspace }}/dist
- uses: pypa/gh-action-pypi-publish@release/v1
if: ${{ startsWith(needs.check-tag.outputs.publish_url, 'http') }}
with:
repository-url: ${{ needs.check-tag.outputs.publish_url }}
skip-existing: true
print-hash: true
verify-metadata: false
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ repos:
- id: forbid-new-submodules
- id: mixed-line-ending
- id: trailing-whitespace
- id: name-tests-test

- repo: https://github.com/regebro/pyroma
rev: "4.2"
Expand Down
1 change: 1 addition & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ sphinx==7.0.1
sphinx-copybutton==0.5.1
sphinx-inline-tabs==2022.1.2b11
sphinxcontrib-towncrier==0.3.2a0
towncrier==23.11.0
30 changes: 26 additions & 4 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,53 @@
import os
import pathlib
import shutil
import sys
from itertools import chain

import nox

ROOT = pathlib.Path(__file__).parent


@nox.session(name="test-with-pip", python=["3.9", "3.10", "3.11"])
@nox.session(name="test-with-pip", python=["3.10", "3.11", "3.12"])
def test_with_pip(session: nox.Session) -> None:
"""Run the tests."""
first_arg = session.posargs[0] if session.posargs else None

session.install("-r", "requirements-testing.in")
session.install(".")
if sys.platform.startswith("win"):
session.install("ecmwflibs")

if first_arg:
if os.path.isfile(first_arg):
session.install(first_arg)
else:
session.error("path must be a source distribution")
else:
session.install(".")

session.run("pytest", "--cov=src/bmi_wavewatch3", "-vvv")
session.run("coverage", "report", "--ignore-errors", "--show-missing")
# "--fail-under=100",


@nox.session(
name="test-with-conda", venv_backend="mamba", python=["3.9", "3.10", "3.11"]
name="test-with-conda", venv_backend="conda", python=["3.10", "3.11", "3.12"]
)
def test_with_conda(session: nox.Session) -> None:
"""Run the tests."""
first_arg = session.posargs[0] if session.posargs else None

session.conda_install("--file=requirements-testing.in")
session.conda_install("--file=requirements-conda.in")
session.install(".", "--no-deps")

if first_arg:
if os.path.isfile(first_arg):
session.install(first_arg, "--no-deps")
else:
session.error("path must be a source distribution")
else:
session.install(".", "--no-deps")

session.run("pytest", "--cov=src/bmi_wavewatch3", "-vvv")
session.run("coverage", "report", "--ignore-errors", "--show-missing")
Expand Down
8 changes: 6 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ dependencies = [
"tomli",
"tqdm",
"xarray",
"ecmwflibs",
]
dynamic = ["readme", "version"]

Expand All @@ -64,9 +63,14 @@ ww3 = "bmi_wavewatch3.cli:ww3"
channels = ["conda-forge", "defaults"]
platforms = ["osx-arm64", "linux-64", "osx-64", "win-64"]

# [tool.setuptools]
# py-modules = []

[tool.setuptools.packages.find]
where = ["src"]

[tool.setuptools.dynamic]
readme = {file = ["README.md", "AUTHORS.md", "CHANGES.md"], content_type="text/markdown"}
readme = {file = ["README.md", "AUTHORS.md", "CHANGES.md"], content-type="text/markdown"}
version = {attr = "bmi_wavewatch3._version.__version__"}

[tool.pytest.ini_options]
Expand Down
1 change: 0 additions & 1 deletion requirements-conda.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ bmipy
cfgrib
click
dask
findlibs
matplotlib
rich-click
tomli
Expand Down
1 change: 0 additions & 1 deletion requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ bmipy
cfgrib
click
dask
ecmwflibs
matplotlib
rich-click
tomli
Expand Down
File renamed without changes.
3 changes: 3 additions & 0 deletions tests/test_url.py → tests/url_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ def test_url(source, grid, quantity):
assert f"{grid}.{quantity}.{date.year}{date.month:02}.grb" in url.filename


# NOTE: these tests seem to be flaky because of disruption caused by
# Hurricane Helene
@pytest.mark.xfail
@pytest.mark.parametrize(
"source,grid,quantity",
[
Expand Down
File renamed without changes.