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
24 changes: 18 additions & 6 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: docs

on:
workflow_dispatch:
pull_request: ~
Expand All @@ -13,6 +13,11 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read
checks: write
statuses: write

jobs:
documentation:

Expand All @@ -22,13 +27,20 @@ jobs:
steps:
- name: Acquire sources
uses: actions/checkout@v6
with:
persist-credentials: false

- name: Set up Python
uses: actions/setup-python@v6
- name: Set up uv
uses: astral-sh/setup-uv@v7
with:
python-version: '3.12'
cache: 'pip'
cache-dependency-path: 'setup.py'
cache-dependency-glob: |
pyproject.toml
enable-cache: true
activate-environment: true
version: "latest"

- name: Setup env
run: uv pip install --group docs

- name: Build docs
run: |
Expand Down
62 changes: 0 additions & 62 deletions .github/workflows/nightly.yml

This file was deleted.

15 changes: 7 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ name: release

on: push

permissions:
contents: read
checks: write
statuses: write

jobs:
pypi:
name: Build & publish package to pypi
Expand All @@ -15,11 +20,8 @@ jobs:
if: startsWith(github.event.ref, 'refs/tags')
steps:
- uses: actions/checkout@v6

- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
persist-credentials: false

- name: Set up uv
uses: astral-sh/setup-uv@v7
Expand All @@ -31,10 +33,7 @@ jobs:
version: "latest"

