Skip to content

fix(xtest): make otdf-sdk-mgr check out go from the platform monorepo - #676

Draft
dmihalcik-virtru wants to merge 1 commit into
DSPX-4372-sdkmgr-moved-tagsfrom
DSPX-4372-sdkmgr-checkout-go
Draft

dmihalcik-virtru wants to merge 1 commit into
DSPX-4372-sdkmgr-moved-tagsfrom
DSPX-4372-sdkmgr-checkout-go

Conversation

@dmihalcik-virtru

Copy link
Copy Markdown
Member

Fourth follow-up from #667's review. Based on #675 (DSPX-4372-sdkmgr-moved-tags).

What it does

  • checkout go <ref> and checkout --all work. The checkout command handed every SDK to checkout_sdk_branch, which raises ValueError for go now that otdfctl's source lives in the platform monorepo. So otdf-sdk-mgr checkout go main, the README's example, always failed. checkout --all failed on go too, and go is first in ALL_SDKS, so js and java were never checked out. go now goes to checkout_go_from_platform, as installers.cmd_tip already does for install tip. That creates the platform worktree at sdk/go/platform-src/<slug> and symlinks sdk/go/src/<slug> to its otdfctl/, without building.
  • Errors read like install tip's. tip's handler is now cli_install.exit_with_error, and both commands call it. A failed git command shows the stderr checkout._run captured, such as fatal: invalid reference: no-such-ref, not only Command [...] returned non-zero exit status 128. A RuntimeError (a platform ref older than otdfctl/, or no git binary) is an Error: line instead of a traceback.
  • checkout still catches ValueError, not only its subclass CheckoutError, so checkout rust stays a one-line "Unsupported language" error. typer.Exit is a RuntimeError, so the missing-SDK usage error is re-raised before that clause; otherwise it would print a second, empty Error:.
  • Expected conflict with feat(xtest): headless-browser web SDK flavour alongside js #650. feat(xtest): headless-browser web SDK flavour alongside js #650 changes the same loop, from for s in ALL_SDKS: to for s in DEFAULT_SDKS:. This PR changes only the loop body, so cli.py gets one two-line conflict (checked with git merge-file against feat(xtest): headless-browser web SDK flavour alongside js #650's head). Resolve it as:
                for s in DEFAULT_SDKS:
                    _checkout_one(s, branch)
    The import change and cli_install.py merge cleanly. checkout web then goes through checkout_sdk_branch and feat(xtest): headless-browser web SDK flavour alongside js #650's alias to js, the same way install tip web does.

Validation

  • uv run pytest in otdf-sdk-mgr: 268 passed (6 new). ruff, ruff format and pyright are clean.
  • The new TestCheckoutCommand tests run the command through CliRunner with real git against a local origin. The origin fixture now stands in for java as well, so nothing reaches the network. The cases:
    • checkout go main: the worktree and symlink are at origin's tip.
    • checkout --all main: go, js and java are all at origin's tip.
    • A ref origin doesn't have: git's stderr is shown.
    • A go ref without otdfctl/: an Error: line, no traceback.
    • The no-SDK and unknown-SDK usage errors are each reported once.
  • Against fix(xtest): make otdf-sdk-mgr follow tags moved upstream #675's code, 4 of the 6 fail. go and --all fail with "checkout_sdk_branch does not support 'go'", and the stderr test finds no git stderr in the output. The two usage-error cases pass before and after; they guard the wider handler.
  • Mutation-checked: removing the typer.Exit re-raise fails the no-SDK case (a second Error:), removing RuntimeError fails the otdfctl case (a traceback), and narrowing ValueError to CheckoutError fails the unknown-SDK case.

Not done here

  • The README documents checkout go main but not --all, which only appears in --help. Left as is.
  • install tip with an unknown SDK name still dies with a KeyError from cmd_tip's sdk_dirs[sdk] before it gets to the checkout. That is a separate bug.

Stack

Follow-ups from #667's review, each based on the one before:

PR Fix
#673 refuse to reset a directory that isn't a worktree
#674 platform branch names, and reset vs reuse decided from origin
#675 follow tags moved upstream
this PR checkout go / checkout --all

@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

