Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
28 changes: 17 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,40 +9,46 @@ on:

jobs:
build:
name: ${{ matrix.os }} python-${{ matrix.python-version }}
name: ${{ matrix.os }}

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

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
with:
fetch-depth: 0

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
- name: Install Python
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
python-version-file: ".python-version"

- name: Install uv
uses: astral-sh/setup-uv@v6
with:
version: "0.8.3"
version: "0.9.11"
enable-cache: true
cache-dependency-glob: "uv.lock"
python-version: ${{ matrix.python-version }}

- name: Install the project
run: uv sync --dev --frozen
run: uv sync --locked

- name: Lint
uses: astral-sh/ruff-action@v3

- name: Run tests & build
- name: Run tests
run: |
uv run nox -s tests

- name: Build & smoke test
shell: bash
run: |
uv run pytest
uv build
uv run --isolated --no-project --with dist/*.whl tests/smoke_test.py
8 changes: 4 additions & 4 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,26 @@ jobs:
contents: write

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
with:
fetch-depth: 0

- name: Install Python and dependencies
- name: Install Python
uses: actions/setup-python@v5
with:
python-version-file: ".python-version"

- name: Install uv
uses: astral-sh/setup-uv@v6
with:
version: "0.8.3"
version: "0.9.11"

- name: Set up Quarto
uses: quarto-dev/quarto-actions/setup@v2

- name: Build docs
run: |
uv sync --dev --frozen
uv sync --locked
cd docs && uv run quartodoc build

- name: Render and publish
Expand Down
18 changes: 15 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,31 @@ jobs:
environment: release
permissions:
id-token: write
contents: read

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
with:
fetch-depth: 0

- name: Install uv
uses: astral-sh/setup-uv@v6
with:
version: "0.8.3"
version: "0.9.11"

- name: Install Python
uses: actions/setup-python@v5
with:
python-version-file: ".python-version"

- name: Build for distribution
run: uv build

- name: Smoke test (wheel)
run: uv run --isolated --no-project --with dist/*.whl tests/smoke_test.py

- name: Smoke test (source distribution)
run: uv run --isolated --no-project --with dist/*.tar.gz tests/smoke_test.py

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
run: uv publish
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ dist/
.pytest_cache
.ruff_cache
.coverage
.nox
htmlcov

# Generated version files
Expand Down
18 changes: 10 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.14.5
hooks:
# Run the linter.
- id: ruff-check
# Run the formatter.
- id: ruff-format
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.5
hooks:
- id: ruff-check
args: [ --fix ]
- id: ruff-format
- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.9.10
hooks:
- id: uv-lock
38 changes: 22 additions & 16 deletions docs/development.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ dependencies. First, be sure you
```bash
# Install dependencies and set up the virtual environment
uv sync

# Install the pre-commit hooks
uv run pre-commit install

```

For more details on how to use `uv`, head over to the [`uv` docs](https://docs.astral.sh/uv/).
Expand All @@ -27,33 +23,46 @@ For more details on how to use `uv`, head over to the [`uv` docs](https://docs.a

### Code
`ruff` is used for linting and formatting, automatically executed in a `pre-commit` hook.

```bash
# Install the pre-commit hooks
uv run pre-commit install
```

To run `ruff` manually from the command line or editor, see the [documentation](https://docs.astral.sh/ruff/) on how to install and use`ruff`.
To run `ruff` manually from the command line or editor, see the [`ruff` documentation](https://docs.astral.sh/ruff/).

### Docstrings
Follow the [`NumPy`](https://numpydoc.readthedocs.io/en/latest/format.html#overview) style guide when writing docstrings. This is important for being able to [build the documentation](#building-the-documentation).

## Running tests
Tests are run using `pytest`, typically via `uv run`:
For fast iteration on specific tests, use `uv run pytest`:

```bash
uv run pytest # all tests
uv run pytest -s tests/test_client.py # one test file
uv run pytest -s tests/test_client.py # one test file
uv run pytest -s tests/test_client.py::test_call_raises_http_error # one specific test
```

To check test coverage:
To run the complete test suite across all supported Python versions, use `nox`:
```bash
uv run nox # for the entire suite
uv run nox -s tests # same thing, just being explicit about the session
```

To check test coverage:
```bash
uv run pytest --cov=src --cov-report=term
uv run pytest --cov=pxweb # for terminal output
uv run pytest --cov=pxweb --cov-report=html # to get a report
```

Some tests utilize [`syrupy`](https://github.com/syrupy-project/syrupy) for snapshot testing to ensure consistency. If snapshots for some reason need to be updated run `uv run pytest --snapshot-update`.
Some tests utilize [`syrupy`](https://github.com/syrupy-project/syrupy) for snapshot testing to ensure consistency. If snapshots need to be updated:
```bash
uv run pytest --snapshot-update
```

## Building the documentation
Documentation is built using [`quartodoc`](https://github.com/machow/quartodoc), thus you also need [`quarto`](https://quarto.org/docs/get-started/) installed on your machine if you wish to build the documentation locally. This is usually a good idea to check that the output looks as expected. The documentation is automatically built and published upon each release.

With `quarto` installed, building the documentation is done in two steps:
With `quarto` installed the documentation can be rendered:

```bash
cd docs
Expand All @@ -67,8 +76,5 @@ The rendered output is found in the folder called `_site`.
When you’re ready to contribute:

1. Clone the repository and create a new branch for your changes.
2. Ensure that:
* All tests pass locally (`uv run pytest`)
* Code is linted and formatted (`uv run ruff check && uv run ruff format`)
* Documentation (if relevant) builds successfully
2. Ensure tests pass and code is properly formatted.
3. Open a pull request to the `main` branch.
2 changes: 1 addition & 1 deletion docs/version_config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from importlib_metadata import version as get_version
from importlib.metadata import version as get_version

version = get_version("pxwebpy")

Expand Down
13 changes: 13 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from nox import Session, options
from nox_uv import session

options.default_venv_backend = "uv"


@session(
name="tests",
python=["3.10", "3.11", "3.12", "3.13"],
uv_groups=["dev"],
)
def test(s: Session) -> None:
s.run("python", "-m", "pytest", "-vv")
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ authors = [
{ name = "Stefan Furne", email = "stefan@furne.net" }
]
dependencies = [
"packaging>=25.0",
"requests>=2.32.3",
"requests-cache>=1.2.1",
]
Expand Down Expand Up @@ -58,6 +59,8 @@ dev = [
"ipykernel>=6.29.5",
"nbclient>=0.10.2",
"nbformat>=5.10.4",
"nox>=2025.11.12",
"nox-uv>=0.6.3",
"pandas>=2.2.3",
"pandas-stubs>=2.2.2.240807",
"polars>=1.19.0",
Expand Down
12 changes: 12 additions & 0 deletions tests/smoke_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"""
Check some basics to ensure functionality.
"""

from pxweb import get_known_apis

apis = get_known_apis()

if not isinstance(apis, dict) or not apis:
raise RuntimeError("Smoke test failed")
else:
print("Smoke test passed")
Loading
Loading