Skip to content

Commit

Permalink
feat: modernize dev tooling (#784)
Browse files Browse the repository at this point in the history
* feat: modernize dev tooling

* feat: update docs

* chore: update changelog

* ci: remove 3.13, sync correctly

* feat: ad uv.lock

* fix: docs

* ci: use conda for docs env

* fix: conda better

* docs: try splitting the readthedocs config

* fix: readthedocs

* fix: readthedocs output

* fix: remove conda

* fix: ci
  • Loading branch information
gadomski authored Feb 3, 2025
1 parent 605e95c commit 9163eb2
Show file tree
Hide file tree
Showing 10 changed files with 3,214 additions and 112 deletions.
107 changes: 33 additions & 74 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ on:
pull_request:

concurrency:
# Cancel running job if another commit is pushed to the branch
group: ${{ github.ref }}
cancel-in-progress: true

Expand All @@ -16,7 +15,6 @@ jobs:
name: build
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version:
- "3.10"
Expand All @@ -28,114 +26,75 @@ jobs:
- macos-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
- uses: astral-sh/setup-uv@v5
with:
python-version: ${{ matrix.python-version }}
- name: Download uv (non-Windows)
if: ${{ runner.os != 'Windows' }}
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Download uv (Windows)
if: ${{ runner.os == 'Windows' }}
run: irm https://astral.sh/uv/install.ps1 | iex
- name: Install package with dev requirements
run: uv pip install --system .[dev]
- name: Sync
run: uv sync
- name: Run pre-commit
run: pre-commit run --all-files
run: uv run pre-commit run --all-files
- name: Run pytest
run: pytest -Werror -s --block-network --cov pystac_client --cov-report term-missing
run: uv run pytest -Werror -s --block-network --cov pystac_client --cov-report term-missing
- name: Run coverage
run: coverage xml
- name: Upload All coverage to Codecov
uses: codecov/codecov-action@v5
run: uv run coverage xml
- uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
files: ./coverage.xml
fail_ci_if_error: false

min-versions:
name: min-versions
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: astral-sh/setup-uv@v5
with:
python-version: "3.10"
- name: Download uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Install with min requirements
run: uv pip install --system --resolution=lowest-direct .
run: uv sync --no-dev --resolution=lowest-direct
- name: Run smoke test
run: stac-client search https://planetarycomputer.microsoft.com/api/stac/v1 -c sentinel-2-l2a --max-items 1

docs:
name: docs
runs-on: ubuntu-latest
# Required shell entrypoint to have properly activated conda environment
defaults:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@v4
- name: Setup Conda Environment
uses: conda-incubator/setup-miniconda@v3.1.1
with:
miniforge-version: latest
python-version: "3.10"
use-mamba: true
channel-priority: strict
environment-file: ./docs/environment.yml
activate-environment: pystac-client-docs
auto-activate-base: false
- name: Build docs
run: ./scripts/build-docs
run: stac-client search https://landsatlook.usgs.gov/stac-server -c landsat-c2l2-sr --max-items 1

pre-release:
name: pre-release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Download uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Install with dev requirements
run: uv pip install --system --pre .[dev]
- uses: astral-sh/setup-uv@v5
- name: Sync
run: uv sync
- name: Install any pre-releases of pystac
run: uv pip install --system -U --pre pystac
run: uv pip install -U --pre pystac
- name: Run pytest
run: pytest -Werror -s --block-network
run: uv run pytest -Werror -s --block-network

upstream:
name: upstream
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Download uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Install
run: uv pip install --system .[dev]
- uses: astral-sh/setup-uv@v5
- name: Sync
run: uv sync
- name: Install pystac from main
run: uv pip install --system --force-reinstall git+https://github.com/stac-utils/pystac.git
run: uv pip install --force-reinstall git+https://github.com/stac-utils/pystac.git
- name: Run pytest
run: pytest -Werror -s --block-network
run: uv run pytest -Werror -s --block-network

dev-and-docs-requirements:
name: dev and docs requirements check
docs:
name: docs
runs-on: ubuntu-latest
defaults:
run:
shell: bash -el {0}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Download uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Install geos
run: sudo apt -y install libgeos-dev
- name: Install
run: uv pip install --system .[dev,docs]
- uses: astral-sh/setup-uv@v5
- name: Install pandoc
run: sudo apt-get install -y pandoc
- name: Sync
run: uv sync --group docs
- name: Build docs
run: ./scripts/build-docs
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -619,5 +619,3 @@ $RECYCLE.BIN/

# Windows shortcuts
*.lnk

uv.lock
5 changes: 1 addition & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ repos:
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/psf/black
rev: 24.10.0
hooks:
- id: black
- id: ruff-format
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
Expand Down
24 changes: 12 additions & 12 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
# .readthedocs.yml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

build:
os: ubuntu-22.04
tools:
python: "mambaforge-22.9"
python: "3.12"
jobs:
post_install:
- asdf plugin add uv
- asdf install uv latest
- asdf global uv latest
- uv sync --group docs
build:
html:
- uv run -- sphinx-build -M html docs $READTHEDOCS_OUTPUT
pdf:
- uv run -- sphinx-build -M latexpdf docs $READTHEDOCS_OUTPUT

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py
# fail_on_warning: true

# Optionally build your docs in additional formats such as PDF
formats:
- pdf
- htmlzip

conda:
environment: docs/environment.yml
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### Changed

- Use [uv](https://docs.astral.sh/uv/) for development ([#784](https://github.com/stac-utils/pystac-client/pull/784))
- Updated to Python 3.10 syntax with **pyupgrade** [#783](https://github.com/stac-utils/pystac-client/pull/783/)

### Fixed
Expand Down
8 changes: 5 additions & 3 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ way is to coordinate with the core developers via an issue or pull request conve

Development installation
^^^^^^^^^^^^^^^^^^^^^^^^
Fork PySTAC Client into your GitHub account. Clone the repo, install
the library as an "editable link", then install the development dependencies:
Fork PySTAC Client into your GitHub account. Clone the repo, install `uv
<https://docs.astral.sh/uv/getting-started/installation/>`_ then sync and
activate the created virtual environment:

.. code-block:: bash
$ git clone git@github.com:your_user_name/pystac-client.git
$ cd pystac-client
$ pip install -e '.[dev]'
$ uv sync
$ source .venv/bin/activate
Testing
^^^^^^^
Expand Down
12 changes: 0 additions & 12 deletions docs/environment.yml

This file was deleted.

7 changes: 3 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "pystac-client"
description = "Python library for working with SpatioTemporal Asset Catalog (STAC) APIs."
description = "Python library for searching SpatioTemporal Asset Catalog (STAC) APIs."
readme = "README.md"
authors = [
{ name = "Jon Duckworth", email = "duckontheweb@gmail.com" },
Expand Down Expand Up @@ -35,9 +35,8 @@ dynamic = ["version"]
[project.scripts]
stac-client = "pystac_client.cli:cli"

[project.optional-dependencies]
[dependency-groups]
dev = [
"black~=25.1",
"codespell~=2.4.0",
"coverage~=7.2",
"doc8~=1.1.1",
Expand Down Expand Up @@ -68,7 +67,7 @@ docs = [
"hvplot~=0.11.0",
"ipykernel~=6.22",
"ipython~=8.12",
"jinja2<4.0",
"jinja2>=3.0,<4.0",
"matplotlib~=3.8",
"myst-parser~=4.0",
"nbsphinx~=0.9",
Expand Down
2 changes: 1 addition & 1 deletion scripts/build-docs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ if [ "${BASH_SOURCE[0]}" = "${0}" ]; then
if [ "${1:-}" = "--help" ]; then
usage
else
sphinx-build -M html docs docs/build
uv run -- sphinx-build -M html docs docs/build
fi
fi
Loading

0 comments on commit 9163eb2

Please sign in to comment.