Skip to content

Add version guard CI check to enforce version bumping' to clearly communicate what the change accomplishes#9

Merged
cap-jmk-real merged 5 commits intomainfrom
improve-coverage
Feb 27, 2026
Merged

Add version guard CI check to enforce version bumping' to clearly communicate what the change accomplishes#9
cap-jmk-real merged 5 commits intomainfrom
improve-coverage

Conversation

@cap-jmk-real
Copy link
Copy Markdown
Owner

@cap-jmk-real cap-jmk-real commented Feb 27, 2026

implemented a small ci workflow for checking I do not have conflicting release versions

Summary by CodeRabbit

  • Chores
    • Added a CI guard to ensure the project version is bumped before tests and builds.
    • Bumped project and package versions to 0.1.8 across desktop, docs, core, runtime, and UI.
  • Tests
    • Test workflow now runs after the version check and includes improved setup, dependency handling, type checking, linting, UI tests, docs build, and coverage reporting.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 27, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 365527e and a8a3d59.

📒 Files selected for processing (6)
  • apps/desktop/package.json
  • apps/docs/package.json
  • package.json
  • packages/core/package.json
  • packages/runtime/package.json
  • packages/ui/package.json

📝 Walkthrough

Walkthrough

Adds a CI-level version guard: new GitHub Actions jobs run a Node script that verifies configured package.json versions are bumped relative to the latest GitHub release tag; test/build jobs are made dependent on the guard. Multiple package.json files have their version fields updated.

Changes

Cohort / File(s) Summary
CI Workflows
.github/workflows/ci.yml, .github/workflows/release-desktop.yml
Add a version_guard job that checks out code, sets up Node via .nvmrc, and runs scripts/check-version-bumped.mjs; make test and build jobs depend on version_guard. ci.yml test job also receives additional setup/test steps (pnpm/node setup, install, typecheck, lint, UI tests, docs build, coverage reporting).
Version Verification Script
scripts/check-version-bumped.mjs
New CI-only Node script that reads versions from configured package.json files, ensures they match, queries the GitHub Releases API using GITHUB_REPOSITORY and GITHUB_TOKEN, and fails CI if the current version equals the latest release tag; no-op outside GitHub Actions.
Package Manifests
package.json, apps/desktop/package.json, apps/docs/package.json, packages/core/package.json, packages/runtime/package.json, packages/ui/package.json
Bump package versions from 0.1.70.1.8 across root, apps, and packages. No other manifest fields changed.

Sequence Diagram

sequenceDiagram
    participant GHA as GitHub Actions
    participant Script as check-version-bumped.mjs
    participant Pkg as package.json files
    participant API as GitHub Releases API

    GHA->>Script: start version_guard job
    Script->>Script: ensure running in GitHub Actions
    Script->>Pkg: read versions from VERSION_PACKAGES
    Script->>Script: verify versions are identical
    Script->>API: fetch latest release (Authorization: token GITHUB_TOKEN)
    alt release found
        API-->>Script: return tag_name
        Script->>Script: normalize tag (strip leading "v")
        alt currentVersion == latestTag
            Script-->>GHA: exit 1 (fail)
        else
            Script-->>GHA: exit 0 (pass)
        end
    else no release found
        API-->>Script: 404 / empty
        Script-->>GHA: log and exit 0 (pass)
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 I hop through tags and JSON trees,
I sniff the version on the breeze,
If tag and package match today,
I thump my paw and block the way,
Bump the number — then I’ll play! 🎩✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: adding a CI check that guards against version mismatches, which aligns with the primary changes in the PR (new version_guard job and associated script).

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch improve-coverage

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/ci.yml:
- Around line 28-29: The CI step running the script check-version-bumped.mjs
fails because the script needs process.env.GITHUB_TOKEN but the workflow step
doesn't pass it; update the GitHub Actions step named "Ensure version is bumped
vs last tagged release" to export the GITHUB_TOKEN environment variable from
secrets (secrets.GITHUB_TOKEN) so the Node script
(scripts/check-version-bumped.mjs) can read process.env.GITHUB_TOKEN at runtime.
- Around line 12-14: Remove the redundant top-level "if:" conditional that
checks (github.event_name == 'pull_request' && github.base_ref == 'main') ||
(github.event_name == 'push' && github.ref == 'refs/heads/main') since the
workflow's "on:" triggers already restrict runs to pushes on main and PRs
targeting main; locate the `if:` block in the CI workflow (the line starting
with "if:" and referencing github.event_name/github.base_ref/github.ref) and
delete it, then run a quick workflow lint or dry-run to confirm no downstream
steps depend on that duplicated guard.
- Around line 16-26: Remove the unnecessary full git history and tag fetch:
delete the fetch-depth: 0 option from the actions/checkout@v4 step and remove
the separate "Fetch tags" run step that executes git fetch --tags --force
--prune, since the workflow uses the GitHub Releases API (not local tags) to
determine the latest release; leave the standard checkout and setup-node actions
(actions/checkout@v4 and actions/setup-node@v4 with node-version-file) intact.

