Skip to content

[CFX-4450] dr self update --version - #788

Open
taras-pokornyy wants to merge 5 commits into
datarobot-oss:mainfrom
taras-pokornyy:CFX-4450_self_update_version
Open

[CFX-4450] dr self update --version#788
taras-pokornyy wants to merge 5 commits into
datarobot-oss:mainfrom
taras-pokornyy:CFX-4450_self_update_version

Conversation

@taras-pokornyy

@taras-pokornyy taras-pokornyy commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

RATIONALE

dr self update could only ever install the latest release — there was no way to pin a specific version. This blocks reproducible environments, rollback-for-testing, and matching a specific dr version to a teammate's or CI's. This change adds a --version flag with strict validation, refuses downgrades, and hard-errors under Homebrew (which can't pin versions at all).

While implementing this, the existing Homebrew-cask detection was found to be macOS-only (if runtime.GOOS == "darwin"), even though Homebrew ("Linuxbrew") is a documented, supported install method on Linux too (README.md's own "Install via Homebrew / Linuxbrew" section). A Linux user on a brew-managed install would previously fall straight through to the raw curl | sh path, bypassing brew entirely and getting no protection from the new --version-under-Homebrew guard. This is fixed alongside the main feature.

CHANGES

  • Added --version <version> flag to dr self update (no shorthand, not settable via any env var).
    • normalizeAndValidateVersion: strict vMAJOR.MINOR.PATCH validation (optional leading v, optional -prerelease/+build suffix), normalized to a v-prefixed form. Uses a regex rather than the semver library's lenient parser, since the ticket's own example ("1.2" → error) would otherwise silently pass.
    • refuseDowngrade: uses github.com/Masterminds/semver/v3 to block installing a version older than the one currently running; skipped entirely for non-release ("dev") builds.
    • The existing "already sufficient, skip update" short-circuit no longer swallows an explicit --version request.
  • Extracted the Homebrew-cask update logic into tryBrewUpdate, and extended it to run on both darwin and linux (previously darwin-only), consolidated into the single switch runtime.GOOS { case "darwin", "linux": ... } dispatch instead of a separate standalone if block. Shell detection now only runs when actually needed (previously called unconditionally, even for the brew-handled path and for Windows where it's unused).
    • brewCaskVersionError: hard error returned when --version is passed but dr is installed via the Homebrew cask, with the manual install.sh command to run instead.
  • Threaded targetVersion into the non-brew install paths: appended to the curl | sh invocation (sh -s -- <version>) and set via $env:VERSION='<version>'; before the PowerShell one-liner on Windows — both install scripts already supported pinned versions, this just wires the flag through.

PR Automation

Comment-Commands: Trigger CI by commenting on the PR:

  • /trigger-smoke-test or /trigger-test-smoke - Run smoke tests
  • /trigger-install-test or /trigger-test-install - Run installation tests

Labels: Apply labels to trigger workflows:

  • run-smoke-tests or go - Run smoke tests on demand (only works for non-forked PRs)

Important

For Forked PRs: The run-smoke-tests label won't work. A required Smoke Tests check will block merge until a maintainer acts:

  • A maintainer uses /approve-smoke-tests to run smoke tests (results will set the check)
  • A maintainer uses /skip-smoke-tests to bypass the check without running tests

Please comment requesting a maintainer review if you need smoke tests to run.


Note

Medium Risk
Changes how the CLI replaces itself (brew reinstall and remote install scripts) on user machines; behavior is well-tested but mistakes could break updates or pin the wrong release.

Overview
Adds --version to dr self update so users can install a specific release (vX.Y.Z or X.Y.Z) instead of always taking latest. Versions are validated with a strict MAJOR.MINOR.PATCH regex, normalized to a v prefix, and downgrades are refused against the running binary (skipped for dev builds). An explicit --version request is no longer blocked by the “already sufficient, skip update” shortcut.

Pinned installs are wired into the existing install scripts on Windows ($env:VERSION) and Unix shell (install.sh -s -- <version>). Homebrew cask installs cannot pin versions; --version now returns a guided error with the manual install.sh command.

Homebrew self-update logic is refactored into tryBrewUpdate and extended from macOS-only to macOS and Linux, so Linuxbrew-managed dr-cli cask installs use brew update / reinstall instead of falling through to curl | sh. Shell detection runs only when the generic install path is needed.

User docs (README, self, quick reference) and unit tests for validation, downgrade refusal, and the Homebrew pin error are updated. CI pins Taskfile to 3.52.0.

Reviewed by Cursor Bugbot for commit 2b841ea. Configure here.

@datarobot-pr-review-router

Copy link
Copy Markdown

🎫 Jira: CFX-4450 — dr self update - flag to update to specific version

@taras-pokornyy

Copy link
Copy Markdown
Contributor Author

/approve-smoke-tests

@github-actions

Copy link
Copy Markdown
Contributor

🔐 Fork PR smoke tests triggered by @taras-pokornyy

⚠️ Security Notice: This will run tests with access to repository secrets.

What happens next:

  1. Security scans will run automatically (Trivy, gosec)
  2. If security scans pass, smoke tests will run
  3. Results will be posted as PR comments

⚠️ Important: Review the PR code carefully before approving!

Warning

This PR modifies files under .github/, which may alter CI workflows, branch protection rules, or secrets handling. Review these changes carefully before proceeding — malicious workflow changes could exfiltrate secrets.

Changed files:

  • .github/actions/setup/action.yaml

@github-actions

Copy link
Copy Markdown
Contributor

🔐 Fork smoke tests started by maintainer

⏳ Security scans passed. Running smoke tests...

Commit: 2b841ea44b00d84d6c72a52b9be61846584963ec
View run

Warning

This PR modifies files under .github/, which may alter CI workflows, branch protection rules, or secrets handling. Review these changes carefully before proceeding — malicious workflow changes could exfiltrate secrets.

Changed files:

  • .github/actions/setup/action.yaml

@github-actions

Copy link
Copy Markdown
Contributor

All smoke tests passed! (Fork PR)

✅ Security Scan: success
✅ Linux: success
✅ Windows: success

View run details

@taras-pokornyy
taras-pokornyy marked this pull request as ready for review August 18, 2026 17:23
@taras-pokornyy
taras-pokornyy requested a review from a team as a code owner August 18, 2026 17:23
@taras-pokornyy taras-pokornyy self-assigned this Aug 18, 2026

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 2b841ea. Configure here.

uses: arduino/setup-task@c0bc642852239c2689f73f4ea6459c29405f3c52 # v3.0.0
with:
version: 3.x
version: 3.52.0

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Composite action CI not exercised

Low Severity

This PR pins Taskfile to 3.52.0 in the reusable setup composite action. Reusable workflows still pull that action via @main, so this PR’s CI does not exercise the new pin—only post-merge runs will. The change needs a branch-ref CI check or a manual workflow_dispatch verification after merge.

Fix in Cursor Fix in Web

Triggered by project rule: Bugbot Rules for DataRobot CLI

Reviewed by Cursor Bugbot for commit 2b841ea. Configure here.

@chasdr

chasdr commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Hi Taras - 1 question before I approve:

the rationale lists rollback-for-testing as a motivation, but refuseDowngrade blocks every older version on a release build and --force doesn't bypass it.

install.sh itself supports downgrade (the [y/N] prompt, and it proceeds non-interactively when piped), so the capability's there at the script layer.

should --force let --version go backwards?

ahjota
ahjota previously approved these changes Aug 18, 2026
Comment thread cmd/self/update/cmd.go Outdated
Comment thread cmd/self/update/cmd.go
Comment thread cmd/self/update/cmd.go Outdated
func brewCaskVersionError(targetVersion string) error {
return fmt.Errorf(
"dr was installed via Homebrew (dr-cli cask). Homebrew always installs the latest release and cannot pin versions.\n\n"+
"To install %s manually, uninstall the cask and run:\n\n"+

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.

maybe "... manually, brew uninstall --cask dr-cli and run`:

Comment thread cmd/self/update/cmd.go Outdated
Comment thread cmd/self/update/cmd.go
Comment thread docs/commands/self.md Outdated
Comment thread docs/commands/self.md
# Update to latest version
dr self update

# Install a specific version

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.

Appreciate that you made either one available.

Comment thread docs/index.md
- [dotenv](commands/dotenv.md)&mdash;environment variable management with interactive wizard and validation.
- [completion](commands/completion.md)&mdash;shell completion setup (install/uninstall or generate for bash, zsh, fish, PowerShell).
- [self](commands/self.md)&mdash;CLI utility commands (version, update, config, completion, and plugin authoring: add, publish, package).
- [self](commands/self.md)&mdash;CLI utility commands (version, update &mdash; including installing a specific released version, config, completion, and plugin authoring: add, publish, package).

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.

Not necessary

@taras-pokornyy

Copy link
Copy Markdown
Contributor Author

Hi Taras - 1 question before I approve:

the rationale lists rollback-for-testing as a motivation, but refuseDowngrade blocks every older version on a release build and --force doesn't bypass it.

install.sh itself supports downgrade (the [y/N] prompt, and it proceeds non-interactively when piped), so the capability's there at the script layer.

should --force let --version go backwards?

Hey @chasdr !
Thank you for comment. Actually it's a very good point!
Description of CFX-4450 says refusal to downgrade .
I believe it would be good to allow --force downgrade the version of dr-cli

@ajalon1 , do we want to allow --force to downgrade dr-cli version ?

@taras-pokornyy

Copy link
Copy Markdown
Contributor Author

/approve-smoke-tests

@github-actions

Copy link
Copy Markdown
Contributor

🔐 Fork PR smoke tests triggered by @taras-pokornyy

⚠️ Security Notice: This will run tests with access to repository secrets.

What happens next:

  1. Security scans will run automatically (Trivy, gosec)
  2. If security scans pass, smoke tests will run
  3. Results will be posted as PR comments

⚠️ Important: Review the PR code carefully before approving!

Warning

This PR modifies files under .github/, which may alter CI workflows, branch protection rules, or secrets handling. Review these changes carefully before proceeding — malicious workflow changes could exfiltrate secrets.

Changed files:

  • .github/actions/setup/action.yaml

@github-actions

Copy link
Copy Markdown
Contributor

🔐 Fork smoke tests started by maintainer

⏳ Security scans passed. Running smoke tests...

Commit: 115496c7d116f7e0f43b44c4a979875901458d26
View run

Warning

This PR modifies files under .github/, which may alter CI workflows, branch protection rules, or secrets handling. Review these changes carefully before proceeding — malicious workflow changes could exfiltrate secrets.

Changed files:

  • .github/actions/setup/action.yaml

@github-actions

Copy link
Copy Markdown
Contributor

All smoke tests passed! (Fork PR)

✅ Security Scan: success
✅ Linux: success
✅ Windows: success

View run details

@ajalon1

ajalon1 commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

do we want to allow --force to downgrade dr-cli version ?

@taras-pokornyy discussed in standup, but yes, if we allow --force to upgrade, we should also allow it to downgrade.

ajalon1 added a commit to ajalon1/derkeley that referenced this pull request Aug 19, 2026
`version: 3.x` in the three arduino/setup-task call sites floats to
whatever go-task/task release GitHub reports as latest on every run.
go-task/task cut v3.53.1 on 2026-08-18 but its release assets weren't
fully published until ~18 minutes after the tag was created; our
build-windows and smoke-test (macos-latest) jobs ran in that window,
resolved the brand-new tag, and 404'd downloading its binary:

  Failed to download version v3.53.1: Unexpected HTTP response: 404

Pin to the exact, already-published 3.52.0 to close the race, matching
the project's existing convention of pinning tool versions explicitly
(GOLANGCI_LINT_VERSION, LEFTHOOK_VERSION, JSCPD_VERSION,
GORELEASER_VERSION in Taskfile.yaml).

The action.yaml pin mirrors the fix Taras Pokornyy already landed for
that call site in datarobot-oss#788; this extends it to the two other call sites
his PR doesn't touch.

Ref: CFX-7669

Co-authored-by: Taras Pokornyy <34406052+taras-pokornyy@users.noreply.github.com>
ajalon1 added a commit that referenced this pull request Aug 19, 2026
fix(ci): pin arduino/setup-task Task version to 3.52.0

`version: 3.x` in the three arduino/setup-task call sites floats to
whatever go-task/task release GitHub reports as latest on every run.
go-task/task cut v3.53.1 on 2026-08-18 but its release assets weren't
fully published until ~18 minutes after the tag was created; our
build-windows and smoke-test (macos-latest) jobs ran in that window,
resolved the brand-new tag, and 404'd downloading its binary:

  Failed to download version v3.53.1: Unexpected HTTP response: 404

Pin to the exact, already-published 3.52.0 to close the race, matching
the project's existing convention of pinning tool versions explicitly
(GOLANGCI_LINT_VERSION, LEFTHOOK_VERSION, JSCPD_VERSION,
GORELEASER_VERSION in Taskfile.yaml).

The action.yaml pin mirrors the fix Taras Pokornyy already landed for
that call site in #788; this extends it to the two other call sites
his PR doesn't touch.

Co-authored-by: Taras Pokornyy <34406052+taras-pokornyy@users.noreply.github.com>
Comment thread cmd/self/update/cmd.go Outdated
Comment on lines +62 to +64
if err := refuseDowngrade(targetVersion); err != nil {
return err
}

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.

looks like standup landed on letting --force downgrade. this still runs unconditionally, so --force can't get past it. gate it?

Suggested change
if err := refuseDowngrade(targetVersion); err != nil {
return err
}
if !force {
if err := refuseDowngrade(targetVersion); err != nil {
return err
}
}

(and the "refuses to install older" line in README + self.md could mention the --force escape hatch)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in commit : 2af4af1

@taras-pokornyy

Copy link
Copy Markdown
Contributor Author

/approve-smoke-tests

@github-actions

Copy link
Copy Markdown
Contributor

🔐 Fork PR smoke tests triggered by @taras-pokornyy

⚠️ Security Notice: This will run tests with access to repository secrets.

What happens next:

  1. Security scans will run automatically (Trivy, gosec)
  2. If security scans pass, smoke tests will run
  3. Results will be posted as PR comments

⚠️ Important: Review the PR code carefully before approving!

Warning

This PR modifies files under .github/, which may alter CI workflows, branch protection rules, or secrets handling. Review these changes carefully before proceeding — malicious workflow changes could exfiltrate secrets.

Changed files:

  • .github/actions/setup/action.yaml

@github-actions

Copy link
Copy Markdown
Contributor

🔐 Fork smoke tests started by maintainer

⏳ Security scans passed. Running smoke tests...

Commit: 2af4af1aa1a874727c86bee82ae4eb1f2e1c1f64
View run

Warning

This PR modifies files under .github/, which may alter CI workflows, branch protection rules, or secrets handling. Review these changes carefully before proceeding — malicious workflow changes could exfiltrate secrets.

Changed files:

  • .github/actions/setup/action.yaml

@github-actions

Copy link
Copy Markdown
Contributor

All smoke tests passed! (Fork PR)

✅ Security Scan: success
✅ Linux: success
✅ Windows: success

View run details

@ajalon1
ajalon1 dismissed ahjota’s stale review August 26, 2026 15:40

not a maintainer

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.

4 participants