Skip to content

refactor: consolidate Octopus version checks and support local builds#249

Merged
egorpavlikhin merged 2 commits intomainfrom
refactor/consolidate-version-check
May 6, 2026
Merged

refactor: consolidate Octopus version checks and support local builds#249
egorpavlikhin merged 2 commits intomainfrom
refactor/consolidate-version-check

Conversation

@egorpavlikhin
Copy link
Copy Markdown
Contributor

Summary

  • Five repository methods duplicated the same semver.lt(version, "2022.3.5512") gate, surrounded by identical "this Octopus instance is too old" log/throw boilerplate. Moved that into a single helper ensureServerVersionAtLeast in a new top-level versionCheck module.
  • Locally-built Octopus servers report a version of 0.0.0-local (or just 0.0.0), which semver-compares as less than every real release and was making local-dev workflows hit the version error. The helper now treats any 0.0.0 version — with or without a -prerelease/+build suffix — as satisfying the minimum.
  • Error message wording is preserved verbatim, so anything depending on the exact string keeps working.

What changed

File Change
src/versionCheck.ts New module: isLocalOctopusVersion, isServerVersionAtLeast, ensureServerVersionAtLeast
src/versionCheck.test.ts Pure unit tests (19 cases, no live server required)
src/index.ts Re-export the new module
src/features/projects/releases/releaseRepository.ts create now uses the helper
src/features/projects/runbooks/runs/runbookRunRepository.ts create and createGit use the helper
src/features/projects/releases/deployments/deploymentRepository.ts create and createTenanted use the helper

src/features/capabilities/capability.ts is intentionally untouched — it is a capabilities-API check, not a semver check; it only mentions a version in a fallback error string.

Test plan

  • npx jest src/versionCheck.test.ts — 19/19 pass (covers regex, comparator, throwing helper, and verifies error-message format byte-for-byte)
  • npx tsc --noEmit — clean
  • npm run build — clean
  • grep "lt(serverInformation.version" -r src — no matches (no leftover inline checks)
  • grep -rn 'from "semver"' src — only src/versionCheck.ts still imports it
  • Optional manual smoke test against a 0.0.0-local Octopus server: previously threw the version-too-old error; now should succeed.

🤖 Generated with Claude Code

Five repository methods (release create, runbook create/createGit,
deployment create/createTenanted) duplicated the same `semver.lt` gate
against `2022.3.5512`. Move that into `ensureServerVersionAtLeast` in a
new `versionCheck` module, with helpers `isLocalOctopusVersion` and
`isServerVersionAtLeast`.

The new helper treats any `0.0.0` server version (with optional
prerelease/build suffix, e.g. `0.0.0-local`) as satisfying the minimum,
so locally-built Octopus servers no longer get rejected by these gates.

Error message format is preserved verbatim. Added pure unit tests in
`src/versionCheck.test.ts` (no live server required).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@flin-8 flin-8 left a comment

Choose a reason for hiding this comment

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

LGTM

Comment thread src/versionCheck.ts
// running server is a local development build.
export function isServerVersionAtLeast(serverVersion: string, minimumVersion: string): boolean {
if (isLocalOctopusVersion(serverVersion)) return true;
if (!valid(serverVersion)) return false;
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.

This is a new check, but I think it's fine. It should always be semver afaik

@egorpavlikhin egorpavlikhin merged commit c5d9e4f into main May 6, 2026
5 checks passed
@egorpavlikhin egorpavlikhin deleted the refactor/consolidate-version-check branch May 6, 2026 06:16
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.

3 participants