In `@scripts/check-version-bumped.mjs`:
- Around line 1-29: Update the version-check so it validates that all aligned
package.json files have the same version instead of only the root; add a helper
(e.g., getAllPackageVersions or extend getCurrentVersion) that reads and returns
versions from root/package.json, apps/desktop/package.json, and
apps/docs/package.json using the existing root and readFileSync logic, then
compare them and if any differ call processLogger.error / console.error and
process.exit(1) (or fail the script) with a clear message listing mismatched
files and their versions; keep existing CI-only gating (inCi) and reuse
fileURLToPath/dirname utilities already in the script.

ℹ️ Review info

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ee0ce54 and b100094.

📒 Files selected for processing (2)
  • .github/workflows/ci.yml
  • scripts/check-version-bumped.mjs

@cap-jmk-real cap-jmk-real changed the title ci version check Add version guard CI check to enforce version bumping' to clearly communicate what the change accomplishes Feb 27, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@scripts/check-version-bumped.mjs`:
- Around line 114-124: The current check only fails when current === latest,
allowing a lower version to slip through; update the logic in the
version-checking block that compares the variables current and latest to enforce
that current must be greater than latest (use a semver-aware comparison, e.g.
semver.lte or semver.compare to detect current <= latest) and keep the existing
error message and process.exit(1) path when the check fails; locate the
comparison using the variables current and latest in the existing conditional
and replace the equality check with a semver-based "less than or equal" check.

ℹ️ Review info

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b100094 and e0b73bb.

📒 Files selected for processing (2)
  • .github/workflows/ci.yml
  • scripts/check-version-bumped.mjs

Comment on lines +114 to +124
if (current === latest) {
console.error(
[
`Current version ${current} matches latest GitHub release version ${latest}.`,
`Every merge to main must bump the version. Please run:`,
` npm run release:bump [patch|minor|major]`,
`then commit and push again.`,
].join("\n")
);
process.exit(1);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Enforce version increase, not just inequality.

The check only blocks current === latest. A lower version than latest still passes, which violates bump intent and can regress release versioning.

🔧 Proposed fix
+function parseSemver(v) {
+  const m = /^v?(\\d+)\\.(\\d+)\\.(\\d+)$/.exec(String(v).trim());
+  if (!m) return null;
+  return [Number(m[1]), Number(m[2]), Number(m[3])];
+}
+
+function compareSemver(a, b) {
+  const pa = parseSemver(a);
+  const pb = parseSemver(b);
+  if (!pa || !pb) return null;
+  for (let i = 0; i < 3; i += 1) {
+    if (pa[i] !== pb[i]) return pa[i] - pb[i];
+  }
+  return 0;
+}
+
 const current = assertAlignedVersions();
 const latest = await getLatestReleaseVersionFromGithub();
@@
-if (current === latest) {
+const cmp = compareSemver(current, latest);
+if (cmp === null) {
+  console.error(
+    `Version guard: unable to compare versions safely (current=${current}, latest=${latest}). Use strict semver x.y.z.`
+  );
+  process.exit(1);
+}
+
+if (cmp <= 0) {
   console.error(
     [
-      `Current version ${current} matches latest GitHub release version ${latest}.`,
+      `Current version ${current} is not greater than latest GitHub release version ${latest}.`,
       `Every merge to main must bump the version. Please run:`,
       `  npm run release:bump [patch|minor|major]`,
       `then commit and push again.`,
     ].join("\n")
   );
   process.exit(1);
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@scripts/check-version-bumped.mjs` around lines 114 - 124, The current check
only fails when current === latest, allowing a lower version to slip through;
update the logic in the version-checking block that compares the variables
current and latest to enforce that current must be greater than latest (use a
semver-aware comparison, e.g. semver.lte or semver.compare to detect current <=
latest) and keep the existing error message and process.exit(1) path when the
check fails; locate the comparison using the variables current and latest in the
existing conditional and replace the equality check with a semver-based "less
than or equal" check.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/release-desktop.yml:
- Around line 11-25: The version_guard job inherits default token permissions;
update the version_guard job to explicitly scope the GITHUB_TOKEN to least
privilege by adding a permissions block (for example permissions: contents:
read) at the job level before steps so the node scripts/check-version-bumped.mjs
step still has a read-only token for release metadata access; keep the existing
env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} and ensure only the minimal read
permission(s) required are granted.

ℹ️ Review info

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e0b73bb and 19287a8.

📒 Files selected for processing (1)
  • .github/workflows/release-desktop.yml

@cap-jmk-real cap-jmk-real merged commit 8aced82 into main Feb 27, 2026
9 checks passed
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