Document architecture baseline and add guardrails (#349) #87
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This workflow will install Python dependencies, run tests and lint with a variety of Python versions | |
| # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | |
| name: Python package | |
| on: | |
| push: | |
| branches: ['main'] | |
| pull_request: | |
| branches: ['main'] | |
| jobs: | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Set up Python 3.14 | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.14" | |
| cache: "pip" | |
| - name: Install ruff | |
| # Keep this version aligned with the ruff-pre-commit revision. | |
| run: pip install ruff==0.16.1 | |
| - name: Lint with ruff | |
| run: | | |
| ruff check . --output-format=github | |
| ruff format --check . | |
| package-artifact: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Set up Python 3.13 | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.13" | |
| cache: "pip" | |
| - name: Build wheel | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip wheel --no-deps --wheel-dir wheelhouse . | |
| - name: Smoke test installed wheel outside the checkout | |
| run: | | |
| venv="$RUNNER_TEMP/dataretrieval-wheel-smoke" | |
| python -m venv "$venv" | |
| "$venv/bin/python" -m pip install "$GITHUB_WORKSPACE"/wheelhouse/*.whl | |
| cd "$RUNNER_TEMP" | |
| "$venv/bin/python" -I - <<'PY' | |
| import importlib.util | |
| import os | |
| from importlib.resources import files | |
| from pathlib import Path | |
| import dataretrieval | |
| from dataretrieval import ngwmn, waterdata, wateruse | |
| from dataretrieval.ogc import engine | |
| checkout = Path(os.environ["GITHUB_WORKSPACE"]).resolve() | |
| installed = Path(dataretrieval.__file__).resolve() | |
| assert not installed.is_relative_to(checkout), (installed, checkout) | |
| assert importlib.util.find_spec("dataretrieval.waterdata.api") is not None | |
| assert importlib.util.find_spec("dataretrieval.ogc.engine") is not None | |
| assert files("dataretrieval").joinpath("py.typed").is_file() | |
| assert waterdata.get_daily | |
| assert ngwmn.get_sites | |
| assert wateruse.get_wateruse | |
| assert engine.get_ogc_data | |
| PY | |
| type-check: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Set up Python 3.13 | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.13" | |
| cache: "pip" | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install .[type-check] | |
| - name: Type-check with mypy | |
| run: mypy | |
| test: | |
| needs: lint | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, windows-latest] | |
| python-version: ["3.10", "3.13", "3.14"] | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| cache: "pip" | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install .[test,nldi] | |
| - name: Test with pytest and report coverage | |
| run: | | |
| coverage run -m pytest tests/ | |
| coverage report -m |