dmihalcik-virtru added a commit that referenced this pull request Oct 23, 2026
…pted js installs (#667)

Part 2a of the [DSPX-4372-t1
plan](#657), split out of #626:
fixes the benchmark needs, which every `otdf-sdk-mgr` install benefits
from. **Based on `main`.**

### What it does
- **Bare repos refresh their branches.** `git clone --bare` records no
fetch refspec, so the `fetch --all --tags` before every checkout
refreshed tags only. Every branch stayed where the first clone found it,
and `install tip main` or `--platform main` built that stale commit.
`checkout.BARE_REFRESH` now fetches origin's branches into
`refs/remotes/origin/*` with `--prune`, for the SDK and platform bare
repos alike, and `checkout.upstream_ref` maps a branch name onto them.
Fetching into the bare repo's own `refs/heads/*` instead would move
branches that other worktrees have checked out, leaving their HEAD ahead
of their files, and would fail for good once upstream replaced a branch
`foo` with `foo/bar`.
- **Worktrees are detached** and reset to the refreshed ref. A branch
origin no longer has is refused rather than built from the clone's stale
copy, and `HEAD` means origin's default branch as of the clone; a
platform `HEAD` worktree used to reset to itself.
- **Go source rebuilds work a second time.** `checkout_go_from_platform`
reset an existing worktree to a `FETCH_HEAD` fetched into the bare repo,
which no worktree can see, so every rebuild after the first failed with
`pathspec 'FETCH_HEAD' did not match`. It now resets to the refreshed
ref, like the SDK and platform paths.
- **`install tip` reports checkout failures as errors.** A refused
branch, or a failed git command with git's stderr, now prints `Error: …`
and exits 1 for go, js and java, as the platform path already did,
instead of a traceback.
- **An interrupted js install leaves nothing behind.** #663 already
removes a partial `dist/` when npm fails. A Ctrl-C mid-install still
left a directory holding only `cli.sh`, which `install_release` then
skipped as installed from then on. Both js install paths now remove it
unless the install finished.
- `AGENTS.md` claimed the bare clone mapped `refs/heads/*`, which is
what hid the first bug. It and the code comments also said `git pull`
fails in a worktree; it merges origin's default branch into whatever is
checked out.

### Validation
- `uv run pytest` in `otdf-sdk-mgr`: 207 passed, and 321 at the top of
this track (#642). ruff, ruff format and pyright are clean.
- `test_checkout.py` runs real git against a local origin. Every shared
behaviour is parametrized over the SDK, go and platform entry points:
new and existing worktrees follow their branch, `HEAD` (including beside
a tag named `main`), a deleted branch is refused, tags and SHAs are
checked out and then reused, and a force-pushed `refs/pull/N/head` is
followed. This replaces the stubbed command-string test for platform PR
refs. SDK-only tests guard other worktrees, force pushes and `x` → `x/y`
renames; platform-only tests cover the helper-scripts worktree. A
`CliRunner` test covers the `install tip` error path.
- Mutation-checked: `symbolic-ref --short`, treating every non-origin
name as a deleted branch, dropping go's explicit PR-ref fetch or its
`+`, swallowing go's refusal, and dropping the `install tip` catch each
fail a test.
- Two new tests interrupt each js install path.
- `isolated_git` keeps those tests off the developer's git config, any
inherited `GIT_DIR`, and the network (`GIT_ALLOW_PROTOCOL=file`).

### Follow-ups
Older problems found while reviewing this PR are fixed in a stack of
drafts based on it: #673 (don't reset a directory that isn't a worktree)
→ #674 (branch names vs versions) → #675 (tags moved upstream) → #676
(`checkout go` / `--all`).

### Stack ([DSPX-4372-t1
plan](#657))

Two parallel tracks from `main`; they share no imports and meet in stage
5.

| Part | PR | Base |
|---|---|---|
| 2a: bare-repo and js install fixes | **#667 (this PR)** | `main` |
| 2b: manifest contract | #668 | 2a |
| 2c: `install benchmark` | #626 | 2b |
| 2d: `otdf-local env` exports | #642 | 2c |
| 3a: arms as a tuple | #669 | `main` |
| 3b: two to four arms | #658 | 3a |
| 3c: pytest reads the manifest | #670 | 3b |
| 4: candidate-to-candidate conclusions | #659 | 3c |
| 5, 6: CI and report | #660, #661 | not yet moved onto these stacks |



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **Bug Fixes**
* SDK and platform worktrees now follow updated branches and pull
request refs, including after force-pushes. Missing branches produce a
clear error instead of a traceback.
* Interrupted JavaScript installations no longer leave partial
distribution files behind.

* **Documentation**
* Updated platform installation guidance for branch refreshes, detached
worktrees, and pull request refs.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Signed-off-by: Dave Mihalcik <dmihalcik@virtru.com>
`otdf-sdk-mgr checkout go <ref>`, the README's example, always failed:
the command handed every SDK to checkout_sdk_branch, which refuses go
because otdfctl's source now comes from the platform monorepo through
checkout_go_from_platform. `checkout --all` failed the same way, and
since go is first in ALL_SDKS, it stopped before js or java was checked
out.

The command now sends go to checkout_go_from_platform, as
installers.cmd_tip already does for `install tip`. That adds the
platform worktree under sdk/go/platform-src/<slug> and links
sdk/go/src/<slug> to its otdfctl/, without the build.

Its errors now read like `install tip`'s. tip's handler moves into
cli_install.exit_with_error, which both commands call, so a failed git
command shows the stderr checkout._run captured, not only the command
and its exit status. A RuntimeError, from a platform ref that predates
otdfctl/ or a missing git binary, is reported rather than raised as a
traceback. The command still catches ValueError, not just its subclass
CheckoutError, so an unknown SDK name stays a one-line error. typer.Exit
is a RuntimeError too, so the missing-SDK usage error is re-raised ahead
of that clause; otherwise it would be reported a second time as a bare
`Error:`.

The tests drive the command through CliRunner with real git against the
local origin, which now stands in for java as well: `checkout go main`,
`checkout --all main`, git's stderr for a ref origin doesn't have, a go
ref without otdfctl/, and each usage error reported once. The first four
failed before the fix; the usage errors pass either way and guard the
wider handler.

Signed-off-by: Dave Mihalcik <dmihalcik@virtru.com>
@dmihalcik-virtru
dmihalcik-virtru force-pushed the DSPX-4372-sdkmgr-checkout-go branch from 27d0715 to 779ddbc Compare October 23, 2026 14:02
@dmihalcik-virtru
dmihalcik-virtru force-pushed the DSPX-4372-sdkmgr-moved-tags branch from f0ea7c8 to 394fb42 Compare October 23, 2026 14:02
@github-actions

Copy link
Copy Markdown

X-Test Failure Report

@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant