Repository navigation
Conversation
Greptile SummaryAdds automatic synchronization of workspace-member versions in
Confidence Score: 3/5This PR should not merge until a failed lock synchronization prevents the nightly workflow from pushing an internally inconsistent version-bump commit. The new synchronization script can intentionally exit before modifying Files Needing Attention: .github/workflows/nightly-changelog.yml Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Compile changelog fragments] --> B[Bump package pyproject versions]
B --> C[Run sync_uv_lock.py]
C -->|Success| D[Rewrite workspace versions in uv.lock]
C -->|Failure| E[Lock remains stale]
D --> F[Commit and push]
E --> F
|
There was a problem hiding this comment.
Isaac Lab Review Bot
Summary
Adds tools/changelog/sync_uv_lock.py — a narrow, no-resolve rewriter that re-points workspace-member version lines in uv.lock at each package's pyproject.toml — plus a nightly workflow step that runs it after cli.py compile and stages uv.lock alongside the version bump. The core rewriter is small, well documented, and covered by focused unit tests. The remaining risk is concentrated in the workflow wiring: the new step is invoked unconditionally on every matrix branch even though the workflow already anticipates branches without a lockfile, and a lock rewrite that is written but not staged can leave the worktree dirty right before git pull --rebase, which would wedge the nightly push. There is also a documentation/behavior gap: the module docstring promises to hard-fail on dependency edits, while the guard only compares editable member paths.
Architecture impact
Self-contained CI tooling under tools/changelog/; no runtime or public API surface is touched. Reusing cli.Package.current_version() for version discovery is the right call — it keeps the compiler and the lock sync from drifting on what "the version" means. Choosing a surgical text rewrite over a full uv lock is a reasonable trade-off for an unreviewed auto-commit, provided the narrowness is enforced rather than only documented.
Test coverage
rewrite_versions is well covered: positive rewrite, already-at-target no-op, third-party package left alone, indented dependency rows left alone, block-scoping, and a byte-for-byte diff assertion. The membership guard has three cases. Untested: sync() (the entry point CI actually runs — --check exit code, in-place write, already-in-sync path), read_lock_members, resolve_target_versions, and any run against the real uv.lock shape (virtual root entry, [package.metadata], wheel/sdist sub-tables).
Implementation verdict
Minor fixes needed. Posted 6 actionable findings inline.
Automated comment-only review; human maintainers own approval decisions.
| # hand. | ||
| if: ${{ !inputs.dry_run }} | ||
| run: python3 tools/changelog/sync_uv_lock.py | ||
|
|
There was a problem hiding this comment.
🟡 Warning — Sync step runs unconditionally on branches that may not carry the script or a lockfile
Scheduled runs check out each entry of env.CRON_BRANCHES (currently develop and release/3.0.0-beta2), and manual dispatch accepts any free-text branch. The existing "Verify changelog tooling exists on target branch" step only asserts tools/changelog/cli.py; nothing guarantees the newly added tools/changelog/sync_uv_lock.py or a root uv.lock exists on the checked-out branch. On such a branch this step dies with can't open file .../sync_uv_lock.py (or a raw traceback from the script), reddening that matrix tile every night even though compile and push succeeded — and because the commit step is always(), the version bump still lands with a stale lock. Note the commit step already guards with [ -f uv.lock ], so the guard is missing only here.
| run: | | |
| if [ ! -f tools/changelog/sync_uv_lock.py ] || [ ! -f uv.lock ]; then | |
| echo "::notice::No sync_uv_lock.py / uv.lock on this branch — skipping lock sync." | |
| exit 0 | |
| fi | |
| python3 tools/changelog/sync_uv_lock.py |
| # resolver drift from landing as a lock-only auto-commit under a | ||
| # "Compile changelog fragments" subject. The -f guard keeps branches | ||
| # without a lockfile from aborting the whole ``git add``. | ||
| if [ -f uv.lock ] && ! git diff --staged --quiet -- 'source/*/pyproject.toml'; then |
There was a problem hiding this comment.
🟡 Warning — Unstaged uv.lock rewrite can abort git pull --rebase and wedge the nightly push
sync_uv_lock.py rewrites uv.lock on disk whenever any member version differs from its pyproject.toml, regardless of whether this run bumped anything. This gate only stages the lock when a source/*/pyproject.toml is also staged. In a run where something is staged but no version bumped — e.g. the only pending fragments are .skip files, which are consumed and deleted without a bump, while uv.lock was already stale from an earlier run — git commit succeeds and then git pull --rebase origin refs/heads/$TARGET_BRANCH fails with "cannot pull with rebase: You have unstaged changes." The push never happens, the fragments are never cleaned, and the same failure repeats the next night. Either discard the unstaged rewrite in the non-bump branch, or add --autostash to the rebase pull.
| if [ -f uv.lock ] && ! git diff --staged --quiet -- 'source/*/pyproject.toml'; then | |
| if [ -f uv.lock ] && ! git diff --staged --quiet -- 'source/*/pyproject.toml'; then | |
| git add uv.lock | |
| elif [ -f uv.lock ]; then | |
| # Drop an unstaged lock rewrite so the `git pull --rebase` below | |
| # does not abort with "you have unstaged changes". | |
| git checkout -- uv.lock | |
| fi |
|
|
||
| That narrowness is also its limit. The script deliberately fails when the | ||
| lock is stale in a way a version rewrite cannot fix (a package added to or | ||
| removed from ``source/``, or a dependency edit), because those genuinely |
There was a problem hiding this comment.
🟡 Warning — Docstring promises a dependency-edit hard-fail the guard does not implement
The docstring states the script "deliberately fails when the lock is stale in a way a version rewrite cannot fix (a package added to or removed from source/, or a dependency edit)", but assert_lock_is_repairable() only compares the set of editable member paths. If a member's dependencies, markers, extras, or requires-python changed without a re-lock, the script reports success, the workflow stages the lock, and uv sync --locked still rejects it — now with a green sync step masking the problem. Either narrow the docstring to what is actually enforced (membership only), or add a real freshness check (e.g. uv lock --check after the rewrite, with uv pinned in the workflow) so this class of staleness fails loudly.
| return "".join(out), changes | ||
|
|
||
|
|
||
| def sync(lock_path: Path = LOCK_PATH, *, check: bool) -> int: |
There was a problem hiding this comment.
🔵 Suggestion — sync() does not forward a matching root pyproject.toml
sync(lock_path=...) passes only lock_path to assert_lock_is_repairable, so the membership guard always compares against the repo-root pyproject.toml even when the caller points at a lock elsewhere. That silently pairs mismatched files and makes sync() awkward to test with tmp_path fixtures. Accept and forward a root_toml_path parameter so the two files stay paired. (Related: PACKAGE_HEADER on line 52 is defined but never used — rewrite_versions keys off line.startswith("[") — so it can be dropped.)
| def sync(lock_path: Path = LOCK_PATH, *, check: bool) -> int: | |
| def sync(lock_path: Path = LOCK_PATH, root_toml_path: Path = ROOT_TOML_PATH, *, check: bool) -> int: | |
| """Sync (or, under ``check``, report on) the lock. Returns a process exit code.""" | |
| assert_lock_is_repairable(lock_path, root_toml_path) |
|
|
||
| def sync(lock_path: Path = LOCK_PATH, *, check: bool) -> int: | ||
| """Sync (or, under ``check``, report on) the lock. Returns a process exit code.""" | ||
| assert_lock_is_repairable(lock_path) |
There was a problem hiding this comment.
🔵 Suggestion — Missing uv.lock / [tool.uv.sources] surfaces as a raw traceback
sync() calls assert_lock_is_repairable(lock_path) unconditionally, which reads uv.lock via read_text and indexes data["tool"]["uv"]["sources"]. On a branch that carries tools/changelog/ but no lockfile (a case the workflow's own [ -f uv.lock ] guard anticipates), this raises an unhandled FileNotFoundError/KeyError. Returning early with a clear message makes "no lockfile here" a clean no-op instead of a recurring red tile.
| assert_lock_is_repairable(lock_path) | |
| if not lock_path.exists(): | |
| print(f"{_display_path(lock_path)} does not exist — nothing to sync.") | |
| return 0 | |
| assert_lock_is_repairable(lock_path) |
| return lock, root | ||
|
|
||
|
|
||
| def test_matching_membership_passes(tmp_path): |
There was a problem hiding this comment.
🔵 Suggestion — No coverage for sync() or for the real uv.lock shape
All assertions target the pure helpers against a 24-line synthetic fixture. sync() — the path the workflow actually invokes — is never called, so the --check non-zero exit, the in-place write (a regression writing text instead of updated would pass every current test), and the already-in-sync branch are unverified. The fixture also omits shapes the real lock contains (the virtual workspace root source = { virtual = "." }, [package.metadata], wheel/sdist sub-tables), so a uv format change would only surface at 5 AM in the auto-commit job. Add (a) sync() tests over a tmp_path lock+root pair covering check-mode exit 1, the write path, and the idempotent second run, and (b) a gate against the checked-in files that also exercises read_lock_members / resolve_target_versions.
| def test_matching_membership_passes(tmp_path): | |
| def test_repo_lock_is_repairable_and_in_sync(): | |
| sync_uv_lock.assert_lock_is_repairable() | |
| text = sync_uv_lock.LOCK_PATH.read_text(encoding="utf-8") | |
| _, changes = sync_uv_lock.rewrite_versions(text, sync_uv_lock.resolve_target_versions()) | |
| assert changes == [] |
|
Correct me if I am wrong. My understanding is that nightly job bumps version pyproject and left uvlock now, so the only purpose of to match the version in lock to pyproject. Three main comments:
I do have a changelog refactor PR pending which i have not got time to finish. But I think to have default branch only carry the trigger, and have cli part handles all the logic including committing files is more scalable as that could avoid a change to be needed in multiple places. #5867 |
The nightly bumps each package's version metadata file, but uv.lock pins those same workspace members by version. Left behind, every `uv sync --locked` / `--frozen` consumer fails with "the lockfile needs to be updated" until a human re-locks by hand. Add a LockFile class that rewrites only the workspace members' own version lines -- no network, no resolution, no third-party churn -- and call it from AutoBumpRun once every package has compiled. uv.lock is a single repo-level artifact pinning all members at once, so the sync is global rather than per-package. The written path joins the same touched-paths manifest the compiler feeds, which is what gets the lock staged and committed alongside the bump it belongs to, in one commit, with no separate `git add` to keep in step. That matters because uv.lock sits at the repo root, outside source/, so no `git add source/...` glob can reach it at all -- the second instance of the producer/consumer drift the auto-bump subcommand removes. The sync refuses to touch a lock whose membership no longer matches [tool.uv.sources]: a package added or removed brings dependency edges a version rewrite cannot invent, and needs a real `uv lock` with a reviewed diff. That failure reds the tile but does not block the commit, since such a lock was already stale before the run started and wedging the nightly would strand every package's changelog. Measured on develop: the surgical rewrite takes `uv lock --check` from exit 1 to exit 0 with an 8-line diff, where a full `uv lock` rewrites 3136 lines of marker-expansion churn that no reviewer would read in an unattended 5 AM commit. Carries the uv.lock sync from isaac-sim#6727, restructured as a class and folded into the auto-bump lifecycle per the review discussion there.
The nightly bumps each package's version metadata file, but uv.lock pins those same workspace members by version. Left behind, every `uv sync --locked` / `--frozen` consumer fails with "the lockfile needs to be updated" until a human re-locks by hand. Add a LockFile class that rewrites only the workspace members' own version lines -- no network, no resolution, no third-party churn -- and call it from AutoBumpRun once every package has compiled. uv.lock is a single repo-level artifact pinning all members at once, so the sync is global rather than per-package. The written path joins the same touched-paths manifest the compiler feeds, which is what gets the lock staged and committed alongside the bump it belongs to, in one commit, with no separate `git add` to keep in step. That matters because uv.lock sits at the repo root, outside source/, so no `git add source/...` glob can reach it at all -- the second instance of the producer/consumer drift the auto-bump subcommand removes. The sync refuses to touch a lock whose membership no longer matches [tool.uv.sources]: a package added or removed brings dependency edges a version rewrite cannot invent, and needs a real `uv lock` with a reviewed diff. That failure reds the tile but does not block the commit, since such a lock was already stale before the run started and wedging the nightly would strand every package's changelog. Measured on develop: the surgical rewrite takes `uv lock --check` from exit 1 to exit 0 with an 8-line diff, where a full `uv lock` rewrites 3136 lines of marker-expansion churn that no reviewer would read in an unattended 5 AM commit. Carries the uv.lock sync from isaac-sim#6727, restructured as a class and folded into the auto-bump lifecycle per the review discussion there.
Description
Bump the uv lock when bumping nightly version to avoid mismatch.
Checklist
pre-commitchecks with./isaaclab.sh --formatsource/<pkg>/changelog.d/for every touched package (do not editCHANGELOG.rstor bumpextension.toml— CI handles that)CONTRIBUTORS.mdor my name already exists there