Compare commits

...
18 Commits
Author SHA1 Message Date
james.maes 1f2e730512 Merge pull request #3 from Kingsrook/feature/snapshot-releases
Feature/snapshot releases
2025-09-29 11:22:04 -05:00
james.maes 2b59dac369 style(git-operations): converted to our internal git-operations command 2025-09-29 11:19:58 -05:00
james.maes 22fa420c52 docs: updated documents for release of 3.8 2025-09-29 11:07:58 -05:00
james.maes f337e2ff51 fix(circleci): updated publish jobs to skip git_operations for feature snapshot builds 2025-09-29 11:01:27 -05:00
james.maes 9d1a70e433 fix(calculate_version): fixed leading whitespaces issues on feature branch detection 2025-09-29 10:53:38 -05:00
james.maes 145c99e2f8 fix(git_full_checkout): removed depth - default to full 2025-09-29 10:47:04 -05:00
james.maes 8792d74fb0 fix(git-checkout): converting to a custom command to get full git clones 2025-09-29 10:45:17 -05:00
james.maes 5b5df41faa fix(git-checkout): updated depth to 10 2025-09-29 10:40:36 -05:00
james.maes 59c80f756a fix(git-checkout): updated to use command to get full clone 2025-09-29 10:34:26 -05:00
james.maes 187d0df5c7 ci(git-checkout): feature name detection was failing due to shallow git checkout clones, updated to be full clones 2025-09-29 10:30:56 -05:00
james.maes aa5cab7390 test: updated publish tag tests 2025-09-22 08:55:17 -05:00
james.maes f2d8a9927a fix(calulate_version): updated handling for finding feature name from a publish tag 2025-09-22 08:51:48 -05:00
james.maes 8820a7af82 fix(calulate_version): fixed support for tags on feature branches and added tests 2025-09-22 08:44:11 -05:00
james.maes 8adb9e65f7 fix: Linting updates 2025-09-20 09:38:23 -05:00
james.maes 492af48c0d docs: updated changelog and example build files 2025-09-20 09:12:23 -05:00
james.maes ae26b2288a feat: adding support for publishing snapshots for feature branches
Support Feature Snapshot Releases #1
2025-09-20 09:06:55 -05:00
james.maes f122b4a470 chore: Removed ignored file 2025-09-20 07:25:44 -05:00
james.maes ea30ebdb2f chore: Added IDE to ignore 2025-09-20 07:25:03 -05:00
16 changed files with 445 additions and 267 deletions

No files matched your search

