Skip to content

Improve CI support in hub push commands via --fail-if-exists and bump command#2672

Open
willosborne wants to merge 2 commits into
finos:mainfrom
willosborne:hub-bump-commands
Open

Improve CI support in hub push commands via --fail-if-exists and bump command#2672
willosborne wants to merge 2 commits into
finos:mainfrom
willosborne:hub-bump-commands

Conversation

@willosborne

@willosborne willosborne commented Jun 17, 2026

Copy link
Copy Markdown
Member

Description

Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📚 Documentation update
  • 🎨 Code style/formatting changes
  • ♻️ Refactoring (no functional changes)
  • ⚡ Performance improvements
  • ✅ Test additions or updates
  • 🔧 Chore (maintenance, dependencies, CI, etc.)

Affected Components

  • CLI (cli/)
  • Schema (calm/)
  • CALM AI (calm-ai/)
  • CALM Hub (calm-hub/)
  • CALM Hub UI (calm-hub-ui/)
  • CALM Server (calm-server/)
  • CALM Widgets (calm-widgets/)
  • Documentation (docs/)
  • Shared (shared/)
  • VS Code Extension (calm-plugins/vscode/)
  • Dependencies
  • CI/CD

Commit Message Format ✅

Testing

  • I have tested my changes locally
  • I have added/updated unit tests
  • All existing tests pass

Checklist

  • My commits follow the conventional commit format
  • I have updated documentation if necessary
  • I have added tests for my changes (if applicable)
  • My changes follow the project's coding standards

@github-actions github-actions Bot added the cli Affects `cli` code label Jun 17, 2026
Adds a --fail-if-exists flag to all five hub push subcommands
(architecture, pattern, standard, control-requirement,
control-configuration). When set, the push skips the version
lookup and auto-bump entirely, pushing the exact version found
in the document's $id. If that version already exists on the
hub the server returns 409, which the existing error handler
surfaces as a fatal error.

Intended for CI pipelines where the version in $id is the
source of truth and any bump should have happened before commit.
Adds calm hub bump <resource> <file> with five subcommands
(architecture, pattern, standard, control-requirement,
control-configuration). The command reads the document's $id,
checks whether that exact version already exists on the hub,
and if so bumps the version in $id on disk by the requested
change type (patch/minor/major) without pushing. If the version
is not yet published the command exits cleanly with a no-op
message.

Pairs with --fail-if-exists on hub push: developers run
hub bump before committing so CI can push the exact committed
version and fail fast if it already exists.

Copilot AI left a comment

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.

Pull request overview

This PR extends the CALM CLI’s Hub commands to better support CI workflows by allowing deterministic pushes (no auto-bump) and by adding a local “bump on disk” workflow to avoid version collisions before pushing.

Changes:

  • Add --fail-if-exists to Hub push commands to push the exact $id version and fail on conflicts (rather than auto-bumping).
  • Add new hub bump ... subcommands to bump $id versions on disk when the current version already exists on the Hub.
  • Add Vitest coverage for --fail-if-exists behavior and bump flows.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
cli/src/command-helpers/hub-commands.ts Adds failIfExists handling for push flows and introduces bump orchestration for mapped resources + control docs.
cli/src/command-helpers/hub-commands.spec.ts Adds tests for --fail-if-exists and bump behavior.
cli/src/cli.ts Wires new flags and hub bump subcommands into the CLI command tree.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +788 to +800
const existingVersions = await client.getMappedResourceVersions(metadata.namespace, metadata.mapping, resourceType);

if (!existingVersions.includes(metadata.version)) {
printJsonSuccess({ file: options.file, currentVersion: metadata.version, bumped: false, message: 'Version not yet published to hub; no bump needed.' });
return;
}

const newVersion = computeSemVerBump(metadata.version, options.changeType);
const newMetadata = { ...metadata, version: newVersion };
const newContent = updateDocumentMetadata(fileContent, newMetadata);
await writeFile(options.file, newContent, 'utf-8');

printBumpResult({ file: options.file, previousVersion: metadata.version, newVersion }, format);
Comment on lines +845 to +859
const existingVersions = kind === 'configuration'
? await client.getControlConfigurationVersions(metadata.domain, metadata.controlName, metadata.configName!)
: await client.getControlRequirementVersions(metadata.domain, metadata.controlName);

if (!existingVersions.includes(metadata.version)) {
printJsonSuccess({ file: options.file, currentVersion: metadata.version, bumped: false, message: 'Version not yet published to hub; no bump needed.' });
return;
}

const newVersion = computeSemVerBump(metadata.version, options.changeType);
const newMetadata: ControlDocumentMetadata = { ...metadata, version: newVersion };
const newContent = updateControlDocumentMetadata(fileContent, newMetadata);
await writeFile(options.file, newContent, 'utf-8');

printBumpResult({ file: options.file, previousVersion: metadata.version, newVersion }, format);
expect.objectContaining({ file: 'arch.json', previousVersion: '1.0.0', newVersion: '1.0.1' })
);
});

@willosborne willosborne mentioned this pull request Jun 18, 2026
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli Affects `cli` code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants