Skip to content

Add nightly bump for uv lock - #6727

Closed
StafaH wants to merge 3 commits into
isaac-sim:developfrom
StafaH:mh/nightly_uvlock_bump
Closed

StafaH wants to merge 3 commits into
isaac-sim:developfrom
StafaH:mh/nightly_uvlock_bump

Conversation

@StafaH

@StafaH StafaH commented Jul 26, 2026

Copy link
Copy Markdown
Collaborator

Description

Bump the uv lock when bumping nightly version to avoid mismatch.

Checklist

  • I have read and understood the contribution guidelines
  • I have run the pre-commit checks with ./isaaclab.sh --format
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • I have added a changelog fragment under source/<pkg>/changelog.d/ for every touched package (do not edit CHANGELOG.rst or bump extension.toml — CI handles that)
  • I have added my name to the CONTRIBUTORS.md or my name already exists there

@greptile-apps

greptile-apps Bot commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds automatic synchronization of workspace-member versions in uv.lock during nightly changelog compilation.

  • Introduces a narrowly scoped lockfile version rewriter with workspace-membership validation.
  • Runs the rewriter after nightly package version bumps and stages uv.lock with bumped manifests.
  • Adds unit coverage for selective rewriting and membership mismatch handling.

Confidence Score: 3/5

This 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 uv.lock, while the downstream always() commit step still stages and pushes the bumped package manifests, preserving the exact stale-lock failure the PR is intended to eliminate.

Files Needing Attention: .github/workflows/nightly-changelog.yml

Important Files Changed

Filename Overview
.github/workflows/nightly-changelog.yml Adds lock synchronization and staging, but still commits and pushes version bumps when synchronization fails.
tools/changelog/sync_uv_lock.py Implements a focused workspace-version rewrite with safeguards against stale workspace membership.
tools/changelog/test/test_sync_uv_lock.py Covers intended version rewrites, preservation of unrelated lock content, and membership validation.

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
Loading

Comments Outside Diff (1)

  1. .github/workflows/nightly-changelog.yml, line 218 (link)

    P1 Failed sync still gets committed

    When sync_uv_lock.py exits before rewriting the lock, such as on a workspace-membership mismatch, always() still runs the commit step and pushes the bumped pyproject.toml files with a stale uv.lock, causing locked and frozen uv consumers to continue failing.

Reviews (1): Last reviewed commit: "Add nightly bump for lock as well" | Re-trigger Greptile

@isaaclab-review-bot isaaclab-review-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 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.

Suggested change
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 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.

Suggested change
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 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:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 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.)

Suggested change
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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 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.

Suggested change
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):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 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.

Suggested change
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 == []

@hujc7

hujc7 commented Jul 26, 2026 •

Copy link
Copy Markdown
Collaborator

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:

  1. It might be preferred to model the utility into a class altering uvlock file, which will make it easier to maintain and expand if ever needed
  2. As the version bump of pyproject happens in changelog/cli, it might be preferred to auto call this as part of the changelog workflow instead of a separate step
  3. the workflow part is only triggered from the default(main) branch, so we will need to cherry-pick the workflow changes there. And make it account for the situations things might be different on branches

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

hujc7 added a commit to hujc7/IsaacLab that referenced this pull request Jul 26, 2026
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.
@StafaH StafaH closed this Jul 27, 2026
@StafaH
StafaH deleted the mh/nightly_uvlock_bump branch July 27, 2026 22:57
hujc7 added a commit to hujc7/IsaacLab that referenced this pull request Jul 31, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants