-
Notifications
You must be signed in to change notification settings - Fork 3
Adopt uv across dev/CI/release workflows and remove remaining Poetry packaging usage
#168
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
base: main
Are you sure you want to change the base?
Changes from all commits
af91527
791a5a3
cce15bd
0e155d9
f260f31
3b5c57c
c5d148e
d89461b
f2af367
dcf375f
7e78d7b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -18,10 +18,11 @@ jobs: | |||||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||||||
| python-version: 3.12 | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| - name: Install Poetry and dependencies | ||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||
| pip install poetry | ||||||||||||||||||||||||||||||||||||||||
| poetry install | ||||||||||||||||||||||||||||||||||||||||
| - name: Set up uv | ||||||||||||||||||||||||||||||||||||||||
| uses: astral-sh/setup-uv@v6 | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| - name: Install dependencies | ||||||||||||||||||||||||||||||||||||||||
| run: uv sync --locked | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| - name: Extract version from Git tag | ||||||||||||||||||||||||||||||||||||||||
| id: version | ||||||||||||||||||||||||||||||||||||||||
|
|
@@ -31,18 +32,45 @@ jobs: | |||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| - name: Bump version in pyproject.toml | ||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||
| poetry version $VERSION | ||||||||||||||||||||||||||||||||||||||||
| poetry lock | ||||||||||||||||||||||||||||||||||||||||
| python <<'PY' | ||||||||||||||||||||||||||||||||||||||||
| from pathlib import Path | ||||||||||||||||||||||||||||||||||||||||
| import re | ||||||||||||||||||||||||||||||||||||||||
| import os | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| version = os.environ.get("VERSION") | ||||||||||||||||||||||||||||||||||||||||
| if not version: | ||||||||||||||||||||||||||||||||||||||||
| raise RuntimeError("VERSION environment variable is required but not set") | ||||||||||||||||||||||||||||||||||||||||
| # major.minor.patch with optional pre-release/build metadata | ||||||||||||||||||||||||||||||||||||||||
| semver_pattern = r"\d+\.\d+\.\d+(?:-[0-9A-Za-z]+(?:\.[0-9A-Za-z]+)*)?(?:\+[0-9A-Za-z]+(?:\.[0-9A-Za-z]+)*)?" | ||||||||||||||||||||||||||||||||||||||||
| if not re.fullmatch(semver_pattern, version): | ||||||||||||||||||||||||||||||||||||||||
| raise RuntimeError(f"VERSION is not a valid semantic version: {version}") | ||||||||||||||||||||||||||||||||||||||||
| pyproject = Path("pyproject.toml") | ||||||||||||||||||||||||||||||||||||||||
| content = pyproject.read_text() | ||||||||||||||||||||||||||||||||||||||||
| updated, updated_count = re.subn( | ||||||||||||||||||||||||||||||||||||||||
| r'(?m)^version = ".*"$', | ||||||||||||||||||||||||||||||||||||||||
| f'version = "{version}"', | ||||||||||||||||||||||||||||||||||||||||
| content, | ||||||||||||||||||||||||||||||||||||||||
| count=1, | ||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||
| if updated_count != 1: | ||||||||||||||||||||||||||||||||||||||||
| raise RuntimeError( | ||||||||||||||||||||||||||||||||||||||||
| f"Expected exactly 1 version substitution in pyproject.toml, found {updated_count}" | ||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||
| pyproject.write_text(updated) | ||||||||||||||||||||||||||||||||||||||||
| PY | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| - name: Push version bump to main | ||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||
| git config user.name "GitHub Actions" | ||||||||||||||||||||||||||||||||||||||||
| git config user.email "actions@github.com" | ||||||||||||||||||||||||||||||||||||||||
| git add pyproject.toml poetry.lock | ||||||||||||||||||||||||||||||||||||||||
| git add pyproject.toml | ||||||||||||||||||||||||||||||||||||||||
| git commit -m "Bump version to $VERSION" | ||||||||||||||||||||||||||||||||||||||||
| git push origin HEAD:main # Push from detached HEAD directly to main | ||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
62
to
68
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Skip the commit when the version rewrite is a no-op. If the tag already matches Proposed fix - name: Push version bump to main
run: |
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
git add pyproject.toml
- git commit -m "Bump version to $VERSION"
- git push origin HEAD:main # Push from detached HEAD directly to main
+ if git diff --cached --quiet; then
+ echo "pyproject.toml already matches $VERSION; skipping commit"
+ else
+ git commit -m "Bump version to $VERSION"
+ git push origin HEAD:main # Push from detached HEAD directly to main
+ fi📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| - name: Build the package and publish to PyPI | ||||||||||||||||||||||||||||||||||||||||
| - name: Build the package | ||||||||||||||||||||||||||||||||||||||||
| run: uv build | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| - name: Publish package to PyPI | ||||||||||||||||||||||||||||||||||||||||
| env: | ||||||||||||||||||||||||||||||||||||||||
| POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_API_TOKEN }} | ||||||||||||||||||||||||||||||||||||||||
| run: poetry publish --build | ||||||||||||||||||||||||||||||||||||||||
| UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }} | ||||||||||||||||||||||||||||||||||||||||
| run: uv publish | ||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,10 +19,11 @@ jobs: | |
| with: | ||
| python-version: 3.12 | ||
|
|
||
| - name: Set up uv | ||
| uses: astral-sh/setup-uv@v6 | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| pip install poetry | ||
| poetry install | ||
| run: uv sync --only-group test --locked | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Check if pyrail declares runtime dependencies in pyproject.toml
echo "=== Checking for runtime dependencies in [project.dependencies] ==="
if grep -A 20 '^\[project\.dependencies\]' pyproject.toml | grep -v '^#' | grep -v '^\[' | grep -q '^\S'; then
echo "✗ Runtime dependencies found:"
grep -A 20 '^\[project\.dependencies\]' pyproject.toml | grep -v '^#' | grep -v '^\[' | grep '^\S'
echo ""
echo "CONCERN: --only-group test may exclude these dependencies, breaking tests."
else
echo "✓ No runtime dependencies declared"
fi
echo ""
echo "=== Checking for runtime dependencies in [project] dependencies array ==="
python3 << 'EOF'
import tomllib
with open('pyproject.toml', 'rb') as f:
data = tomllib.load(f)
deps = data.get('project', {}).get('dependencies', [])
if deps:
print(f"✗ Runtime dependencies found: {deps}")
print("\nCONCERN: --only-group test may exclude these dependencies, breaking tests.")
else:
print("✓ No runtime dependencies in dependencies array")
EOFRepository: tjorim/pyrail Length of output: 402 🏁 Script executed: cat pyproject.tomlRepository: tjorim/pyrail Length of output: 1620 🏁 Script executed: # Check the structure of dependency groups and how they're defined
python3 << 'EOF'
import tomllib
with open('pyproject.toml', 'rb') as f:
data = tomllib.load(f)
print("=== Project Dependencies (runtime) ===")
runtime_deps = data.get('project', {}).get('dependencies', [])
print(runtime_deps if runtime_deps else "None")
print("\n=== Dependency Groups ===")
dep_groups = data.get('dependency-groups', {})
if dep_groups:
for group_name, deps in dep_groups.items():
print(f"\n[{group_name}]")
for dep in deps:
print(f" {dep}")
else:
print("No dependency-groups found")
print("\n=== Check for [project.optional-dependencies] ===")
opt_deps = data.get('project', {}).get('optional-dependencies', {})
if opt_deps:
for group_name, deps in opt_deps.items():
print(f"\n[{group_name}]")
for dep in deps:
print(f" {dep}")
else:
print("None")
EOFRepository: tjorim/pyrail Length of output: 385 🌐 Web query:
💡 Result: In uv, Citations:
Use The Change to 🤖 Prompt for AI Agents |
||
|
|
||
| - name: Run tests | ||
| run: poetry run pytest | ||
| run: uv run pytest | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: tjorim/pyrail
Length of output: 39
🏁 Script executed:
Repository: tjorim/pyrail
Length of output: 593
🏁 Script executed:
Repository: tjorim/pyrail
Length of output: 530
🏁 Script executed:
Repository: tjorim/pyrail
Length of output: 80
🏁 Script executed:
Repository: tjorim/pyrail
Length of output: 1199
🏁 Script executed:
Repository: tjorim/pyrail
Length of output: 2061
🏁 Script executed:
Repository: tjorim/pyrail
Length of output: 263
Replace
--only-group devwith--group devto include production dependencies during type checking.The
--only-group devflag installs only the dev group (ruff, ty) and the package itself, excluding production dependencies. However, pyrail imports runtime dependencies (aiohttpandmashumaro) in its source code. Type checking withtyrequires these dependencies to be available for import resolution; without them, type checking will fail or produce incomplete results.Use
uv sync --group dev --lockedinstead to include both production and dev dependencies.🤖 Prompt for AI Agents