From a2133ec4d430cafc98ff2c762df2cd890803ce1f Mon Sep 17 00:00:00 2001 From: Pete Gadomski Date: Tue, 2 Apr 2024 11:13:22 -0600 Subject: [PATCH] ci: switch to uv From my reading, it looks like the caching doesn't get us much, so I removed it. --- .github/workflows/continuous-integration.yml | 53 ++++++++++++-------- CHANGELOG.md | 1 + scripts/install-min-requirements | 43 ---------------- 3 files changed, 32 insertions(+), 65 deletions(-) delete mode 100755 scripts/install-min-requirements diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 80ae20e1..2a6a40e6 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -33,9 +33,14 @@ jobs: uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - cache: "pip" + - 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: pip install .[dev] + run: uv pip install --system .[dev] - name: Run pre-commit run: pre-commit run --all-files - name: Run pytest @@ -57,13 +62,14 @@ jobs: - uses: actions/setup-python@v5 with: python-version: 3.9 - cache: "pip" - - name: Install with dev requirements - run: pip install .[dev] - - name: Install minimum requirements - run: ./scripts/install-min-requirements - - name: Test - run: ./scripts/test + - name: Download uv + run: curl -LsSf https://astral.sh/uv/install.sh | sh + - name: Install dev requirements + run: uv pip install --system .[dev] + - name: Install with min requirements + run: uv pip install --system --resolution=lowest-direct --reinstall . + - name: Run pytest + run: pytest -Werror -s --block-network docs: name: docs @@ -96,13 +102,14 @@ jobs: - uses: actions/setup-python@v5 with: python-version: 3.9 - cache: "pip" - - name: Install - run: pip install .[dev] + - 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] - name: Install any pre-releases of pystac - run: pip install -U --pre pystac - - name: Test - run: ./scripts/test + run: uv pip install --system -U --pre pystac + - name: Run pytest + run: pytest -Werror -s --block-network upstream: name: upstream @@ -113,13 +120,14 @@ jobs: - uses: actions/setup-python@v5 with: python-version: 3.9 - cache: "pip" + - name: Download uv + run: curl -LsSf https://astral.sh/uv/install.sh | sh - name: Install - run: pip install .[dev] + run: uv pip install .[dev] - name: Install pystac from main - run: pip install --force-reinstall git+https://github.com/stac-utils/pystac.git - - name: Test - run: ./scripts/test + run: uv pip install --system --force-reinstall git+https://github.com/stac-utils/pystac.git + - name: Run pytest + run: pytest -Werror -s --block-network dev-and-docs-requirements: name: dev and docs requirements check @@ -129,8 +137,9 @@ jobs: - uses: actions/setup-python@v5 with: python-version: 3.9 - cache: "pip" + - 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: pip install .[dev,docs] + run: uv pip install --system .[dev,docs] diff --git a/CHANGELOG.md b/CHANGELOG.md index 0cf5717f..285a639e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Changed - Updated to **pystac** v1.10.0 [#661](https://github.com/stac-utils/pystac-client/pull/661) +- Use [uv](https://github.com/astral-sh/uv) for CI [#663](https://github.com/stac-utils/pystac-client/pull/663) ## [v0.7.6] diff --git a/scripts/install-min-requirements b/scripts/install-min-requirements deleted file mode 100755 index a2849462..00000000 --- a/scripts/install-min-requirements +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env python3 - -"""Installs the minimum version of all stactools dependencies, with pip. - -Assumptions: -- You've installed the development dependencies: `pip install '.[dev]'` -- All of the dependencies in pyproject.toml are specified with `>=` - -For more context on the approach and rationale behind testing against minimum -requirements, see -https://www.gadom.ski/2022/02/18/dependency-protection-with-python-and-github-actions.html. - -""" - -import subprocess -import sys -from pathlib import Path - -from packaging.requirements import Requirement - -assert sys.version_info[0] == 3 -if sys.version_info[1] < 11: - import tomli as toml -else: - import tomllib as toml - - -root = Path(__file__).parents[1] -with open(root / "pyproject.toml", "rb") as f: - pyproject_toml = toml.load(f) -requirements = [] -for install_requires in filter( - bool, - (i.strip() for i in pyproject_toml["project"]["dependencies"]), -): - requirement = Requirement(install_requires) - assert len(requirement.specifier) == 1 - specifier = list(requirement.specifier)[0] - assert specifier.operator == ">=" - install_requires = install_requires.replace(">=", "==") - requirements.append(install_requires) - -subprocess.run(["pip", "install", *requirements])