refactor: consolidate Octopus version checks and support local builds#249
Merged
egorpavlikhin merged 2 commits intomainfrom May 6, 2026
Merged
refactor: consolidate Octopus version checks and support local builds#249egorpavlikhin merged 2 commits intomainfrom
egorpavlikhin merged 2 commits intomainfrom
Conversation
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>
APErebus
approved these changes
May 6, 2026
| // 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; |
Contributor
There was a problem hiding this comment.
This is a new check, but I think it's fine. It should always be semver afaik
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
semver.lt(version, "2022.3.5512")gate, surrounded by identical "this Octopus instance is too old" log/throw boilerplate. Moved that into a single helperensureServerVersionAtLeastin a new top-levelversionCheckmodule.0.0.0-local(or just0.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 any0.0.0version — with or without a-prerelease/+buildsuffix — as satisfying the minimum.What changed
src/versionCheck.tsisLocalOctopusVersion,isServerVersionAtLeast,ensureServerVersionAtLeastsrc/versionCheck.test.tssrc/index.tssrc/features/projects/releases/releaseRepository.tscreatenow uses the helpersrc/features/projects/runbooks/runs/runbookRunRepository.tscreateandcreateGituse the helpersrc/features/projects/releases/deployments/deploymentRepository.tscreateandcreateTenanteduse the helpersrc/features/capabilities/capability.tsis 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— cleannpm run build— cleangrep "lt(serverInformation.version" -r src— no matches (no leftover inline checks)grep -rn 'from "semver"' src— onlysrc/versionCheck.tsstill imports it0.0.0-localOctopus server: previously threw the version-too-old error; now should succeed.🤖 Generated with Claude Code