From 937a7f2fd9e1b60f9cec7654f354a5d10ce46fa0 Mon Sep 17 00:00:00 2001 From: James Briggs <35938317+jamescalam@users.noreply.github.com> Date: Fri, 14 Feb 2025 01:18:56 +0400 Subject: [PATCH] feat: moving workflows to uv --- .github/workflows/docs.yml | 26 ++++++++++++++------------ .github/workflows/lint.yml | 19 ++++++++----------- .github/workflows/release.yml | 32 ++++++++++++++++---------------- .pre-commit-config.yaml | 2 +- CONTRIBUTING.md | 15 +++++++++------ Makefile | 18 +++++++++--------- 6 files changed, 57 insertions(+), 55 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 0e0f2c9e..83f3cb24 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -22,24 +22,26 @@ jobs: - name: Cache Poetry uses: actions/cache@v4 with: - path: ~/.poetry - key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }} + path: ~/.uv + key: ${{ runner.os }}-uv-${{ hashFiles('**/uv.lock') }} restore-keys: | - ${{ runner.os }}-poetry- - - name: Install poetry + ${{ runner.os }}-uv- + - name: Install uv run: | - pipx install poetry==$POETRY_VERSION + curl -LsSf https://astral.sh/uv/install.sh | sh + # - name: Set up Python ${{ matrix.python-version }} + # uses: actions/setup-python@v4 + # with: + # python-version: ${{ matrix.python-version }} + # cache: uv - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - cache: poetry + run: uv venv --python 3.13 + cache: uv - name: Install dependencies - run: | - poetry install --all-extras + run: uv pip install -e .[dev] - name: Build docs run: | - poetry run sphinx-build -M html docs/source docs/build + uv run sphinx-build -M html docs/source docs/build - name: Authenticate to Google Cloud id: auth uses: google-github-actions/auth@v2 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index bc3f5db0..6072eb12 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -21,21 +21,18 @@ jobs: - name: Cache Poetry uses: actions/cache@v4 with: - path: ~/.poetry - key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }} + path: ~/.uv + key: ${{ runner.os }}-uv-${{ hashFiles('**/uv.lock') }} restore-keys: | - ${{ runner.os }}-poetry- - - name: Install poetry + ${{ runner.os }}-uv- + - name: Install uv run: | - pipx install poetry==$POETRY_VERSION + curl -LsSf https://astral.sh/uv/install.sh | sh - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - cache: poetry + run: uv venv --python 3.13 + cache: uv - name: Install dependencies - run: | - poetry install + run: uv pip install -e .[dev] - name: Analyzing the code with our lint run: | make lint diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ee26b0c5..9b437ed7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,16 +11,14 @@ jobs: steps: - uses: actions/checkout@v2 - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: '3.13' - - name: Install Poetry - run: | - curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1 + run: uv venv --python 3.13 + cache: uv + - name: Install uv + run: curl -LsSf https://astral.sh/uv/install.sh | sh - name: Install dependencies - run: poetry install + run: uv pip install -e .[dev] - name: Build - run: poetry build + run: uv build publish: needs: build @@ -28,15 +26,17 @@ jobs: steps: - uses: actions/checkout@v2 - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: '3.13' - - name: Install Poetry - run: | - curl -sSL https://install.python-poetry.org | python - -y --version 2.0.1 + run: uv venv --python 3.13 + cache: uv + - name: Install uv + run: curl -LsSf https://astral.sh/uv/install.sh | sh + - name: Install dependencies + run: uv pip install -e .[dev] + - name: Build + run: uv build - name: Publish to PyPI run: | - poetry config repositories.remote https://upload.pypi.org/legacy/ - poetry --no-interaction -v publish --build --repository remote --username "__token__" --password "$PYPI_API_TOKEN" + uv config repositories.remote https://upload.pypi.org/legacy/ + uv --no-interaction -v publish --build --repository remote --username "__token__" --password "$PYPI_API_TOKEN" env: PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a849bb3b..4bd34b54 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -32,7 +32,7 @@ repos: language: python types: [ text ] args: [ "--write-changes", "--ignore-words-list", "asend" ] - exclude: "poetry.lock" + exclude: "uv.lock" - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.4.0 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d7208e9b..7713038a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -27,6 +27,7 @@ While we encourage you to initiate a draft Pull Request early to get feedback on 1. Fork on GitHub: Go to the [repository's page](https://github.com/aurelio-labs/semantic-router) on GitHub: Click the "Fork" button in the top-right corner of the page. + 2. Clone Your Fork: After forking, you'll be taken to your new fork of the repository on GitHub. Copy the URL of your fork from the address bar or by clicking the "Code" button and copying the URL under "Clone with HTTPS" or "Clone with SSH". Open your terminal or command prompt. @@ -34,18 +35,20 @@ While we encourage you to initiate a draft Pull Request early to get feedback on ``` git clone https://github.com/<your-gh-username>/<semantic-router>.git ``` -3. Ensure you have poetry installed: `pip install poetry`. -4. Then navigate to the cloned folder, create a virtualenv, and install via poetry (which defaults to an editable installation): + +3. Ensure you have [`uv` installed](https://docs.astral.sh/uv/getting-started/installation/), for macos and linux use `curl -LsSf https://astral.sh/uv/install.sh | sh`. + +4. Then navigate to the cloned folder, create a virtualenv, and install via `uv`: ``` # Move into the cloned folder cd semantic-router/ # Create a virtual environment - python3 -m venv venv + uv venv --python 3.13 # Activate the environment - source venv/bin/activate + source .venv/bin/activate - # Install via poetry with all extras relevant to perform unit tests - poetry install --all-extras + # Install via uv with all extras relevant to perform unit tests + uv pip install -e .[dev] ``` diff --git a/Makefile b/Makefile index 5f85bd41..502846f3 100644 --- a/Makefile +++ b/Makefile @@ -1,23 +1,23 @@ format: - poetry run black --target-version py313 -l 88 . - poetry run ruff --select I --fix . + uv run black --target-version py313 -l 88 . + uv run ruff --select I --fix . PYTHON_FILES=. lint: PYTHON_FILES=. lint_diff: PYTHON_FILES=$(shell git diff --name-only --diff-filter=d main | grep -E '\.py$$') lint lint_diff: - poetry run black --target-version py313 -l 88 $(PYTHON_FILES) --check - poetry run ruff check . - poetry run mypy $(PYTHON_FILES) + uv run black --target-version py313 -l 88 $(PYTHON_FILES) --check + uv run ruff check . + uv run mypy $(PYTHON_FILES) test: - poetry run pytest -vv --cov=semantic_router --cov-report=term-missing --cov-report=xml --exitfirst --maxfail=1 + uv run pytest -vv --cov=semantic_router --cov-report=term-missing --cov-report=xml --exitfirst --maxfail=1 test_functional: - poetry run pytest -vv -s --exitfirst --maxfail=1 tests/functional + uv run pytest -vv -s --exitfirst --maxfail=1 tests/functional test_unit: - poetry run pytest -vv --exitfirst --maxfail=1 tests/unit + uv run pytest -vv --exitfirst --maxfail=1 tests/unit test_integration: - poetry run pytest -vv --exitfirst --maxfail=1 tests/integration + uv run pytest -vv --exitfirst --maxfail=1 tests/integration -- GitLab