Skip to content

feat(codegen): pinned-version upgrade detection (k8s, gcp, docker, gitlab) - #530

Merged
lex00 merged 1 commit into
mainfrom
feat/525-pinned-upgrade
Jul 1, 2026
Merged

lex00 merged 1 commit into
mainfrom
feat/525-pinned-upgrade

Conversation

@lex00

@lex00 lex00 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Part of #523. Implements #525.

What

checkPinnedUpgrade(lexiconDir) — pinned-version upgrade detection for the four pinned lexicons (k8s, gcp, docker, gitlab). It:

  1. Reads the current pinned version constant from the lexicon source.
  2. Queries upstream for the latest stable release (pre-release/rc tags skipped).
  3. If newer: bumps the constant in place, calls feat(codegen): shared lexicon regen-validate + API surface-diff tooling #524's regenLexicon to regen + surface-diff, then reverts the bump (dry run — the working tree is never left bumped).
  4. Returns { lexicon, hasUpgrade, from, to, validation, fetchError } where validation carries the regen severity/delta.

Pins covered

  • k8s — K8S_SCHEMA_VERSION (lexicons/k8s/src/spec/fetch.ts); upstream = kubernetes/kubernetes releases.
  • gcp — KCC_VERSION (lexicons/gcp/src/spec/fetch.ts); upstream = GoogleCloudPlatform/k8s-config-connector releases.
  • docker — the moby/moby/<tag> version embedded in ENGINE_API_URL (lexicons/docker/src/codegen/versions.ts); upstream = moby/moby releases.
  • gitlab — GITLAB_SCHEMA_VERSION (lexicons/gitlab/src/codegen/fetch.ts); upstream = gitlab-org/gitlab tags with the -ee suffix.

Design

  • Upstream query + version compare are pure/injectable functions: parseVersion, compareVersionTuples, isNewer, isPreRelease, and REAL_RESOLVERS (per-lexicon GitHub API resolvers). Tests inject a mock resolver — no network, no live regen.
  • The bump is applied line-by-line via a per-lexicon regex + replacement, and reverted in a finally so it is undone even if regen throws.

CLI

chant dev pinned-upgrade <lexicon-dir> — reports only (text or -f json, with a minor/major semver label derived from the surface severity). Lexicon inferred from the directory basename.

Scope

Reporting only. Branch management, gh pr create for upgrades, and the scheduled runner are #527. Does not touch aws/azure/github (#526).

Validation

  • npx tsc --noEmit -p packages/core/tsconfig.json — clean.
  • npx vitest run packages/core/src/codegen/pinned-upgrade.test.ts — 21 passed (version parse/compare, pin read/bump/revert round-trip, and checkPinnedUpgrade upgrade/no-upgrade/fetch-error/revert-on-failure paths, all with mocked upstream).
  • npx vitest run packages/core/src/cli/main.test.ts — 46 passed (registry/handler edits).
  • eslint clean on all touched files.

Live end-to-end regen over the large lexicons is deferred to CI / the runner (#527).

… gitlab

Add checkPinnedUpgrade(lexiconDir): reads the pinned upstream version
constant, queries GitHub for the latest stable release (skipping
pre-release/rc tags), and when newer, dry-run bumps the constant, runs
#524's regenLexicon to regen + surface-diff, then reverts the bump so the
working tree is unchanged.

Upstream-query and version-compare are pure/injectable functions
(parseVersion, compareVersionTuples, isNewer, isPreRelease, REAL_RESOLVERS)
so the bump/regen/revert flow is unit-testable with mocked upstream.

Add `chant dev pinned-upgrade <dir>` CLI to report the result (text/json,
semver label from surface severity). Reports only — branch/PR automation
is out of scope (#527).

Refs #525
@lex00
lex00 merged commit f44a00e into main Jul 1, 2026
6 checks passed
@lex00
lex00 deleted the feat/525-pinned-upgrade branch August 3, 2026 19:21
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