- name: Build package
run: |
uv pip install --system build twine wheel
python -m build
twine check dist/*
run: uv build

- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
Expand Down
60 changes: 26 additions & 34 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
---
name: Tests

on:
push:
branches: [ main ]
branches:
- main
pull_request: ~
workflow_dispatch:
schedule:
- cron: '0 2 * * *'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read
checks: write
statuses: write

jobs:
test:
name: "Python: ${{ matrix.python-version }}
Expand All @@ -18,33 +27,23 @@ jobs:
strategy:
fail-fast: false
matrix:
os: ['ubuntu-22.04']
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13', '3.14']
cratedb-version: ['nightly']
os: ["ubuntu-24.04"]
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']

# To save resources, only verify the most recent Python versions on macOS.
# Save resources - only verify the most recent Python versions on macOS.
include:
- os: 'macos-latest'
cratedb-version: '5.9.2'
python-version: '3.11'
- os: 'macos-latest'
cratedb-version: '5.9.2'
python-version: '3.12'
- os: 'macos-latest'
cratedb-version: '5.9.2'
python-version: '3.13'
- os: 'macos-latest'
python-version: '3.14'

env:
CRATEDB_VERSION: ${{ matrix.cratedb-version }}
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
Comment on lines 40 to 41
Copy link
Member

@amotl amotl Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see now that we have been able to define the CrateDB version on the test matrix before, which is no longer possible. Is it possible to bring this back?


steps:
- uses: actions/checkout@v6

- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
persist-credentials: false

- name: Set up uv
uses: astral-sh/setup-uv@v7
Expand All @@ -53,30 +52,23 @@ jobs:
pyproject.toml
cache-suffix: ${{ matrix.python-version }}
enable-cache: true
activate-environment: true
version: "latest"

- name: Setup env
run: uv sync
run: uv pip install --group dev -e .

- name: Invoke tests
- name: Run Linters
run: |

# Propagate build matrix information.
./devtools/setup_ci.sh
ruff check .
mypy

# Bootstrap environment.
source bootstrap.sh

# Report about the test matrix slot.
echo "Invoking tests with CrateDB ${CRATEDB_VERSION}"

# Run linter.
poe lint

# Run tests.
poe test
- name: Run tests
run: |
coverage run -m pytest
coverage combine
coverage xml

# https://github.com/codecov/codecov-action
- name: Upload coverage results to Codecov
uses: codecov/codecov-action@v5
env:
Expand Down
94 changes: 24 additions & 70 deletions DEVELOP.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,95 +5,49 @@ CrateDB Python developer guide
Setup
=====

Optionally install Python package and project manager `uv`_,
in order to significantly speed up the package installation::

{apt,brew,pip,zypper} install uv
alias pip="uv pip"

To start things off, bootstrap the sandbox environment::
Clone the repository::

git clone https://github.com/crate/crate-python
cd crate-python
source bootstrap.sh

This command should automatically install all prerequisites for the development
sandbox and drop you into the virtualenv, ready for invoking further commands.


Running tests
=============

All tests will be invoked using the Python interpreter that was used when
creating the Python virtualenv. The test runner is `zope.testrunner`_.

Some examples are outlined below. In order to learn about more details,
see, for example, `useful command-line options for zope-testrunner`_.

Run all tests::

poe test
Setup a virtualenv and install the package::

Run specific tests::
python -m venv .venv
source .venv/bin/activate
python -m pip install --group dev --group docs -e .

# Select modules.
bin/test -t test_cursor
bin/test -t client
bin/test -t testing
Or if using `uv`_::

# Select doctests.
bin/test -t http.rst
uv venv .venv
source .venv/bin/activate
uv pip install --group dev --group docs -e .

Ignore specific test directories::

bin/test --ignore_dir=testing

The ``LayerTest`` test cases have quite some overhead. Omitting them will save
a few cycles (~70 seconds runtime)::

bin/test -t '!LayerTest'

Invoke all tests without integration tests (~10 seconds runtime)::

bin/test --layer '!crate.testing.layer.crate' --test '!LayerTest'

Yet ~60 test cases, but only ~1 second runtime::
Running tests
=============

bin/test --layer '!crate.testing.layer.crate' --test '!LayerTest' \
-t '!test_client_threaded' -t '!test_no_retry_on_read_timeout' \
-t '!test_wait_for_http' -t '!test_table_clustered_by'
Ensure the virtualenv is active and run tests using `pytest`_::

To inspect the whole list of test cases, run::
python -m pytest

bin/test --list-tests

The CI setup on GitHub Actions (GHA) provides a full test matrix covering
relevant Python versions. You can invoke the software tests against a specific
Python interpreter or multiple `Python versions`_ on your workstation using
`uv`_, by supplying the ``--python`` command-line option, or by defining the
`UV_PYTHON`_ environment variable prior to invoking ``source bootstrap.sh``.
See also:

*Note*: Before running the tests, make sure to stop all CrateDB instances which
are listening on the default CrateDB transport port to avoid side effects with
the test layer.
- `How to invoke pytest <https://docs.pytest.org/en/stable/how-to/usage.html>` for more information.


Formatting and linting code
===========================

To use Ruff for code formatting, according to the standards configured in
``pyproject.toml``, use::

poe format

To lint the code base using Ruff and mypy, use::
Use `ruff`_ for code formatting and linting::

poe lint
ruff format --check .
ruff check .

Linting and software testing, all together now::

poe check
Use ``mypy`` for type checking::

mypy

Renew certificates
==================
Expand All @@ -120,8 +74,8 @@ In the release branch:

- Push to origin/<release_branch>

- Create a tag by running ``./devtools/create_tag.sh``. This will trigger a
Github action which releases the new version to PyPi.
- Create a tag by running ``git tag -s <version>`` and push it ``git push --tags``.
This will trigger a Github action which releases the new version to PyPi.

On branch ``main``:

Expand All @@ -147,7 +101,7 @@ Writing documentation

The docs live under the ``docs`` directory.

The docs are written written with ReStructuredText_ and processed with Sphinx_.
The docs are written with ReStructuredText_ and processed with Sphinx_.

Build the docs by running::

Expand All @@ -171,4 +125,4 @@ nothing special you need to do to get the live docs to update.
.. _uv: https://docs.astral.sh/uv/
.. _UV_PYTHON: https://docs.astral.sh/uv/configuration/environment/#uv_python
.. _versions hosted on ReadTheDocs: https://readthedocs.org/projects/crate-python/versions/
.. _zope.testrunner: https://pypi.org/project/zope.testrunner/
.. _pytest: https://docs.pytest.org/en/stable/
Loading
Loading