Skip to content

Refactor packaging pipeline#43

Merged
leoyala merged 2 commits into
mainfrom
42-refactor-package-version-bumping
Jul 15, 2026
Merged

Refactor packaging pipeline#43
leoyala merged 2 commits into
mainfrom
42-refactor-package-version-bumping

Conversation

@leoyala

@leoyala leoyala commented Jul 15, 2026

Copy link
Copy Markdown
Owner

Summary

Creates new GitHub action to bump package version, and adds dynamic version loading.

Changes

  • Creates GitHub action to bump package version and open a PR.
  • Makes package version loading a bit more dynamic by loading it from the installed package.

Test plan

  • uv run pytest passes

Summary by CodeRabbit

  • New Features

    • Added an on-demand version bump workflow supporting major, minor, patch, prerelease, and post-release updates.
    • Automatically prepares a release branch and pull request after a version change.
  • Bug Fixes

    • The displayed package version now stays synchronized with the installed package metadata, reducing the risk of stale version information.

@leoyala leoyala added this to the v0.1.0 milestone Jul 15, 2026
@leoyala leoyala self-assigned this Jul 15, 2026
@leoyala leoyala added the tools Changes to package development tools. label Jul 15, 2026
@leoyala leoyala linked an issue Jul 15, 2026 that may be closed by this pull request
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds metadata-based package version reporting and a manually triggered GitHub Actions workflow that bumps versions, pushes a release branch, and opens a pull request targeting main.

Changes

Version and release automation

Layer / File(s) Summary
Package version metadata
src/dstrack/__init__.py
__version__ is now loaded from the installed dstrack package metadata.
Manual version bump workflow
.github/workflows/bump.yaml
Adds selectable version bumping, release branch creation, force-push, and automated pull request creation against main.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant GitHubActions
  participant uv
  participant Repository
  participant gh
  GitHubActions->>uv: Bump selected version component
  uv->>Repository: Update package version files
  GitHubActions->>Repository: Commit and force-push release/vVERSION
  GitHubActions->>gh: Create release pull request targeting main
  gh->>Repository: Open pull request
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is relevant and reasonably summarizes the packaging/versioning workflow changes, though it is somewhat broad.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 42-refactor-package-version-bumping

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 60.00000% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/dstrack/__init__.py 60.00% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown

Test Results

   48 files  ±0     48 suites  ±0   1m 11s ⏱️ -9s
  206 tests ±0    206 ✅ ±0  0 💤 ±0  0 ❌ ±0 
4 944 runs  ±0  4 944 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit 159aa60. ± Comparison against base commit 3d1cbd5.

♻️ This comment has been updated with latest results.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
.github/workflows/bump.yaml (1)

43-47: 📐 Maintainability & Code Quality | 🔵 Trivial

Consider using a Personal Access Token (PAT) for PR creation.

Pull requests created using the default GITHUB_TOKEN will not automatically trigger subsequent GitHub Actions workflows (such as CI test runs). If you rely on automated CI testing on release PRs, consider generating a PAT with the necessary permissions, storing it as a repository secret, and using it in place of secrets.GITHUB_TOKEN.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/bump.yaml around lines 43 - 47, Update the PR creation
step using gh pr create to authenticate with a repository secret containing a
PAT instead of secrets.GITHUB_TOKEN. Ensure the PAT has the required repository
permissions and preserves the existing release PR creation behavior, including
the main base, BRANCH head, title, and body.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/dstrack/__init__.py`:
- Around line 1-5: Update the module-level version initialization around
__version__ and importlib.metadata.version to catch PackageNotFoundError when
the dstrack distribution is unavailable, and assign a safe fallback version
instead of failing import. Keep the installed-package version path unchanged.

---

Nitpick comments:
In @.github/workflows/bump.yaml:
- Around line 43-47: Update the PR creation step using gh pr create to
authenticate with a repository secret containing a PAT instead of
secrets.GITHUB_TOKEN. Ensure the PAT has the required repository permissions and
preserves the existing release PR creation behavior, including the main base,
BRANCH head, title, and body.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 0a7e3a4f-5fbe-46f5-8829-921e54d186f9

📥 Commits

Reviewing files that changed from the base of the PR and between 3d1cbd5 and fda5861.

📒 Files selected for processing (2)
  • .github/workflows/bump.yaml
  • src/dstrack/__init__.py

Comment thread src/dstrack/__init__.py Outdated
Comment on lines +1 to +5
from importlib.metadata import version

from . import _logging as _logging

__version__ = "0.1.0"
__version__ = version("dstrack")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Add a fallback for uninstalled environments.

If this module is imported without the package being installed (e.g., during local development without an editable install or in certain test environments), version("dstrack") will raise a PackageNotFoundError and crash the application. Catch this exception to provide a safe fallback.

🛡️ Proposed fix
-from importlib.metadata import version
+from importlib.metadata import PackageNotFoundError, version
 
 from . import _logging as _logging
 
-__version__ = version("dstrack")
+try:
+    __version__ = version("dstrack")
+except PackageNotFoundError:
+    __version__ = "unknown"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
from importlib.metadata import version
from . import _logging as _logging
__version__ = "0.1.0"
__version__ = version("dstrack")
from importlib.metadata import PackageNotFoundError, version
from . import _logging as _logging
try:
__version__ = version("dstrack")
except PackageNotFoundError:
__version__ = "unknown"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/dstrack/__init__.py` around lines 1 - 5, Update the module-level version
initialization around __version__ and importlib.metadata.version to catch
PackageNotFoundError when the dstrack distribution is unavailable, and assign a
safe fallback version instead of failing import. Keep the installed-package
version path unchanged.

…n version cannot be infered from package import failure
@leoyala leoyala merged commit c0fac9b into main Jul 15, 2026
33 of 34 checks passed
@leoyala leoyala deleted the 42-refactor-package-version-bumping branch July 15, 2026 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tools Changes to package development tools.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor package version bumping

1 participant