From 36ab191b7bdd6fac94d4c77dcd1fcc4cd79e33ad Mon Sep 17 00:00:00 2001 From: Selvam Palanimalai Date: Sat, 4 Jan 2025 18:19:43 -0500 Subject: [PATCH] feat: switching from poetry to uv --- .github/workflows/ci.yml | 52 +++++++++++++----------------- .github/workflows/dependencies.yml | 14 ++++---- .github/workflows/deploy-pypi.yml | 16 ++++----- .github/workflows/e2e-tests.yml | 24 +++++++------- README.md | 4 +-- pyproject.toml | 7 ++-- 6 files changed, 52 insertions(+), 65 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index be0f1c5..c318463 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,32 +25,25 @@ jobs: python-version: ${{ matrix.python-version }} cache: "pip" - - name: Install Poetry - uses: snok/install-poetry@v1 - with: - version: 1.8.5 - virtualenvs-create: true - virtualenvs-in-project: true + - name: Install uv + run: | + pip install uv - - name: Load cached venv - id: cached-poetry-dependencies + - name: Load cached dependencies uses: actions/cache@v4 with: path: .venv - key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }} + key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/requirements.txt') }} - name: Install project - run: poetry install --no-interaction + run: | + uv venv + uv pip install -e ".[dev]" - name: Run tests - run: poetry run pytest -v --cov=docs_actions --cov-report=xml - - # - name: Upload coverage to Codecov - # uses: codecov/codecov-action@v4 - # with: - # token: ${{ secrets.CODECOV_TOKEN }} - # file: ./coverage.xml - # fail_ci_if_error: true + run: | + source .venv/bin/activate + pytest -v --cov=docs_actions --cov-report=xml lint: name: Lint @@ -64,26 +57,25 @@ jobs: python-version: "3.12" cache: "pip" - - name: Install Poetry - uses: snok/install-poetry@v1 - with: - version: 1.8.5 - virtualenvs-create: true - virtualenvs-in-project: true + - name: Install uv + run: | + pip install uv - - name: Load cached venv - id: cached-poetry-dependencies + - name: Load cached dependencies uses: actions/cache@v4 with: path: .venv - key: venv-${{ runner.os }}-lint-${{ hashFiles('**/poetry.lock') }} + key: venv-${{ runner.os }}-lint-${{ hashFiles('**/requirements.txt') }} - name: Install dependencies - if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' - run: poetry install --no-interaction --no-root + run: | + uv venv + uv pip install -e ".[dev]" - name: Run pre-commit - run: poetry run pre-commit run --all-files + run: | + source .venv/bin/activate + pre-commit run --all-files security: name: Security Checks diff --git a/.github/workflows/dependencies.yml b/.github/workflows/dependencies.yml index 1e4c9e0..66c1609 100644 --- a/.github/workflows/dependencies.yml +++ b/.github/workflows/dependencies.yml @@ -17,17 +17,15 @@ jobs: python-version: "3.12" cache: "pip" - - name: Install Poetry - uses: snok/install-poetry@v1 - with: - version: 1.7.1 - virtualenvs-create: true - virtualenvs-in-project: true + - name: Install uv + run: | + curl -LsSf https://astral.sh/uv/install.sh | sh + echo "$HOME/.local/bin" >> $GITHUB_PATH - name: Check for updates - run: poetry show --outdated + run: uv pip list --outdated - name: Run safety check run: | - pip install safety + uv pip install safety safety check diff --git a/.github/workflows/deploy-pypi.yml b/.github/workflows/deploy-pypi.yml index 6eaac01..d6fcd53 100644 --- a/.github/workflows/deploy-pypi.yml +++ b/.github/workflows/deploy-pypi.yml @@ -26,20 +26,20 @@ jobs: python-version: "3.12" cache: "pip" - - name: Install Poetry - uses: snok/install-poetry@v1 - with: - version: 1.8.5 - virtualenvs-create: true - virtualenvs-in-project: true + - name: Install uv + run: | + curl -LsSf https://astral.sh/uv/install.sh | sh + echo "$HOME/.local/bin" >> $GITHUB_PATH - name: Update version run: | VERSION=${GITHUB_REF#refs/tags/v} - poetry version $VERSION + uvx --from=toml-cli toml set --toml-path=pyproject.toml project.version $VERSION - name: Build package - run: poetry build + run: | + uv sync + uv build - name: Publish package distributions to PyPI uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index d72164e..70ca88a 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -18,18 +18,16 @@ jobs: python-version: "3.12" cache: "pip" - - name: Install Poetry - uses: snok/install-poetry@v1 - with: - version: 1.8.5 - virtualenvs-create: true - virtualenvs-in-project: true + - name: Install uv + run: | + curl -LsSf https://astral.sh/uv/install.sh | sh + echo "$HOME/.local/bin" >> $GITHUB_PATH - name: Install dependencies run: | - poetry install --no-interaction - pip install mkdocs - pip install sphinx sphinx-sitemap + uv venv + uv pip install -e . + uv pip install mkdocs sphinx sphinx-sitemap - name: mkdocs - Build docs run: | @@ -39,7 +37,7 @@ jobs: - name: mkdocs - Run llms-txt run: | cd tests/test_mkdocs - poetry run llms-txt --docs-dir site/ + uv run llms-txt --docs-dir site/ - name: mkdocs - Check generated files run: | @@ -64,7 +62,7 @@ jobs: MODEL_API_KEY: ${{ secrets.MODEL_API_KEY }} run: | cd tests/test_mkdocs - poetry run llms-txt --docs-dir site/ + uv run llms-txt --docs-dir site/ - name: mkdocs - Check generated files run: | @@ -86,7 +84,7 @@ jobs: - name: sphinx - Run llms-txt run: | cd tests/test_sphinx - poetry run llms-txt --docs-dir build/html/ + uv run llms-txt --docs-dir build/html/ - name: sphinx - Check generated files run: | @@ -111,7 +109,7 @@ jobs: MODEL_API_KEY: ${{ secrets.MODEL_API_KEY }} run: | cd tests/test_sphinx - poetry run llms-txt --docs-dir build/html/ + uv run llms-txt --docs-dir build/html/ - name: sphinx - Check generated files run: | diff --git a/README.md b/README.md index af0ffb4..f18d0a4 100644 --- a/README.md +++ b/README.md @@ -83,13 +83,13 @@ llms-txt --docs-dir site/ ```bash # clone the repo - poetry install + uv sync ``` 1. Run the crawler: ```bash - poetry run python -m "llms_txt_action.entrypoint" --docs-dir site/ + uv run python -m "llms_txt_action.entrypoint" --docs-dir site/ ``` ## Examples diff --git a/pyproject.toml b/pyproject.toml index d52a2e4..3bc3f2a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "llms-txt-action" -version = "0.1.1" +version = "0.0.0" description = "GitHub Action to make documentation more accessible to LLMs." authors = [ {name = "DemoDrive AI", email = "founders@demodrive.tech"} @@ -47,8 +47,8 @@ dev = [ ] [build-system] -requires = ["poetry-core>=1.1.0"] -build-backend = "poetry.core.masonry.api" +requires = ["hatchling"] +build-backend = "hatchling.build" [tool.ruff] line-length = 88 @@ -83,7 +83,6 @@ select = [ "SLF", # self "SIM", # simplify "TID", # tidy-imports - "TCH", # type-checking "ARG", # unused-arguments "PTH", # use-pathlib "ERA", # eradicate