From e2e0ffce4487334f203673a64a05e7d43b412893 Mon Sep 17 00:00:00 2001 From: Chris Coutinho Date: Fri, 19 Dec 2025 19:38:24 +0100 Subject: [PATCH] fix(ci): improve versioning and error handling Addresses remaining high-priority code review feedback: VERSIONING SCHEME FIXES: - Helm chart: Changed from pep440 to semver (correct for Helm) - Astrolabe: Changed from pep440 to semver (correct for Nextcloud apps) - MCP server: Remains pep440 (correct for Python packages) Helm charts must use semantic versioning per Helm specification. Nextcloud apps use semantic versioning in info.xml and package.json. ENHANCED ERROR HANDLING IN BUMP SCRIPTS: All three bump scripts now include: - Comprehensive validation checks * Tool availability (uv) * Directory structure (must run from repo root) * Required files exist (Chart.yaml, info.xml, package.json) - Better error messages * Stderr output for errors * Captured commitizen output on failure * Common failure causes listed - Success confirmation * Clear indication of what was updated * Next steps guidance (git push --follow-tags) - Robust shell options (set -euo pipefail) Scripts now provide helpful guidance when: - No conventional commits found - No commits with required scope - Git working directory not clean - Required dependencies missing --- charts/nextcloud-mcp-server/.cz.toml | 2 +- scripts/bump-astrolabe.sh | 53 ++++++++++++++++++++++++---- scripts/bump-helm.sh | 50 +++++++++++++++++++++----- scripts/bump-mcp.sh | 38 ++++++++++++++++---- third_party/astrolabe/.cz.toml | 2 +- 5 files changed, 122 insertions(+), 23 deletions(-) diff --git a/charts/nextcloud-mcp-server/.cz.toml b/charts/nextcloud-mcp-server/.cz.toml index c71bcdd..8f4504c 100644 --- a/charts/nextcloud-mcp-server/.cz.toml +++ b/charts/nextcloud-mcp-server/.cz.toml @@ -2,7 +2,7 @@ name = "cz_conventional_commits" version = "0.53.0" tag_format = "nextcloud-mcp-server-$version" -version_scheme = "pep440" +version_scheme = "semver" update_changelog_on_bump = true major_version_zero = true diff --git a/scripts/bump-astrolabe.sh b/scripts/bump-astrolabe.sh index 4a320d7..c51b8eb 100755 --- a/scripts/bump-astrolabe.sh +++ b/scripts/bump-astrolabe.sh @@ -1,17 +1,56 @@ #!/bin/bash # Bump Astrolabe app version -set -e +set -euo pipefail # Validate dependencies -command -v uv >/dev/null 2>&1 || { echo "Error: uv not found. Install from https://docs.astral.sh/uv/"; exit 1; } +command -v uv >/dev/null 2>&1 || { + echo "❌ Error: uv not found" >&2 + echo " Install from https://docs.astral.sh/uv/" >&2 + exit 1 +} + +# Validate Astrolabe directory exists +if [ ! -d "third_party/astrolabe" ]; then + echo "❌ Error: Must run from repository root (third_party/astrolabe not found)" >&2 + exit 1 +fi cd third_party/astrolabe -echo "Bumping Astrolabe version..." -uv run cz --config .cz.toml bump --yes +# Validate required files exist +if [ ! -f "appinfo/info.xml" ]; then + echo "❌ Error: appinfo/info.xml not found" >&2 + exit 1 +fi -echo "✓ Astrolabe version bumped" -echo " - Updated: appinfo/info.xml, package.json" -echo " - Tag format: astrolabe-v\${version}" +if [ ! -f "package.json" ]; then + echo "❌ Error: package.json not found" >&2 + exit 1 +fi + +echo "Bumping Astrolabe version..." + +# Run commitizen bump and capture output +if ! output=$(uv run cz --config .cz.toml bump --yes 2>&1); then + cd ../.. + echo "❌ Error: Version bump failed" >&2 + echo "$output" >&2 + echo "" >&2 + echo "Common causes:" >&2 + echo " - No commits with scope 'astrolabe' since last version" >&2 + echo " - No conventional commits found (use feat(astrolabe):, fix(astrolabe):, etc.)" >&2 + echo " - Git working directory not clean" >&2 + exit 1 +fi + +echo "$output" +echo "" +echo "✓ Astrolabe version bumped successfully" +echo " Updated: appinfo/info.xml, package.json" +echo " Tag format: astrolabe-v\${version}" +echo "" +echo "Next steps:" +echo " cd ../.." +echo " git push --follow-tags" cd ../.. diff --git a/scripts/bump-helm.sh b/scripts/bump-helm.sh index dd5411a..d57aef7 100755 --- a/scripts/bump-helm.sh +++ b/scripts/bump-helm.sh @@ -1,18 +1,52 @@ #!/bin/bash # Bump Helm chart version -set -e +set -euo pipefail # Validate dependencies -command -v uv >/dev/null 2>&1 || { echo "Error: uv not found. Install from https://docs.astral.sh/uv/"; exit 1; } +command -v uv >/dev/null 2>&1 || { + echo "❌ Error: uv not found" >&2 + echo " Install from https://docs.astral.sh/uv/" >&2 + exit 1 +} + +# Validate Helm chart directory exists +if [ ! -d "charts/nextcloud-mcp-server" ]; then + echo "❌ Error: Must run from repository root (charts/ not found)" >&2 + exit 1 +fi cd charts/nextcloud-mcp-server -echo "Bumping Helm chart version..." -uv run cz --config .cz.toml bump --yes +# Validate Chart.yaml exists +if [ ! -f "Chart.yaml" ]; then + echo "❌ Error: Chart.yaml not found" >&2 + exit 1 +fi -echo "✓ Helm chart version bumped" -echo " - Updated: Chart.yaml:version" -echo " - Tag format: nextcloud-mcp-server-\${version}" -echo " - Note: appVersion stays at MCP server version" +echo "Bumping Helm chart version..." + +# Run commitizen bump and capture output +if ! output=$(uv run cz --config .cz.toml bump --yes 2>&1); then + cd ../.. + echo "❌ Error: Version bump failed" >&2 + echo "$output" >&2 + echo "" >&2 + echo "Common causes:" >&2 + echo " - No commits with scope 'helm' since last version" >&2 + echo " - No conventional commits found (use feat(helm):, fix(helm):, etc.)" >&2 + echo " - Git working directory not clean" >&2 + exit 1 +fi + +echo "$output" +echo "" +echo "✓ Helm chart version bumped successfully" +echo " Updated: Chart.yaml:version" +echo " Tag format: nextcloud-mcp-server-\${version}" +echo " Note: appVersion stays at MCP server version" +echo "" +echo "Next steps:" +echo " cd ../.." +echo " git push --follow-tags" cd ../.. diff --git a/scripts/bump-mcp.sh b/scripts/bump-mcp.sh index 6cc9a47..d6b618e 100755 --- a/scripts/bump-mcp.sh +++ b/scripts/bump-mcp.sh @@ -1,13 +1,39 @@ #!/bin/bash # Bump MCP server version -set -e +set -euo pipefail # Validate dependencies -command -v uv >/dev/null 2>&1 || { echo "Error: uv not found. Install from https://docs.astral.sh/uv/"; exit 1; } +command -v uv >/dev/null 2>&1 || { + echo "❌ Error: uv not found" >&2 + echo " Install from https://docs.astral.sh/uv/" >&2 + exit 1 +} + +# Validate we're in the repository root +if [ ! -f "pyproject.toml" ]; then + echo "❌ Error: Must run from repository root (pyproject.toml not found)" >&2 + exit 1 +fi echo "Bumping MCP server version..." -uv run cz bump --yes -echo "✓ MCP server version bumped" -echo " - Updated: pyproject.toml, Chart.yaml:appVersion" -echo " - Tag format: v\${version}" +# Run commitizen bump and capture output +if ! output=$(uv run cz bump --yes 2>&1); then + echo "❌ Error: Version bump failed" >&2 + echo "$output" >&2 + echo "" >&2 + echo "Common causes:" >&2 + echo " - No commits since last version" >&2 + echo " - No conventional commits found (use feat:, fix:, etc.)" >&2 + echo " - Git working directory not clean" >&2 + exit 1 +fi + +echo "$output" +echo "" +echo "✓ MCP server version bumped successfully" +echo " Updated: pyproject.toml, Chart.yaml:appVersion" +echo " Tag format: v\${version}" +echo "" +echo "Next steps:" +echo " git push --follow-tags" diff --git a/third_party/astrolabe/.cz.toml b/third_party/astrolabe/.cz.toml index d16c32a..6e7c9b3 100644 --- a/third_party/astrolabe/.cz.toml +++ b/third_party/astrolabe/.cz.toml @@ -2,7 +2,7 @@ name = "cz_conventional_commits" version = "0.1.0" tag_format = "astrolabe-v$version" -version_scheme = "pep440" +version_scheme = "semver" update_changelog_on_bump = true major_version_zero = true