Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate from poetry to uv #351

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
16 changes: 3 additions & 13 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
# These are supported funding model platforms

github: [seapagan]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: grantramsay
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
custom: ["https://www.buymeacoffee.com/seapagan"]
github: seapagan
buy_me_a_coffee: seapagan
ko_fi: seapagan
10 changes: 0 additions & 10 deletions .github/dependabot.yml

This file was deleted.

20 changes: 20 additions & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:recommended"
],
"labels": [
"dependencies"
],
"gitIgnoredAuthors": [
"66853113+pre-commit-ci[bot]@users.noreply.github.com"
],
"enabled": true,
"enabledManagers": [
"pep621",
"github-actions"
],
"ignoreDeps": [
"pytest-asyncio"
]
}
13 changes: 11 additions & 2 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
name: Linting
on: [push, pull_request]

on: [push, pull_request, workflow_dispatch]

jobs:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: chartboost/ruff-action@v1
- name: Linting
uses: chartboost/ruff-action@v1
with:
args: check
- name: Check Formatting
uses: chartboost/ruff-action@v1
with:
args: format --check
22 changes: 12 additions & 10 deletions .github/workflows/mypy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@ jobs:
mypy:
# uncomment the line before to disable this job if needed.
# if: false
name: mypy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Create MyPy Cache Directory
run: mkdir -p ${{ runner.workspace }}/.mypy_cache
- name: Mypy
uses: jpetrucciani/mypy-check@master

- name: Install uv
uses: astral-sh/setup-uv@v3
with:
path: "."
mypy_flags:
"--install-types --non-interactive --config-file pyproject.toml
--ignore-missing-imports --strict"
requirements_file: "requirements-dev.txt"
python_version: "3.9"
enable-cache: true
cache-dependency-glob: "uv.lock"

- name: Set up Python
run: uv python install 3.12

- name: Run mypy
run: uv run --all-extras mypy . --strict
66 changes: 21 additions & 45 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Tests
name: Test Suite

on:
push:
Expand All @@ -8,60 +8,36 @@ on:
workflow_dispatch:

jobs:
test:
uv-example:
name: python
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
# ---------------------------------------------------------------------- #
# checkout repo and setup Python #
# ---------------------------------------------------------------------- #
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
# ---------------------------------------------------------------------- #
# install and configure poetry #
# ---------------------------------------------------------------------- #
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
# ---------------------------------------------------------------------- #
# load cached venv if cache exists #
# ---------------------------------------------------------------------- #
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v3
with:
path: .venv
key:
venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version
}}-${{ hashFiles('**/poetry.lock') }}
# ---------------------------------------------------------------------- #
# install dependencies if cache does not exist #
# ---------------------------------------------------------------------- #
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
enable-cache: true
cache-dependency-glob: "uv.lock"

- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}

- name: Run tests
run:
uv run --all-extras -p ${{ matrix.python-version }} pytest tests
--cov-report=xml

# ---------------------------------------------------------------------- #
# run Pytest #
# ---------------------------------------------------------------------- #
- name: Test with pytest
run: |
poetry run pytest --cov-report=xml
- name: Run codacy-coverage-reporter
env:
CODACY_CONFIGURED: ${{ secrets.CODACY_PROJECT_TOKEN }}
if: ${{ env.CODACY_CONFIGURED != ''}}
uses: codacy/codacy-coverage-reporter-action@v1
continue-on-error: true
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
# or
# api-token: ${{ secrets.CODACY_API_TOKEN }}
coverage-reports: ./coverage.xml
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -215,3 +215,4 @@ pyrightconfig.json
.github_changelog_generator
.changelog_gen.toml
.changelog_generator.toml
.envrc
67 changes: 28 additions & 39 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
ci:
autofix_commit_msg: "[pre-commit.ci] auto fixes from pre-commit.com hooks [dependabot skip]"
autofix_commit_msg: "[pre-commit.ci] auto fixes from pre-commit.com hooks"
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: check-yaml
args: [--unsafe]
Expand All @@ -11,59 +11,48 @@ repos:
- id: check-merge-conflict
- id: end-of-file-fixer

- repo: https://github.com/renovatebot/pre-commit-hooks
rev: 39.5.0
hooks:
- id: renovate-config-validator
files: ^renovate\.json$

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.1
rev: v0.7.2
hooks:
- id: ruff
name: "lint with ruff"
- id: ruff-format
name: "format with ruff"

- repo: https://github.com/jackdewinter/pymarkdown
rev: v0.9.22
hooks:
- id: pymarkdown
name: "check markdown"
exclude: ^.github/|CHANGELOG
args: [-d, "MD046", scan]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.11.1" # Use the sha / tag you want to point at
rev: "v1.13.0" # Use the sha / tag you want to point at
hooks:
- id: mypy
name: "run mypy"
additional_dependencies:
- pydantic

- repo: https://github.com/python-poetry/poetry
rev: "1.8.0"
hooks:
- id: poetry-check
name: "check poetry files"
# - id: poetry-lock

- repo: https://github.com/python-poetry/poetry-plugin-export
rev: "1.8.0"
- repo: https://github.com/astral-sh/uv-pre-commit
# uv version.
rev: 0.4.30
hooks:
- id: poetry-export
name: "export production dependencies"
# Update the uv lockfile
- id: uv-lock
- id: uv-export
name: "Export dependencies to 'requirements.txt'"
args:
[
"--without-hashes",
"-f",
"requirements.txt",
"-o",
"requirements.txt",
"--without",
"dev",
"--no-hashes",
"--no-dev",
"--no-emit-project",
"--output-file=requirements.txt",
]
- id: poetry-export
name: "export development dependencies"
- id: uv-export
name: "Export dev dependencies to 'requirements-dev.txt'"
args:
[
"--without-hashes",
"-f",
"requirements.txt",
"-o",
"requirements-dev.txt",
"--with",
"dev",
"--no-hashes",
"--no-emit-project",
"--output-file=requirements-dev.txt",
]
2 changes: 1 addition & 1 deletion github_changelog_md/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def get_app_version() -> str:
# we are locally developing the package
try:
config = rtoml.load(toml_path)
version: str = config["tool"]["poetry"]["version"]
version: str = config["project"]["version"]
except (KeyError, OSError) as exc:
print(f"Problem getting the Version : {exc}")
sys.exit(ExitErrors.OS_ERROR)
Expand Down
Loading