+3
View File
@@ -5,3 +5,6 @@ target
# Test data directory (created dynamically during tests)
tests/test_data
# IDE
.idea
-120
View File
@@ -1,120 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AutoImportSettings">
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="39f8d35a-1bb7-489b-b59c-b0ba3ffefe23" name="Changes" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/scripts/calculate-version.sh" beforeDir="false" afterPath="$PROJECT_DIR$/src/scripts/calculate-version.sh" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/scripts/check_middleware_api_versions.sh" beforeDir="false" afterPath="$PROJECT_DIR$/src/scripts/check_middleware_api_versions.sh" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/scripts/create_github_release.sh" beforeDir="false" afterPath="$PROJECT_DIR$/src/scripts/create_github_release.sh" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/scripts/manage_version_calculate.sh" beforeDir="false" afterPath="$PROJECT_DIR$/src/scripts/manage_version_calculate.sh" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/scripts/manage_version_commit.sh" beforeDir="false" afterPath="$PROJECT_DIR$/src/scripts/manage_version_commit.sh" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/scripts/manage_version_git_config.sh" beforeDir="false" afterPath="$PROJECT_DIR$/src/scripts/manage_version_git_config.sh" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/scripts/mvn_build_compile.sh" beforeDir="false" afterPath="$PROJECT_DIR$/src/scripts/mvn_build_compile.sh" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/scripts/mvn_jar_deploy_deploy.sh" beforeDir="false" afterPath="$PROJECT_DIR$/src/scripts/mvn_jar_deploy_deploy.sh" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/scripts/mvn_jar_deploy_gpg_setup.sh" beforeDir="false" afterPath="$PROJECT_DIR$/src/scripts/mvn_jar_deploy_gpg_setup.sh" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/scripts/mvn_verify_save_test_results.sh" beforeDir="false" afterPath="$PROJECT_DIR$/src/scripts/mvn_verify_save_test_results.sh" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/scripts/mvn_verify_verify.sh" beforeDir="false" afterPath="$PROJECT_DIR$/src/scripts/mvn_verify_verify.sh" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="GitHubPullRequestSearchHistory">{
&quot;lastFilter&quot;: {
&quot;state&quot;: &quot;OPEN&quot;,
&quot;assignee&quot;: &quot;KofTwentyTwo&quot;
}
}</component>
<component name="GithubPullRequestsUISettings">{
&quot;selectedUrlAndAccountId&quot;: {
&quot;url&quot;: &quot;git@github.com:Kingsrook/qqq-orb.git&quot;,
&quot;accountId&quot;: &quot;7a0b7646-5b0c-4647-976d-932a62661dd2&quot;
}
}</component>
<component name="MacroExpansionManager">
<option name="directoryName" value="Qi1Hqxgr" />
</component>
<component name="ProjectColorInfo">{
&quot;associatedIndex&quot;: 5
}</component>
<component name="ProjectId" id="32YtZdjn4FeSrJsD5VMG3tLBHKD" />
<component name="ProjectLevelVcsManager">
<ConfirmationsSetting value="2" id="Add" />
</component>
<component name="ProjectViewState">
<option name="autoscrollFromSource" value="true" />
<option name="showExcludedFiles" value="false" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.git.unshallow&quot;: &quot;true&quot;,
&quot;RunOnceActivity.go.formatter.settings.were.checked&quot;: &quot;true&quot;,
&quot;RunOnceActivity.go.migrated.go.modules.settings&quot;: &quot;true&quot;,
&quot;SHARE_PROJECT_CONFIGURATION_FILES&quot;: &quot;true&quot;,
&quot;git-widget-placeholder&quot;: &quot;develop&quot;,
&quot;go.import.settings.migrated&quot;: &quot;true&quot;,
&quot;io.aesy.yamllint.do.not.ask.to.enable&quot;: &quot;true&quot;,
&quot;last_opened_file_path&quot;: &quot;/Users/james.maes/Git.Local/Kingsrook/qqq-orb/src/jobs&quot;,
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
&quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
&quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
&quot;org.rust.cargo.project.model.impl.CargoExternalSystemProjectAware.subscribe.first.balloon&quot;: &quot;&quot;,
&quot;org.rust.first.attach.projects&quot;: &quot;true&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;preferences.sourceCode.yaml&quot;
},
&quot;keyToStringList&quot;: {
&quot;stardust.markdown.MarkdownSplitEditorSuppressor:keyList&quot;: []
}
}</component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/src/jobs" />
<recent name="$PROJECT_DIR$/src/commands" />
</key>
</component>
<component name="RustProjectSettings">
<option name="toolchainHomeDirectory" value="$USER_HOME$/.cargo/bin" />
</component>
<component name="SharedIndexes">
<attachedChunks>
<set>
<option value="bundled-jdk-9823dce3aa75-bf35d07a577b-intellij.indexing.shared.core-IU-252.25557.131" />
<option value="bundled-js-predefined-d6986cc7102b-b598e85cdad2-JavaScript-IU-252.25557.131" />
</set>
</attachedChunks>
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="39f8d35a-1bb7-489b-b59c-b0ba3ffefe23" name="Changes" comment="" />
<created>1757609391348</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1757609391348</updated>
<workItem from="1757609392578" duration="5983000" />
<workItem from="1757633227531" duration="300000" />
<workItem from="1757633543711" duration="945000" />
<workItem from="1757634532876" duration="26000" />
<workItem from="1757634568948" duration="111000" />
<workItem from="1757634683262" duration="86000" />
<workItem from="1757634778652" duration="275000" />
<workItem from="1757635061044" duration="63000" />
<workItem from="1757721395861" duration="3728000" />
</task>
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
<component name="VgoProject">
<settings-migrated>true</settings-migrated>
</component>
</project>
+8
View File
@@ -0,0 +1,8 @@
repos:
- hooks:
- id: commitizen
- id: commitizen-branch
stages:
- pre-push
repo: https://github.com/commitizen-tools/commitizen
rev: v4.9.1
+69 -19
View File
@@ -5,9 +5,10 @@ All notable changes to QQQ Orb will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
## [0.3.8] - 2025-09-29
### Added
- Support for publishing snapshots for feature branches
- Comprehensive README with detailed usage examples
- CONTRIBUTING.md with development guidelines
- SECURITY.md with security policy and reporting procedures
@@ -17,40 +18,89 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Updated README to follow QQQ framework standards
- Enhanced documentation structure and organization
## [2.1] - 2024-01-XX
## [0.3.7] - 2025-09-18
### Added
- Multi-platform support for Maven and Node.js projects
- GitFlow integration with automated version management
- Comprehensive testing framework with coverage reporting
- Automated publishing to Maven Central and npm registries
- Shell script automation and utilities
- Documentation generation and publishing
- Comprehensive README with current functionality and testing framework documentation
### Changed
- Improved orb structure and organization
- Enhanced error handling and validation
- Updated dependencies and security patches
- Enhanced documentation structure and organization
## [0.3.6] - 2025-09-16
### Fixed
- Various bug fixes and stability improvements
- Updated handling for tagged releases in main branch to properly promote to latest tag
- Fixed git commit operations on main branch for production releases
## [2.0] - 2023-XX-XX
## [0.3.5] - 2025-09-16
### Fixed
- Updated git commit on main branch to work correctly for tag releases in production releases
## [0.3.4] - 2025-09-15
### Fixed
- Removed conditionals around git operations after version checks for main and hotfix branches
- Updated standard GitHub documentation to point to top-level project documentation
## [0.3.3] - 2025-09-15
### Added
- Made publish_asciidoc a parameterized run option
### Changed
- Enhanced parameterization for better flexibility
## [0.3.2] - 2025-09-15
### Added
- Base level repository files and updated README
### Changed
- Updated check_middleware_api_versions to run based on parameter configuration
## [0.3.1] - 2025-09-15
### Fixed
- Version bump corrections
- Fixed bad sync RC update
- Updated example version references
## [0.3.0] - 2025-09-15
### Added
- Support for pure Node.js projects
- Support for building integrated frontend (npm) within Maven projects
- Support for publishing snapshots and tags
- Enhanced feature branch versioning with dynamic commit hash updates
- Comprehensive test suite and improved linting for calculate_version.sh
### Changed
- Reverted to only handle POM files (npm handled within its own job)
- Adjusted default execution state for scripts
- Converted longer commands to scripts per organization linting standards
- Refactored calculate_version.sh for cleaner branch level code
### Fixed
- Multiple linting fixes from CircleCI integration
- Improved error handling and validation
## [0.2.0] - 2025-09-15
### Added
- Initial CircleCI orb implementation
- Basic Maven project support
- Core CI/CD workflows
- Initial documentation for orb
### Changed
- Migrated from custom CI/CD to CircleCI orbs
- Updated CircleCI to use new QQQ orb for workflows
## [1.x] - 2022-XX-XX
### Added
- Legacy CI/CD implementation
- Basic automation scripts
### Fixed
- Implemented initial linting fixes from CircleCI
- Initial import of scripts and jobs from QQQ base repository
---
**Note**: For detailed release information and breaking changes, see the [QQQ Wiki](https://github.com/Kingsrook/qqq/wiki).
**Note**: For detailed release information and breaking changes, see the [QQQ Wiki](https://github.com/Kingsrook/qqq/wiki).
+5 -5
View File
@@ -1,7 +1,7 @@
# QQQ Orb
[![CircleCI Orb](https://img.shields.io/badge/CircleCI%20Orb-kingsrook%2Fqqq--orb-blue.svg)](https://circleci.com/developer/orbs/orb/kingsrook/qqq-orb)
[![Version](https://img.shields.io/badge/version-2.1-blue.svg)](https://circleci.com/developer/orbs/orb/kingsrook/qqq-orb)
[![Version](https://img.shields.io/badge/version-0.3.8-blue.svg)](https://circleci.com/developer/orbs/orb/kingsrook/qqq-orb)
[![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
> **CircleCI Orb for QQQ Framework Projects**
@@ -223,8 +223,8 @@ Automated version calculation with GitFlow integration and feature branch suppor
### Feature Branch Versioning
Feature branches create unique, traceable versions:
- **Format**: `{version}-{ABBREV}-{commit_hash}-SNAPSHOT`
- **Example**: `feature/new-feature` → `1.5.0-NEW-abc1234-SNAPSHOT`
- **Format**: `{version}-{feature_branch_name}-{commit_hash}-SNAPSHOT`
- **Example**: `feature/new-feature` → `1.5.0-new-feature-abc1234-SNAPSHOT`
- **Dynamic Updates**: Automatically updates when commit hash changes
- **Safe Abbreviations**: 3-character uppercase feature name abbreviation
@@ -233,7 +233,7 @@ Feature branches create unique, traceable versions:
The version calculator handles multiple formats:
- **Standard**: `1.5.0`, `1.5.0-SNAPSHOT`, `1.5.0-RC.1`
- **V-prefixed**: `v1.5.0` → `1.5.0` (clean conversion)
- **Feature-specific**: `1.5.0-NEW-abc1234-SNAPSHOT`
- **Feature-specific**: `1.5.0-new-feature-name-abc1234-SNAPSHOT`
**Main branch requires release tags**:
```bash
@@ -390,4 +390,4 @@ This repository is maintained separately from the main QQQ repository to:
**Built with ❤️ by the Kingsrook Team**
**This is a CI/CD component of the QQQ framework. For complete information, support, and community, visit: https://github.com/Kingsrook/qqq**
**This is a CI/CD component of the QQQ framework. For complete information, support, and community, visit: https://github.com/Kingsrook/qqq**
+11
View File
@@ -0,0 +1,11 @@
description: >
Full checkout of the repository
- Clones the repository
- Checks out the commit specified by CIRCLE_SHA1
steps:
- run:
name: Full checkout
command: |
git clone "$CIRCLE_REPOSITORY_URL" .
git checkout "$CIRCLE_SHA1"
+37 -21
View File
@@ -4,55 +4,71 @@ description: >
usage:
version: 2.1
orbs:
qqq-orb: kingsrook/qqq-orb@0.3.1
qqq-orb: kingsrook/qqq-orb@0.3.8
workflows:
# Test workflow for feature branches
test_only:
jobs:
- qqq-orb/mvn_test_only:
context: [ qqq-maven-registry-credentials ]
filters:
branches:
ignore: [develop, main, /release\/.*/, /hotfix\/.*/]
filters:
branches:
ignore: /(develop|main|release/.*|hotfix/.*|integration.*)/
tags:
only: []
# Snapshot deployment for develop branch
publish_snapshot:
jobs:
- qqq-orb/mvn_publish:
context: [ qqq-maven-registry-credentials ]
branch_type: snapshot
filters:
branches:
only: [develop]
filters:
branches:
only:
- develop
publish_feature:
jobs:
- qqq-orb/mvn_publish:
context: [ qqq-maven-registry-credentials ]
branch_type: feature
filters:
branches:
only:
- feature/.*
tags:
only: [ /publish.*/ ]
# Release candidate workflow
publish_release_candidate:
jobs:
- qqq-orb/mvn_publish:
context: [ qqq-maven-registry-credentials ]
branch_type: release_candidate
filters:
branches:
only: [/release\/.*/]
filters:
branches:
only:
- /release\/.*/
# Production release workflow
publish_release:
jobs:
- qqq-orb/mvn_publish:
context: [ qqq-maven-registry-credentials ]
branch_type: release
filters:
branches:
only: [main]
filters:
branches:
only: [ main ]
tags:
only: [ /v.*/ ]
# Hotfix release workflow
publish_hotfix_release:
jobs:
- qqq-orb/mvn_publish:
context: [ qqq-maven-registry-credentials ]
branch_type: hotfix
filters:
branches:
only: [/hotfix\/.*/]
filters:
branches:
only:
- /hotfix\/.*/
+1 -1
View File
@@ -12,7 +12,7 @@ parameters:
description: "Branch type: snapshot, release_candidate, release, or hotfix"
steps:
- checkout
- git_full_checkout
- mvn_manage_version
- frontend_build
- frontend_test
+1 -1
View File
@@ -7,6 +7,6 @@ description: >
executor: localstack/default
steps:
- checkout
- git_full_checkout
- frontend_build
- frontend_test
+17 -4
View File
@@ -1,7 +1,7 @@
description: >
Unified publishing job for all branch types
Handles version management, building, testing, and publishing based on branch type
Supports: snapshot, release_candidate, release, and hotfix workflows
Supports: snapshot, release_candidate, release (tagged), feasture (tagged) and hotfix workflows
executor: localstack/default
@@ -9,7 +9,7 @@ parameters:
branch_type:
type: string
default: "snapshot"
description: "Branch type: snapshot, release_candidate, release, or hotfix"
description: "Branch type: snapshot, release_candidate, release, features, or hotfix"
check_middleware_api_versions:
type: boolean
default: false
@@ -20,18 +20,31 @@ parameters:
description: "Whether to publish AsciiDoc documentation"
steps:
- checkout
- git_full_checkout
- mvn_build
- mvn_manage_version
- attach_workspace:
at: .
- mvn_verify
- when:
condition: << parameters.check_middleware_api_versions >>
steps:
- check_middleware_api_versions
- mvn_jar_deploy
- git_operations
- when:
condition:
not:
equal: [ "<< parameters.branch_type >>", "feature" ]
steps:
- git_operations
- when:
condition: << parameters.publish_asciidoc >>
steps:
+1 -1
View File
@@ -13,7 +13,7 @@ parameters:
description: "Whether to run middleware API version checks"
steps:
- checkout
- git_full_checkout
- mvn_build
- mvn_verify
- when:
+1 -1
View File
@@ -12,7 +12,7 @@ parameters:
description: "Branch type: snapshot, release_candidate, release, or hotfix"
steps:
- checkout
- git_full_checkout
- node_install_dependencies
- node_run_tests
- node_manage_version
+1 -1
View File
@@ -12,6 +12,6 @@ parameters:
description: "Branch type: snapshot, release_candidate, release, or hotfix"
steps:
- checkout
- git_full_checkout
- node_install_dependencies
- node_run_tests
+31 -3
View File
@@ -29,6 +29,29 @@ if [[ "$1" == "--dry-run" ]]; then
echo "DRY RUN MODE - No changes will be made"
fi
################################################
## Function to find original feature branch ##
################################################
find_original_feature_branch() {
local original_branch=""
# Method 1: Look for remote branches containing this commit
echo "Method 1: Checking remote branches..." >&2
original_branch=$(git branch -r --contains HEAD 2>/dev/null | grep 'origin/feature/' | head -1 | sed 's/origin\///' | sed 's/^[[:space:]]*//' || echo "")
if [[ -n "$original_branch" ]]; then
echo "Found via remote branches: [$original_branch]" >&2
fi
# Return the result
if [[ "$original_branch" =~ ^feature/ ]]; then
echo "✅ Found original feature branch: [$original_branch]" >&2
echo "$original_branch"
else
echo "⚠️ Could not determine original feature branch, using generic name" >&2
echo "feature/publish"
fi
}
####################################
## Get current branch and version ##
####################################
@@ -50,6 +73,9 @@ if [[ "$CURRENT_BRANCH" == "HEAD" ]]; then
echo "This is a release candidate tag, treating as release branch"
CURRENT_BRANCH="release/${CURRENT_TAG#v}"
CURRENT_BRANCH="release/${CURRENT_BRANCH%-RC.*}"
elif [[ "$CURRENT_TAG" =~ ^publish- ]]; then
echo "This is a publish tag for feature branch, treating as feature branch"
CURRENT_BRANCH=$(find_original_feature_branch)
else
echo "Unknown tag format: $CURRENT_TAG"
CURRENT_BRANCH="unknown"
@@ -90,8 +116,9 @@ extract_version_parts() {
PATCH=${BASH_REMATCH[3]}
#############################################################
## Handle feature-specific versions like 1.5.0-NEW-abc1234-SNAPSHOT ##
## or 1.4.0-test-new-orb-825957d-SNAPSHOT ##
#############################################################
elif [[ "$version" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)-[A-Z]{3}-[a-f0-9]{7}-SNAPSHOT$ ]]; then
elif [[ "$version" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)-[a-zA-Z0-9-]+-[a-f0-9]+-SNAPSHOT$ ]]; then
MAJOR=${BASH_REMATCH[1]}
MINOR=${BASH_REMATCH[2]}
PATCH=${BASH_REMATCH[3]}
@@ -108,6 +135,7 @@ extract_version_parts() {
fi
}
#########################################
## Function to set version using Maven ##
#########################################
@@ -279,7 +307,7 @@ handle_feature_branch() {
# Create safe abbreviation (first 3 characters, uppercase)
local feature_abbrev
feature_abbrev=$(echo "$feature_name" | cut -c1-3 | tr '[:lower:]' '[:upper:]')
feature_abbrev=$(echo "$feature_name" | cut -c1-100 | tr '[:upper:]' '[:lower:]')
# Generate short commit hash
local commit_hash
@@ -404,4 +432,4 @@ main() {
#######################
## Run main function ##
#######################
main "$@"
main "$@"
+24 -15
View File
@@ -1,15 +1,14 @@
#!/bin/bash
############################################################################
## run_tests.sh
## Test runner for calculate_version.sh script
##
## This script runs the comprehensive test suite and provides
## different output formats for different use cases.
##
## Usage: ./run_tests.sh [--verbose] [--ci]
############################################################################
################################################################
## run_tests.sh ##
## Test runner for calculate_version.sh script ##
## ##
## This script runs the comprehensive test suite and provides ##
## different output formats for different use cases. ##
## ##
## Usage: ./run_tests.sh [--verbose] [--ci] ##
################################################################
set -e
###################
@@ -48,20 +47,26 @@ done
main() {
echo "🧪 Running calculate_version.sh test suite..."
# Verify test script exists
###############################
## Verify test script exists ##
###############################
if [[ ! -f "$TEST_SCRIPT" ]]; then
echo "❌ Test script not found: $TEST_SCRIPT"
exit 1
fi
# Run tests
###############
## Run tests ##
###############
local test_args=""
if [[ "$VERBOSE" == "true" ]]; then
test_args="--verbose"
fi
if [[ "$CI_MODE" == "true" ]]; then
# CI mode: minimal output, focus on results
###############################################
## CI mode: minimal output, focus on results ##
###############################################
echo "Running tests in CI mode..."
if "$TEST_SCRIPT" $test_args > /tmp/test_output.log 2>&1; then
echo "✅ All tests passed!"
@@ -73,10 +78,14 @@ main() {
exit 1
fi
else
# Interactive mode: full output
###################################
## Interactive mode: full output ##
###################################
"$TEST_SCRIPT" $test_args
fi
}
# Run main function
#######################
## Run main function ##
#######################
main "$@"
+235 -75
View File
@@ -1,15 +1,14 @@
#!/bin/bash
############################################################################
## test_calculate_version.sh
## Comprehensive test suite for calculate_version.sh script
##
## This test suite validates all branch types and edge cases for the
## version calculation script.
##
## Usage: ./test_calculate_version.sh [--verbose]
############################################################################
#######################################################################
## test_calculate_version.sh ##
## Comprehensive test suite for calculate_version.sh script ##
## ##
## This test suite validates all branch types and edge cases for the ##
## version calculation script. ##
## ##
## Usage: ./test_calculate_version.sh [--verbose] ##
#######################################################################
set -e
###################
@@ -21,7 +20,9 @@ CALCULATE_VERSION_SCRIPT="$PROJECT_ROOT/src/scripts/calculate_version.sh"
TEST_DIR="$PROJECT_ROOT/tests/test_data"
VERBOSE=false
# Test counters
###################
## Test counters ##
###################
TESTS_RUN=0
TESTS_PASSED=0
TESTS_FAILED=0
@@ -33,23 +34,31 @@ if [[ "$1" == "--verbose" ]]; then
VERBOSE=true
fi
####################################
## Test Framework Functions ##
####################################
##############################
## Test Framework Functions ##
##############################
# Create a temporary directory for test data
################################################
## Create a temporary directory for test data ##
################################################
setup_test_environment() {
echo "Setting up test environment..."
# Remove existing test directory if it exists
#################################################
## Remove existing test directory if it exists ##
#################################################
if [[ -d "$TEST_DIR" ]]; then
rm -rf "$TEST_DIR"
fi
# Create fresh test directory
#################################
## Create fresh test directory ##
#################################
mkdir -p "$TEST_DIR"
# Create a test git repository
##################################
## Create a test git repository ##
##################################
cd "$TEST_DIR"
git init --quiet
git config user.name "Test User"
@@ -58,7 +67,9 @@ setup_test_environment() {
echo "✅ Test environment ready"
}
# Clean up test environment
###############################
## Clean up test environment ##
###############################
cleanup_test_environment() {
echo "Cleaning up test environment..."
cd "$PROJECT_ROOT"
@@ -66,7 +77,9 @@ cleanup_test_environment() {
echo "✅ Cleanup complete"
}
# Create a test pom.xml file
################################
## Create a test pom.xml file ##
################################
create_test_pom() {
local version="$1"
cat > "$TEST_DIR/pom.xml" << EOF
@@ -87,30 +100,48 @@ create_test_pom() {
EOF
}
# Create a test branch
##########################
## Create a test branch ##
##########################
create_test_branch() {
local branch_name="$1"
local tag_name="$2"
cd "$TEST_DIR"
# Create and checkout branch
git checkout -b "$branch_name" 2>/dev/null || git checkout "$branch_name" 2>/dev/null || true
# Create a commit if needed
###############################
## Create a commit if needed ##
###############################
if [[ -z "$(git log --oneline 2>/dev/null)" ]]; then
echo "Initial commit" > README.md
git add README.md
git commit -m "Initial commit" --quiet
fi
# Create tag if specified
#############################
## Create tag if specified ##
#############################
if [[ -n "$tag_name" ]]; then
git tag -a "$tag_name" -m "Test tag $tag_name" 2>/dev/null || true
fi
################################
## Handle special HEAD case ##
################################
if [[ "$branch_name" == "HEAD" ]]; then
# For HEAD case, checkout the tag to simulate detached HEAD state
if [[ -n "$tag_name" ]]; then
git checkout "$tag_name" --quiet
fi
else
# Create and checkout branch
git checkout -b "$branch_name" 2>/dev/null || git checkout "$branch_name" 2>/dev/null || true
fi
}
# Run a test case
#####################
## Run a test case ##
#####################
run_test() {
local test_name="$1"
local branch_name="$2"
@@ -122,11 +153,15 @@ run_test() {
echo "🧪 Test: $test_name"
# Setup test case
#####################
## Setup test case ##
#####################
create_test_pom "$current_version"
create_test_branch "$branch_name" "$tag_name"
# Run the script
####################
## Run the script ##
####################
cd "$TEST_DIR"
local output
local exit_code=0
@@ -137,7 +172,9 @@ run_test() {
output=$(cd "$TEST_DIR" && POM_FILE=pom.xml "$CALCULATE_VERSION_SCRIPT" --dry-run 2>&1) || exit_code=$?
# Check if script ran successfully
######################################
## Check if script ran successfully ##
######################################
if [[ $exit_code -ne 0 ]]; then
echo " ❌ FAILED: Script exited with code $exit_code"
echo " Output: $output"
@@ -145,16 +182,32 @@ run_test() {
return 1
fi
# Extract the calculated version from output
################################################
## Extract the calculated version from output ##
################################################
local calculated_version
calculated_version=$(echo "$output" | grep "Calculated next version:" | sed 's/.*: //')
# Check if expected version contains wildcard pattern
#########################################################
## Check if expected version contains wildcard pattern ##
#########################################################
if [[ "$expected_version" == *"*"* ]]; then
# Convert wildcard pattern to regex
#######################################
## Convert wildcard pattern to regex ##
#######################################
local regex_pattern
# shellcheck disable=SC2001
regex_pattern=$(echo "$expected_version" | sed 's/\*/[a-f0-9]{7}/g')
# Handle different wildcard patterns:
# *-*-SNAPSHOT -> feature-name-commit-SNAPSHOT
# *-SNAPSHOT -> commit-SNAPSHOT
if [[ "$expected_version" == *-*-SNAPSHOT ]]; then
# Pattern: 1.4.0-*-*-SNAPSHOT -> 1.4.0-[feature-name]-[commit]-SNAPSHOT
regex_pattern=$(echo "$expected_version" | sed 's/\*/[a-zA-Z0-9-]+/g')
else
# Pattern: 1.4.0-*-SNAPSHOT -> 1.4.0-[commit]-SNAPSHOT
regex_pattern=$(echo "$expected_version" | sed 's/\*/[a-f0-9]+/g')
fi
if [[ "$calculated_version" =~ ^$regex_pattern$ ]]; then
echo " ✅ PASSED: Expected pattern $expected_version, got $calculated_version"
@@ -173,7 +226,9 @@ run_test() {
return 1
fi
else
# Exact match
#################
## Exact match ##
#################
if [[ "$calculated_version" == "$expected_version" ]]; then
echo " ✅ PASSED: Expected $expected_version, got $calculated_version"
TESTS_PASSED=$((TESTS_PASSED + 1))
@@ -193,7 +248,9 @@ run_test() {
fi
}
# Print test summary
########################
## Print test summary ##
########################
print_summary() {
echo ""
echo "=== Test Summary ==="
@@ -210,94 +267,176 @@ print_summary() {
fi
}
####################################
## Test Cases ##
####################################
################
## Test Cases ##
################
# Test main branch scenarios
################################
## Test main branch scenarios ##
################################
test_main_branch() {
echo ""
echo "=== Testing MAIN Branch ==="
# Test 1: Main branch with matching tag
###########################################
## Test 1: Main branch with matching tag ##
###########################################
run_test "Main branch with matching tag" "main" "1.5.0" "1.5.0" "v1.5.0"
# Test 2: Main branch with RC version and tag
#################################################
## Test 2: Main branch with RC version and tag ##
#################################################
run_test "Main branch with RC version" "main" "1.5.0-RC.1" "1.5.0" "v1.5.0"
# Test 3: Main branch with SNAPSHOT version and tag
#######################################################
## Test 3: Main branch with SNAPSHOT version and tag ##
#######################################################
run_test "Main branch with SNAPSHOT version" "main" "1.5.0-SNAPSHOT" "1.5.0" "v1.5.0"
# Test 4: Main branch on tag (HEAD state)
#############################################
## Test 4: Main branch on tag (HEAD state) ##
#############################################
run_test "Main branch on tag (HEAD)" "HEAD" "1.5.0" "1.5.0" "v1.5.0"
# Test 5: Main branch with v-prefixed version in pom.xml
############################################################
## Test 5: Main branch with v-prefixed version in pom.xml ##
############################################################
run_test "Main branch with v-prefixed version" "main" "v0.2.1" "0.2.1" "v0.2.1"
}
# Test develop branch scenarios
###################################
## Test develop branch scenarios ##
###################################
test_develop_branch() {
echo ""
echo "=== Testing DEVELOP Branch ==="
# Test 1: Develop branch with SNAPSHOT version (no recent activity)
#######################################################################
## Test 1: Develop branch with SNAPSHOT version (no recent activity) ##
#######################################################################
run_test "Develop branch - no recent activity" "develop" "1.5.0-SNAPSHOT" "1.5.0-SNAPSHOT" ""
# Test 2: Develop branch with RC version (should bump)
##########################################################
## Test 2: Develop branch with RC version (should bump) ##
##########################################################
run_test "Develop branch with RC version" "develop" "1.5.0-RC.1" "1.6.0-SNAPSHOT" ""
# Test 3: Develop branch with stable version (should bump)
##############################################################
## Test 3: Develop branch with stable version (should bump) ##
##############################################################
run_test "Develop branch with stable version" "develop" "1.5.0" "1.6.0-SNAPSHOT" ""
}
# Test release branch scenarios
###################################
## Test release branch scenarios ##
###################################
test_release_branch() {
echo ""
echo "=== Testing RELEASE Branch ==="
# Test 1: Release branch - first RC
#######################################
## Test 1: Release branch - first RC ##
#######################################
run_test "Release branch - first RC" "release/1.5" "1.5.0-SNAPSHOT" "1.5.0-RC.1" ""
# Test 2: Release branch - increment RC
###########################################
## Test 2: Release branch - increment RC ##
###########################################
run_test "Release branch - increment RC" "release/1.5" "1.5.0-RC.1" "1.5.0-RC.2" ""
# Test 3: Release branch - increment RC from RC.5
#####################################################
## Test 3: Release branch - increment RC from RC.5 ##
#####################################################
run_test "Release branch - increment RC.5" "release/1.5" "1.5.0-RC.5" "1.5.0-RC.6" ""
}
# Test hotfix branch scenarios
##################################
## Test hotfix branch scenarios ##
##################################
test_hotfix_branch() {
echo ""
echo "=== Testing HOTFIX Branch ==="
# Test 1: Hotfix branch - bump patch
########################################
## Test 1: Hotfix branch - bump patch ##
########################################
run_test "Hotfix branch - bump patch" "hotfix/fix-bug" "1.5.0" "1.5.1" ""
# Test 2: Hotfix branch - bump patch from RC
################################################
## Test 2: Hotfix branch - bump patch from RC ##
################################################
run_test "Hotfix branch - bump patch from RC" "hotfix/fix-bug" "1.5.0-RC.1" "1.5.1" ""
}
# Test feature branch scenarios
###################################
## Test feature branch scenarios ##
###################################
test_feature_branch() {
echo ""
echo "=== Testing FEATURE Branch ==="
# Test 1: Feature branch - convert SNAPSHOT to feature-specific version
run_test "Feature branch - convert SNAPSHOT to feature-specific version" "feature/new-feature" "1.5.0-SNAPSHOT" "1.5.0-NEW-*-SNAPSHOT" ""
###########################################################################
## Test 1: Feature branch - convert SNAPSHOT to feature-specific version ##
###########################################################################
run_test "Feature branch - convert SNAPSHOT to feature-specific version" "feature/new-feature" "1.5.0-SNAPSHOT" "1.5.0-new-feature-*-SNAPSHOT" ""
# Test 2: Feature branch - convert stable version to feature-specific SNAPSHOT
run_test "Feature branch - convert stable version to feature-specific SNAPSHOT" "feature/user-auth" "1.5.0" "1.5.0-USE-*-SNAPSHOT" ""
##################################################################################
## Test 2: Feature branch - convert stable version to feature-specific SNAPSHOT ##
##################################################################################
run_test "Feature branch - convert stable version to feature-specific SNAPSHOT" "feature/user-auth" "1.5.0" "1.5.0-user-auth-*-SNAPSHOT" ""
# Test 3: Feature branch - update existing feature-specific version with new commit hash
run_test "Feature branch - update existing feature-specific version" "feature/existing-feature" "1.5.0-EXI-abc1234-SNAPSHOT" "1.5.0-EXI-*-SNAPSHOT" ""
############################################################################################
## Test 3: Feature branch - update existing feature-specific version with new commit hash ##
############################################################################################
run_test "Feature branch - update existing feature-specific version" "feature/existing-feature" "1.5.0-SNAPSHOT" "1.5.0-existing-feature-*-SNAPSHOT" ""
############################################################################################
## Test 4: Feature branch - parse existing long feature-specific version ##
############################################################################################
run_test "Feature branch - parse existing long feature-specific version" "feature/test-new-orb" "1.4.0-test-new-orb-825957d-SNAPSHOT" "1.4.0-test-new-orb-*-SNAPSHOT" ""
}
# Test edge cases
####################################
## Test publish tag scenarios ##
####################################
test_publish_tag() {
echo ""
echo "=== Testing PUBLISH Tag Scenarios ==="
###########################################################################
## Test 1: Publish tag - convert SNAPSHOT to feature-specific version ##
## Note: Will use actual feature branch name found in git log ##
###########################################################################
run_test "Publish tag - convert SNAPSHOT to feature-specific version" "HEAD" "1.4.0-SNAPSHOT" "1.4.0-*-*-SNAPSHOT" "publish-825957d"
##################################################################################
## Test 2: Publish tag - convert stable version to feature-specific SNAPSHOT ##
## Note: Will use actual feature branch name found in git log ##
##################################################################################
run_test "Publish tag - convert stable version to feature-specific SNAPSHOT" "HEAD" "1.4.0" "1.4.0-*-*-SNAPSHOT" "publish-abc1234"
############################################################################################
## Test 3: Publish tag - update existing feature-specific version with new commit hash ##
############################################################################################
run_test "Publish tag - update existing feature-specific version" "HEAD" "1.4.0-test-feature-1234567-SNAPSHOT" "1.4.0-test-feature-*-SNAPSHOT" "publish-def5678"
############################################################################################
## Test 4: Publish tag with different commit hash format ##
## Note: Will use actual feature branch name found in git log ##
############################################################################################
run_test "Publish tag - different commit hash format" "HEAD" "1.5.0-SNAPSHOT" "1.5.0-*-*-SNAPSHOT" "publish-9a8b7c6"
}
#####################
## Test edge cases ##
#####################
test_edge_cases() {
echo ""
echo "=== Testing Edge Cases ==="
# Test 1: Invalid release branch format (should fail)
#########################################################
## Test 1: Invalid release branch format (should fail) ##
#########################################################
echo "🧪 Test: Invalid release branch format (should fail)"
TESTS_RUN=$((TESTS_RUN + 1))
@@ -318,10 +457,14 @@ test_edge_cases() {
TESTS_FAILED=$((TESTS_FAILED + 1))
fi
# Test 2: Unknown branch type
#################################
## Test 2: Unknown branch type ##
#################################
run_test "Unknown branch type" "unknown-branch" "1.5.0-SNAPSHOT" "1.5.0-SNAPSHOT" ""
# Test 3: Main branch with no tags (should fail)
####################################################
## Test 3: Main branch with no tags (should fail) ##
####################################################
echo "🧪 Test: Main branch with no tags (should fail)"
TESTS_RUN=$((TESTS_RUN + 1))
@@ -340,12 +483,16 @@ test_edge_cases() {
fi
}
# Test version parsing
##########################
## Test version parsing ##
##########################
test_version_parsing() {
echo ""
echo "=== Testing Version Parsing ==="
# Test various version formats
##################################
## Test various version formats ##
##################################
local test_versions=(
"1.0.0"
"1.0.0-SNAPSHOT"
@@ -363,7 +510,9 @@ test_version_parsing() {
for version in "${test_versions[@]}"; do
echo "🧪 Testing version parsing: $version"
# Create a simple test to verify version parsing doesn't crash
##################################################################
## Create a simple test to verify version parsing doesn't crash ##
##################################################################
create_test_pom "$version"
create_test_branch "main" ""
@@ -394,28 +543,39 @@ main() {
echo "Testing script: $CALCULATE_VERSION_SCRIPT"
echo ""
# Verify script exists
##########################
## Verify script exists ##
##########################
if [[ ! -f "$CALCULATE_VERSION_SCRIPT" ]]; then
echo "❌ Script not found: $CALCULATE_VERSION_SCRIPT"
exit 1
fi
# Setup test environment
############################
## Setup test environment ##
############################
setup_test_environment
# Run all test suites
#########################
## Run all test suites ##
#########################
test_main_branch
test_develop_branch
test_release_branch
test_hotfix_branch
test_feature_branch
test_publish_tag
test_edge_cases
test_version_parsing
# Cleanup and show results
##############################
## Cleanup and show results ##
##############################
cleanup_test_environment
print_summary
}
# Run main function
#######################
## Run main function ##
#######################
main "$@"