Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
06a3d113bd | ||
|
|
b0dc7e1eea | ||
|
|
0bbd09cdca | ||
|
|
9af91511aa | ||
|
|
7e3b967bb2 | ||
|
|
629ec15a2e | ||
|
|
f10f63fe27 | ||
|
|
c0365111f5 | ||
|
|
002b82d1f1 | ||
|
|
9751567138 | ||
|
|
0383e9fabf | ||
|
|
3ec32dd942 | ||
|
|
daa7201398 | ||
|
|
46556a1633 | ||
|
|
3c2087a0e2 | ||
|
|
732a2a86b0 | ||
|
|
c5befd275a | ||
|
|
6ba26b4072 | ||
|
|
e3b087062c | ||
|
|
8e2be0f286 | ||
|
|
78448438b6 | ||
|
|
e0ecef9746 | ||
|
|
7b408dc138 |
No files matched your search
@@ -0,0 +1,51 @@
|
||||
---
|
||||
name: Bug Report
|
||||
about: Create a report to help us improve QQQ Orb
|
||||
title: '[BUG] '
|
||||
labels: ['bug', 'needs-triage']
|
||||
assignees: ''
|
||||
---
|
||||
|
||||
## 🐛 Bug Description
|
||||
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
## 🔄 Steps to Reproduce
|
||||
|
||||
Steps to reproduce the behavior:
|
||||
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
## ✅ Expected Behavior
|
||||
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
## ❌ Actual Behavior
|
||||
|
||||
A clear and concise description of what actually happened.
|
||||
|
||||
## 📸 Screenshots
|
||||
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
## 🖥️ Environment
|
||||
|
||||
- **QQQ Orb Version**: [e.g. 2.1.0]
|
||||
- **CircleCI Version**: [e.g. 2.1]
|
||||
- **Operating System**: [e.g. macOS, Ubuntu, Windows]
|
||||
- **Project Type**: [e.g. Maven, Node.js, Hybrid]
|
||||
|
||||
## 📋 Additional Context
|
||||
|
||||
Add any other context about the problem here.
|
||||
|
||||
## 🔗 Related Issues
|
||||
|
||||
Link any related issues or discussions.
|
||||
|
||||
---
|
||||
|
||||
**Note**: This repository is a component of the QQQ framework. For general QQQ issues, please use the [main QQQ repository](https://github.com/Kingsrook/qqq/issues).
|
||||
@@ -0,0 +1,11 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: QQQ Framework Support
|
||||
url: https://github.com/Kingsrook/qqq/issues
|
||||
about: For general QQQ framework issues, please use the main QQQ repository
|
||||
- name: QQQ Community Discussions
|
||||
url: https://github.com/Kingsrook/qqq/discussions
|
||||
about: Join community discussions and ask questions
|
||||
- name: QQQ Documentation
|
||||
url: https://github.com/Kingsrook/qqq/wiki
|
||||
about: Check the QQQ Wiki for comprehensive documentation
|
||||
@@ -0,0 +1,55 @@
|
||||
---
|
||||
name: Feature Request
|
||||
about: Suggest an idea for QQQ Orb
|
||||
title: '[FEATURE] '
|
||||
labels: ['enhancement', 'needs-triage']
|
||||
assignees: ''
|
||||
---
|
||||
|
||||
## 🚀 Feature Description
|
||||
|
||||
A clear and concise description of the feature you'd like to see implemented.
|
||||
|
||||
## 💡 Motivation
|
||||
|
||||
Why is this feature needed? What problem does it solve?
|
||||
|
||||
## 📋 Detailed Description
|
||||
|
||||
A detailed description of the feature, including:
|
||||
|
||||
- **What**: What should the feature do?
|
||||
- **Why**: Why is this feature important?
|
||||
- **How**: How should it work?
|
||||
- **When**: When would this be used?
|
||||
|
||||
## 🎯 Use Cases
|
||||
|
||||
Describe specific use cases for this feature:
|
||||
|
||||
1. **Use Case 1**: Description
|
||||
2. **Use Case 2**: Description
|
||||
3. **Use Case 3**: Description
|
||||
|
||||
## 🔧 Implementation Ideas
|
||||
|
||||
If you have ideas about how this could be implemented, please share them here.
|
||||
|
||||
## 📊 Priority
|
||||
|
||||
- [ ] Low - Nice to have
|
||||
- [ ] Medium - Would be helpful
|
||||
- [ ] High - Important for workflow
|
||||
- [ ] Critical - Blocking current work
|
||||
|
||||
## 🔗 Related Issues
|
||||
|
||||
Link any related issues or discussions.
|
||||
|
||||
## 📝 Additional Context
|
||||
|
||||
Add any other context, mockups, or examples about the feature request here.
|
||||
|
||||
---
|
||||
|
||||
**Note**: This repository is a component of the QQQ framework. For general QQQ features, please use the [main QQQ repository](https://github.com/Kingsrook/qqq/issues).
|
||||
@@ -0,0 +1,66 @@
|
||||
## 📋 Description
|
||||
|
||||
Brief description of the changes in this PR.
|
||||
|
||||
## 🔗 Related Issue
|
||||
|
||||
Closes #(issue number)
|
||||
|
||||
## 🧪 Testing
|
||||
|
||||
- [ ] I have tested these changes locally
|
||||
- [ ] I have run `make test` and all tests pass
|
||||
- [ ] I have run `make lint` and all linting checks pass
|
||||
- [ ] I have validated the orb configuration with `make validate`
|
||||
|
||||
## 📝 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
|
||||
- [ ] Refactoring (no functional changes)
|
||||
- [ ] Performance improvement
|
||||
- [ ] Other (please describe):
|
||||
|
||||
## 🔍 Changes Made
|
||||
|
||||
- [ ] Updated orb configuration
|
||||
- [ ] Added new commands or jobs
|
||||
- [ ] Updated shell scripts
|
||||
- [ ] Updated documentation
|
||||
- [ ] Updated examples
|
||||
- [ ] Other (please describe):
|
||||
|
||||
## 📸 Screenshots
|
||||
|
||||
If applicable, add screenshots to help explain your changes.
|
||||
|
||||
## 🖥️ Environment
|
||||
|
||||
- **QQQ Orb Version**: [e.g. 2.1.0]
|
||||
- **CircleCI Version**: [e.g. 2.1]
|
||||
- **Operating System**: [e.g. macOS, Ubuntu, Windows]
|
||||
|
||||
## 📋 Checklist
|
||||
|
||||
- [ ] My code follows the project's style guidelines
|
||||
- [ ] I have performed a self-review of my own code
|
||||
- [ ] I have commented my code, particularly in hard-to-understand areas
|
||||
- [ ] I have made corresponding changes to the documentation
|
||||
- [ ] My changes generate no new warnings
|
||||
- [ ] I have added tests that prove my fix is effective or that my feature works
|
||||
- [ ] New and existing unit tests pass locally with my changes
|
||||
- [ ] Any dependent changes have been merged and published
|
||||
|
||||
## 🚀 Deployment Notes
|
||||
|
||||
Any special deployment considerations or notes.
|
||||
|
||||
## 📝 Additional Notes
|
||||
|
||||
Any additional information that reviewers should know.
|
||||
|
||||
---
|
||||
|
||||
**Note**: This repository is a component of the QQQ framework. For general QQQ changes, please use the [main QQQ repository](https://github.com/Kingsrook/qqq).
|
||||
@@ -2,3 +2,6 @@
|
||||
orb.yml
|
||||
.DS_Store
|
||||
target
|
||||
|
||||
# Test data directory (created dynamically during tests)
|
||||
tests/test_data
|
||||
@@ -0,0 +1,56 @@
|
||||
# Changelog
|
||||
|
||||
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]
|
||||
|
||||
### Added
|
||||
- Comprehensive README with detailed usage examples
|
||||
- CONTRIBUTING.md with development guidelines
|
||||
- SECURITY.md with security policy and reporting procedures
|
||||
- CHANGELOG.md for tracking changes
|
||||
|
||||
### Changed
|
||||
- Updated README to follow QQQ framework standards
|
||||
- Enhanced documentation structure and organization
|
||||
|
||||
## [2.1] - 2024-01-XX
|
||||
|
||||
### 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
|
||||
|
||||
### Changed
|
||||
- Improved orb structure and organization
|
||||
- Enhanced error handling and validation
|
||||
- Updated dependencies and security patches
|
||||
|
||||
### Fixed
|
||||
- Various bug fixes and stability improvements
|
||||
|
||||
## [2.0] - 2023-XX-XX
|
||||
|
||||
### Added
|
||||
- Initial CircleCI orb implementation
|
||||
- Basic Maven project support
|
||||
- Core CI/CD workflows
|
||||
|
||||
### Changed
|
||||
- Migrated from custom CI/CD to CircleCI orbs
|
||||
|
||||
## [1.x] - 2022-XX-XX
|
||||
|
||||
### Added
|
||||
- Legacy CI/CD implementation
|
||||
- Basic automation scripts
|
||||
|
||||
---
|
||||
|
||||
**Note**: For detailed release information and breaking changes, see the [QQQ Wiki](https://github.com/Kingsrook/qqq/wiki).
|
||||
@@ -0,0 +1,4 @@
|
||||
# Code of Conduct
|
||||
|
||||
|
||||
See Project level [Code of Conduct](https://github.com/Kingsrook/qqq/blob/develop/CODE_OF_CONDUCT.md)
|
||||
@@ -0,0 +1,3 @@
|
||||
# Code Style Guide
|
||||
|
||||
* See Project [Code Style Guide](https://github.com/Kingsrook/qqq/blob/develop/CODE_STYLE.md)
|
||||
@@ -0,0 +1,4 @@
|
||||
# Contributing to QBit User Role Permissions
|
||||
|
||||
* See Project [Contributing](https://github.com/Kingsrook/qqq/blob/develop/CONTRIBUTING.md)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2023 <organization>
|
||||
Copyright (c) 2021-2024 Kingsrook, LLC
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,23 +1,26 @@
|
||||
# QQQ Orb Development Makefile
|
||||
# Provides convenient commands for orb development, validation, and publishing
|
||||
|
||||
.PHONY: help pack validate clean test publish dev
|
||||
.PHONY: help pack validate clean test test-scripts test-all publish-snapshot publish-release dev check-clean check-branch
|
||||
|
||||
# Default target
|
||||
help:
|
||||
@echo "QQQ Orb Development Commands:"
|
||||
@echo ""
|
||||
@echo " make pack - Pack the orb using 'orb pack' (recommended for orb development)"
|
||||
@echo " make validate - Validate the packed orb"
|
||||
@echo " make test - Pack and validate the orb"
|
||||
@echo " make clean - Remove packed orb files"
|
||||
@echo " make dev - Development workflow: pack, validate, and show status"
|
||||
@echo " make lint - Run all CircleCI-style linting checks"
|
||||
@echo " make publish - Show publishing instructions (requires manual steps)"
|
||||
@echo " make pack - Pack the orb using 'orb pack' (recommended for orb development)"
|
||||
@echo " make validate - Validate the packed orb"
|
||||
@echo " make test - Pack and validate the orb"
|
||||
@echo " make test-scripts - Run comprehensive tests for calculate_version.sh"
|
||||
@echo " make test-all - Run all tests (orb + scripts)"
|
||||
@echo " make clean - Remove packed orb files"
|
||||
@echo " make dev - Development workflow: pack, validate, and show status"
|
||||
@echo " make lint - Run all CircleCI-style linting checks"
|
||||
@echo " make publish-snapshot - Interactive snapshot release (dev:snapshot)"
|
||||
@echo " make publish-release - Interactive production release (tagged version)"
|
||||
@echo ""
|
||||
@echo "Key Files:"
|
||||
@echo " src/@orb.yml - Main orb definition"
|
||||
@echo " target/qqq-orb-packed.yml - Packed orb (generated)"
|
||||
@echo " src/@orb.yml - Main orb definition"
|
||||
@echo " target/qqq-orb-packed.yml - Packed orb (generated)"
|
||||
|
||||
# Pack the orb using the correct command for orb development
|
||||
pack:
|
||||
@@ -36,10 +39,22 @@ validate: pack
|
||||
test: validate
|
||||
@echo "✅ All tests passed!"
|
||||
|
||||
# Test scripts: run comprehensive tests for calculate_version.sh
|
||||
test-scripts:
|
||||
@echo "🧪 Running calculate_version.sh test suite..."
|
||||
@./tests/run_tests.sh --ci
|
||||
@echo "✅ Script tests passed!"
|
||||
|
||||
# Test all: run both orb tests and script tests
|
||||
test-all: test test-scripts
|
||||
@echo "🎉 All tests completed successfully!"
|
||||
|
||||
# Clean up generated files
|
||||
clean:
|
||||
@echo "Cleaning up packed orb files..."
|
||||
@rm -rf target
|
||||
@echo "Cleaning up test data..."
|
||||
@rm -rf tests/test_data
|
||||
@echo "✅ Cleanup complete"
|
||||
|
||||
# Lint source files (same checks as CircleCI)
|
||||
@@ -52,13 +67,17 @@ lint:
|
||||
@echo ""
|
||||
@echo "2. Shell Script Linting (ShellCheck)..."
|
||||
@shellcheck src/scripts/*.sh
|
||||
@echo "✅ ShellCheck passed"
|
||||
@echo "✅ Source script ShellCheck passed"
|
||||
@echo ""
|
||||
@echo "3. CircleCI Orb Linting..."
|
||||
@echo "3. Test Script Linting (ShellCheck)..."
|
||||
@shellcheck tests/*.sh
|
||||
@echo "✅ Test script ShellCheck passed"
|
||||
@echo ""
|
||||
@echo "4. CircleCI Orb Linting..."
|
||||
@circleci orb validate src/@orb.yml
|
||||
@echo "✅ CircleCI orb validation passed"
|
||||
@echo ""
|
||||
@echo "4. Orb Packing Test..."
|
||||
@echo "5. Orb Packing Test..."
|
||||
@circleci orb pack src > /tmp/test-packed.yml
|
||||
@circleci orb validate /tmp/test-packed.yml
|
||||
@rm -f /tmp/test-packed.yml
|
||||
@@ -80,25 +99,76 @@ dev: validate
|
||||
@echo "Next steps:"
|
||||
@echo " 1. Review the packed orb: cat target/qqq-orb-packed.yml"
|
||||
@echo " 2. Test with a project configuration"
|
||||
@echo " 3. Publish when ready: make publish"
|
||||
@echo " 3. Publish when ready:"
|
||||
@echo " - make publish-snapshot (for dev testing)"
|
||||
@echo " - make publish-release (for production)"
|
||||
|
||||
# Show publishing instructions
|
||||
publish:
|
||||
@echo "🚀 Orb Publishing Instructions:"
|
||||
# Check if working directory is clean
|
||||
check-clean:
|
||||
@if [ -n "$$(git status --porcelain)" ]; then \
|
||||
echo "❌ Working directory is not clean. Commit changes first."; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
# Check if we're on the right branch for releases
|
||||
check-branch:
|
||||
@current=$$(git branch --show-current); \
|
||||
if [ "$$current" != "main" ] && [ "$$current" != "master" ]; then \
|
||||
echo "⚠️ Warning: You're on branch '$$current', not main/master"; \
|
||||
echo " This is recommended for production releases."; \
|
||||
read -p "Continue anyway? [y/N]: " confirm; \
|
||||
if [ "$$confirm" != "y" ] && [ "$$confirm" != "Y" ]; then \
|
||||
exit 1; \
|
||||
fi; \
|
||||
fi
|
||||
|
||||
# Interactive snapshot release (dev:snapshot)
|
||||
publish-snapshot: check-clean lint clean dev test-all
|
||||
@echo "🚀 Publishing Snapshot Release"
|
||||
@echo ""
|
||||
@echo "1. Ensure you're logged in to CircleCI CLI:"
|
||||
@echo " circleci auth login"
|
||||
@echo "This will publish to: kingsrook/qqq-orb@dev:snapshot"
|
||||
@echo ""
|
||||
@echo "2. Build the orb first (if not already done):"
|
||||
@echo " make dev"
|
||||
@read -p "Continue with snapshot release? [y/N]: " confirm; \
|
||||
if [ "$$confirm" != "y" ] && [ "$$confirm" != "Y" ]; then \
|
||||
echo "❌ Release cancelled"; \
|
||||
exit 1; \
|
||||
fi; \
|
||||
echo ""; \
|
||||
echo "📦 Publishing snapshot..."; \
|
||||
circleci orb publish target/qqq-orb-packed.yml kingsrook/qqq-orb@dev:snapshot; \
|
||||
echo "✅ Snapshot published successfully!"
|
||||
|
||||
# Interactive production release (tagged version)
|
||||
publish-release: check-clean check-branch lint clean dev test-all
|
||||
@echo "🚀 Publishing Production Release"
|
||||
@echo ""
|
||||
@echo "3. Publish the orb:"
|
||||
@echo " circleci orb publish target/qqq-orb-packed.yml kingsrook/qqq-orb@dev:alpha"
|
||||
@echo "This will create a git tag and publish a production version."
|
||||
@echo ""
|
||||
@echo "4. For production release:"
|
||||
@echo " circleci orb publish target/qqq-orb-packed.yml kingsrook/qqq-orb@2.1.0"
|
||||
@echo ""
|
||||
@echo "5. Promote dev version to production:"
|
||||
@echo " circleci orb publish promote kingsrook/qqq-orb@dev:alpha patch"
|
||||
@echo ""
|
||||
@echo "📚 More info: https://circleci.com/docs/orb-author/#publishing-an-orb"
|
||||
@latest=$$(git tag -l 'v*' | sort -V | tail -1); \
|
||||
if [ -n "$$latest" ]; then \
|
||||
echo "Latest version: $$latest"; \
|
||||
next=$$(echo "$$latest" | sed 's/^v//' | awk -F. '{$$NF++; print $$1"."$$2"."$$NF}'); \
|
||||
echo "Suggested next version: v$$next"; \
|
||||
else \
|
||||
echo "No previous versions found. Starting with v0.1.0"; \
|
||||
next="0.1.0"; \
|
||||
fi; \
|
||||
echo ""; \
|
||||
read -p "Enter version [v$$next]: " version; \
|
||||
version=$${version:-v$$next}; \
|
||||
if [ "$$version" != "v$$(echo $$version | sed 's/^v//')" ]; then \
|
||||
echo "❌ Version must start with 'v' (e.g., v1.0.0)"; \
|
||||
exit 1; \
|
||||
fi; \
|
||||
if git tag -l | grep -q "^$$version$$"; then \
|
||||
echo "❌ Tag $$version already exists"; \
|
||||
exit 1; \
|
||||
fi; \
|
||||
echo ""; \
|
||||
echo "Creating tag $$version..."; \
|
||||
git tag -a "$$version" -m "Release $$version"; \
|
||||
echo "Publishing kingsrook/qqq-orb@$$(echo $$version | sed 's/^v//')..."; \
|
||||
circleci orb publish target/qqq-orb-packed.yml kingsrook/qqq-orb@$$(echo $$version | sed 's/^v//'); \
|
||||
echo "Pushing tag to remote..."; \
|
||||
git push origin "$$version"; \
|
||||
echo "✅ Production release $$version published successfully!"
|
||||
@@ -1,8 +1,52 @@
|
||||
# QQQ Orb
|
||||
|
||||
CircleCI orb for Maven projects using GitFlow. Provides automated building, testing, version management, and Maven Central publishing.
|
||||
[](https://circleci.com/developer/orbs/orb/kingsrook/qqq-orb)
|
||||
[](https://circleci.com/developer/orbs/orb/kingsrook/qqq-orb)
|
||||
[](LICENSE)
|
||||
|
||||
## Quick Start
|
||||
> **CircleCI Orb for QQQ Framework Projects**
|
||||
|
||||
CircleCI orb for Maven and Node.js projects using GitFlow. Provides automated building, testing, version management, and publishing to Maven Central and npm registries.
|
||||
|
||||
## 🚀 Overview
|
||||
|
||||
QQQ Orb is a **CircleCI orb** that provides standardized CI/CD workflows for projects in the QQQ ecosystem. It handles the complete development lifecycle from building and testing to publishing releases.
|
||||
|
||||
### What This Repository Contains
|
||||
|
||||
- **CircleCI Orb**: Reusable CI/CD workflows and commands
|
||||
- **GitFlow Integration**: Automated branching and version management with intelligent version calculation
|
||||
- **Multi-Platform Support**: Maven (Java) and npm (Node.js) project support
|
||||
- **Publishing Automation**: Automated publishing to Maven Central and npm
|
||||
- **Comprehensive Testing**: Full test suite with dynamic test environments
|
||||
- **Quality Gates**: Enforced linting, testing, and validation before publishing
|
||||
|
||||
### What This Repository Does NOT Contain
|
||||
|
||||
- **QQQ Framework**: The actual low-code engine and backend
|
||||
- **Application Code**: Business logic or application-specific code
|
||||
- **Runtime Dependencies**: Libraries or frameworks used by applications
|
||||
|
||||
## 🏗️ Architecture
|
||||
|
||||
### Technology Stack
|
||||
|
||||
- **CircleCI Orbs**: Reusable configuration components
|
||||
- **GitFlow**: Branching strategy for release management
|
||||
- **Maven**: Java project build and dependency management
|
||||
- **npm**: Node.js package management
|
||||
- **Shell Scripts**: Automation and utility scripts with comprehensive testing
|
||||
- **YAML**: Configuration and workflow definitions
|
||||
|
||||
### Core Capabilities
|
||||
|
||||
- **Automated Building**: Maven and npm project compilation
|
||||
- **Testing**: Unit tests, integration tests, and coverage reporting
|
||||
- **Intelligent Version Management**: Automated semantic versioning based on GitFlow with feature branch support
|
||||
- **Publishing**: Maven Central and npm registry publishing with quality gates
|
||||
- **Documentation**: Automated documentation generation and publishing
|
||||
|
||||
## 🚀 Quick Start
|
||||
|
||||
### Using the Orb
|
||||
|
||||
@@ -54,60 +98,64 @@ workflows:
|
||||
### Required Context
|
||||
|
||||
Set up `qqq-maven-registry-credentials` context in CircleCI:
|
||||
- `MAVEN_USERNAME`, `MAVEN_PASSWORD`: Sonatype credentials
|
||||
- `GPG_PRIVATE_KEY_B64`, `GPG_KEYNAME`, `GPG_PASSPHRASE`: GPG signing
|
||||
- `GITHUB_TOKEN`: GitHub releases
|
||||
- `RDBMS_PASSWORD`: Database testing
|
||||
|
||||
| Variable | Description | Required For |
|
||||
|----------|-------------|--------------|
|
||||
| `MAVEN_USERNAME` | Sonatype username | Maven publishing |
|
||||
| `MAVEN_PASSWORD` | Sonatype password | Maven publishing |
|
||||
| `GPG_PRIVATE_KEY_B64` | Base64 encoded GPG private key | Maven signing |
|
||||
| `GPG_KEYNAME` | GPG key identifier | Maven signing |
|
||||
| `GPG_PASSPHRASE` | GPG passphrase | Maven signing |
|
||||
| `GITHUB_TOKEN` | GitHub API token | GitHub releases |
|
||||
| `RDBMS_PASSWORD` | Database password | Integration testing |
|
||||
|
||||
### Project Requirements
|
||||
|
||||
- `pom.xml` with `<revision>` property
|
||||
- `/tmp/circleci/mvn-settings.xml` (auto-generated if missing)
|
||||
- `docs/index.adoc` (optional, for documentation)
|
||||
- **Maven Projects**: `pom.xml` with `<revision>` property
|
||||
- **Node.js Projects**: `package.json` with version field
|
||||
- **Settings**: `/tmp/circleci/mvn-settings.xml` (auto-generated if missing)
|
||||
- **Documentation**: `docs/index.adoc` (optional, for documentation)
|
||||
|
||||
## Development
|
||||
## 📁 Repository Structure
|
||||
|
||||
### Prerequisites
|
||||
```bash
|
||||
# Install CircleCI CLI
|
||||
curl -fLSs https://raw.githubusercontent.com/CircleCI-Public/circleci-cli/main/install.sh | sudo bash
|
||||
```
|
||||
src/
|
||||
├── @orb.yml # Main orb definition
|
||||
├── commands/ # Reusable commands
|
||||
│ ├── mvn_build.yml # Maven build command
|
||||
│ ├── mvn_verify.yml # Maven test and verify
|
||||
│ ├── mvn_jar_deploy.yml # Maven deployment
|
||||
│ ├── node_build_package.yml # Node.js build and package
|
||||
│ ├── node_publish.yml # npm publishing
|
||||
│ └── ... # Additional commands
|
||||
├── jobs/ # Complete workflow jobs
|
||||
│ ├── mvn_publish.yml # Maven publishing workflow
|
||||
│ ├── mvn_test_only.yml # Maven testing workflow
|
||||
│ ├── node_publish.yml # npm publishing workflow
|
||||
│ └── node_test_only.yml # npm testing workflow
|
||||
├── scripts/ # Shell scripts
|
||||
│ ├── calculate_version.sh # Intelligent version calculation
|
||||
│ ├── mvn_build_compile.sh # Maven compilation
|
||||
│ ├── node_npm_auth.sh # npm authentication
|
||||
│ └── ... # Additional scripts
|
||||
├── executors/ # Execution environments
|
||||
│ └── default.yml # Default executor configuration
|
||||
└── examples/ # Usage examples
|
||||
└── build.yml # Example configuration
|
||||
|
||||
# Install linting tools
|
||||
brew install shellcheck yamllint # macOS
|
||||
tests/ # Comprehensive test suite
|
||||
├── test_calculate_version.sh # Version calculation tests
|
||||
├── run_tests.sh # Test runner with CI support
|
||||
└── README.md # Test documentation
|
||||
```
|
||||
|
||||
### Commands
|
||||
```bash
|
||||
make pack # Pack orb (resolves <<include()>>)
|
||||
make validate # Validate packed orb
|
||||
make lint # Run all linting checks
|
||||
make dev # Pack + validate
|
||||
make clean # Clean build artifacts
|
||||
```
|
||||
## 🎯 Available Jobs
|
||||
|
||||
### Publishing
|
||||
```bash
|
||||
make publish-dev # Publish as kingsrook/qqq-orb@dev:alpha
|
||||
make publish # Publish as kingsrook/qqq-orb@X.Y.Z
|
||||
```
|
||||
|
||||
## Version Management
|
||||
|
||||
Automated version calculation based on branch:
|
||||
- `develop`: Minor bump (1.5.0-SNAPSHOT → 1.6.0-SNAPSHOT)
|
||||
- `release/1.5`: RC versions (1.5.0-RC.1, 1.5.0-RC.2, ...)
|
||||
- `main`: Stable release (1.5.0-RC.3 → 1.5.0) **requires v* tag**
|
||||
- `hotfix/1.5.1`: Patch bump (1.5.0 → 1.5.1)
|
||||
|
||||
**Main branch requires release tags**: `git tag -a v1.5.0 -m "Release 1.5.0" && git push origin v1.5.0`
|
||||
|
||||
## Available Jobs
|
||||
|
||||
| Job | Branch | Output |
|
||||
|-----|--------|--------|
|
||||
| `build` | Any | Compiled artifacts |
|
||||
| `test` | Any | Test results + JaCoCo |
|
||||
| `publish` | Any | Unified publishing based on branch_type parameter |
|
||||
| Job | Branch | Output | Description |
|
||||
|-----|--------|--------|-------------|
|
||||
| `build` | Any | Compiled artifacts | Build project without testing |
|
||||
| `test` | Any | Test results + JaCoCo | Run tests with coverage |
|
||||
| `publish` | Any | Published artifacts | Unified publishing based on branch_type |
|
||||
|
||||
### Publish Job Parameters
|
||||
|
||||
@@ -115,27 +163,128 @@ Automated version calculation based on branch:
|
||||
|-----------|------|---------|-------------|
|
||||
| `branch_type` | string | "snapshot" | Branch type: snapshot, release_candidate, release, hotfix |
|
||||
|
||||
## Repository Structure
|
||||
## 🔧 Development
|
||||
|
||||
```
|
||||
src/
|
||||
├── @orb.yml # Orb definition
|
||||
├── commands/ # Reusable commands
|
||||
├── jobs/ # Complete workflow jobs
|
||||
├── scripts/ # Shell scripts (<<include()>>)
|
||||
└── examples/ # Usage examples
|
||||
### Prerequisites
|
||||
|
||||
```bash
|
||||
# Install CircleCI CLI
|
||||
curl -fLSs https://raw.githubusercontent.com/CircleCI-Public/circleci-cli/main/install.sh | sudo bash
|
||||
|
||||
# Install linting tools (macOS)
|
||||
brew install shellcheck yamllint
|
||||
|
||||
# Install linting tools (Ubuntu/Debian)
|
||||
sudo apt-get install shellcheck yamllint
|
||||
```
|
||||
|
||||
## Project Links
|
||||
### Development Commands
|
||||
|
||||
- **Main Project**: [QQQ Framework](https://github.com/Kingsrook/qqq)
|
||||
- **Issues & Planning**: [QQQ Issues](https://github.com/Kingsrook/qqq/issues)
|
||||
- **Documentation**: [QQQ Docs](https://github.com/Kingsrook/qqq/tree/main/docs)
|
||||
- **CircleCI Registry**: [kingsrook/qqq-orb](https://circleci.com/developer/orbs/orb/kingsrook/qqq-orb)
|
||||
```bash
|
||||
# Core development
|
||||
make pack # Pack orb (resolves <<include()>>)
|
||||
make validate # Validate packed orb
|
||||
make lint # Run all linting checks (YAML, ShellCheck, CircleCI orb)
|
||||
make dev # Pack + validate + show status
|
||||
make clean # Clean build artifacts and test data
|
||||
|
||||
## Usage Examples
|
||||
# Testing
|
||||
make test # Pack and validate orb
|
||||
make test-scripts # Run comprehensive calculate_version.sh tests
|
||||
make test-all # Run all tests (orb + scripts)
|
||||
|
||||
# Publishing (with full build cycle)
|
||||
make publish-snapshot # Publish as kingsrook/qqq-orb@dev:snapshot
|
||||
make publish-release # Publish as kingsrook/qqq-orb@X.Y.Z
|
||||
```
|
||||
|
||||
### Quality Gates
|
||||
|
||||
All publishing commands enforce a complete quality gate:
|
||||
|
||||
1. **check-clean**: Ensures working directory is clean
|
||||
2. **lint**: Runs all linting checks (YAML, ShellCheck, CircleCI orb validation)
|
||||
3. **clean**: Removes all generated files for fresh build
|
||||
4. **dev**: Development workflow (pack + validate)
|
||||
5. **test-all**: Comprehensive testing (orb + scripts)
|
||||
|
||||
## 📋 Intelligent Version Management
|
||||
|
||||
Automated version calculation with GitFlow integration and feature branch support:
|
||||
|
||||
| Branch Pattern | Version Change | Example |
|
||||
|----------------|----------------|---------|
|
||||
| `develop` | Minor bump | `1.5.0-SNAPSHOT` → `1.6.0-SNAPSHOT` |
|
||||
| `release/1.5` | RC versions | `1.5.0-RC.1`, `1.5.0-RC.2`, ... |
|
||||
| `main` | Stable release | `1.5.0-RC.3` → `1.5.0` **requires v* tag** |
|
||||
| `hotfix/1.5.1` | Patch bump | `1.5.0` → `1.5.1` |
|
||||
| `feature/new-feature` | Feature-specific | `1.5.0-SNAPSHOT` → `1.5.0-NEW-abc1234-SNAPSHOT` |
|
||||
|
||||
### 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`
|
||||
- **Dynamic Updates**: Automatically updates when commit hash changes
|
||||
- **Safe Abbreviations**: 3-character uppercase feature name abbreviation
|
||||
|
||||
### Version Parsing Support
|
||||
|
||||
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`
|
||||
|
||||
**Main branch requires release tags**:
|
||||
```bash
|
||||
git tag -a v1.5.0 -m "Release 1.5.0"
|
||||
git push origin v1.5.0
|
||||
```
|
||||
|
||||
## 🧪 Comprehensive Testing
|
||||
|
||||
### Test Suite Features
|
||||
|
||||
- **Dynamic Test Environment**: Creates isolated git repositories for each test run
|
||||
- **Pattern Matching**: Supports wildcard patterns for commit hash testing
|
||||
- **Comprehensive Coverage**: Tests all branch types and edge cases
|
||||
- **CI Integration**: Clean exit codes and minimal output for CI systems
|
||||
- **Automatic Cleanup**: Test data removed automatically after tests
|
||||
|
||||
### Running Tests
|
||||
|
||||
```bash
|
||||
# Run all tests
|
||||
make test-all
|
||||
|
||||
# Run specific test suites
|
||||
make test # Orb tests only
|
||||
make test-scripts # Script tests only
|
||||
|
||||
# Run with verbose output
|
||||
./tests/run_tests.sh --verbose
|
||||
|
||||
# Run in CI mode
|
||||
./tests/run_tests.sh --ci
|
||||
|
||||
# Run linting checks
|
||||
make lint
|
||||
```
|
||||
|
||||
### Test Coverage
|
||||
|
||||
The orb includes comprehensive testing:
|
||||
- **YAML Validation**: CircleCI orb configuration validation
|
||||
- **Shell Script Testing**: ShellCheck for shell script validation
|
||||
- **Orb Packing**: Tests orb packing and resolution
|
||||
- **Version Calculation**: 20+ test cases covering all branch types
|
||||
- **Integration Testing**: End-to-end workflow testing
|
||||
- **Edge Case Testing**: Invalid formats, missing tags, error conditions
|
||||
|
||||
## 📦 Usage Examples
|
||||
|
||||
### Maven Project (Backend Only)
|
||||
|
||||
**Backend only (default)**:
|
||||
```yaml
|
||||
jobs:
|
||||
- qqq-orb/publish:
|
||||
@@ -143,7 +292,8 @@ jobs:
|
||||
branch_type: snapshot
|
||||
```
|
||||
|
||||
**Release with GitHub release**:
|
||||
### Node.js Project (Frontend Only)
|
||||
|
||||
```yaml
|
||||
jobs:
|
||||
- qqq-orb/publish:
|
||||
@@ -151,6 +301,93 @@ jobs:
|
||||
branch_type: release
|
||||
```
|
||||
|
||||
## License
|
||||
### Hybrid Project (Maven + Node.js)
|
||||
|
||||
MIT License - see [LICENSE](LICENSE)
|
||||
```yaml
|
||||
jobs:
|
||||
- qqq-orb/publish:
|
||||
context: qqq-maven-registry-credentials
|
||||
branch_type: release_candidate
|
||||
```
|
||||
|
||||
## 🤝 Contributing
|
||||
|
||||
**Important**: This repository is a component of the QQQ framework. All contributions, issues, and discussions should go through the main QQQ repository.
|
||||
|
||||
### Development Workflow
|
||||
|
||||
1. **Fork the main QQQ repository**: https://github.com/Kingsrook/qqq
|
||||
2. **Create a feature branch**: `git checkout -b feature/amazing-feature`
|
||||
3. **Make your changes** (including orb changes if applicable)
|
||||
4. **Run tests**: `make test-all`
|
||||
5. **Run linting**: `make lint`
|
||||
6. **Commit your changes**: `git commit -m 'Add amazing feature'`
|
||||
7. **Push to the branch**: `git push origin feature/amazing-feature`
|
||||
8. **Open a Pull Request** to the main QQQ repository
|
||||
|
||||
### Code Standards
|
||||
|
||||
- **YAML**: Follow CircleCI orb best practices
|
||||
- **Shell Scripts**: Use ShellCheck for validation, comprehensive testing
|
||||
- **Documentation**: Update README and inline documentation
|
||||
- **Testing**: Comprehensive test coverage with dynamic test environments
|
||||
- **Quality Gates**: All changes must pass linting and testing
|
||||
|
||||
## 📄 License
|
||||
|
||||
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
||||
|
||||
```
|
||||
QQQ Orb
|
||||
Copyright (C) 2021-2024 Kingsrook, LLC
|
||||
651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States
|
||||
contact@kingsrook.com | https://github.com/Kingsrook/
|
||||
```
|
||||
|
||||
## 🆘 Support & Community
|
||||
|
||||
### ⚠️ Important: Use Main QQQ Repository
|
||||
|
||||
**All support, issues, discussions, and community interactions should go through the main QQQ repository:**
|
||||
|
||||
- **Main Repository**: https://github.com/Kingsrook/qqq
|
||||
- **Issues**: https://github.com/Kingsrook/qqq/issues
|
||||
- **Discussions**: https://github.com/Kingsrook/qqq/discussions
|
||||
- **Wiki**: https://github.com/Kingsrook/qqq/wiki
|
||||
|
||||
### Why This Repository Exists
|
||||
|
||||
This repository is maintained separately from the main QQQ repository to:
|
||||
- **Enable independent orb development** and versioning
|
||||
- **Allow orb-specific CI/CD** and deployment pipelines
|
||||
- **Provide clear separation** between orb and framework concerns
|
||||
- **Support different release cycles** for CI/CD tools vs. core framework
|
||||
|
||||
### Getting Help
|
||||
|
||||
- **Documentation**: Check the [QQQ Wiki](https://github.com/Kingsrook/qqq/wiki)
|
||||
- **Issues**: Report bugs and feature requests on [Main QQQ Issues](https://github.com/Kingsrook/qqq/issues)
|
||||
- **Discussions**: Join community discussions on [Main QQQ Discussions](https://github.com/Kingsrook/qqq/discussions)
|
||||
- **Questions**: Ask questions in the main QQQ repository
|
||||
|
||||
### Contact Information
|
||||
|
||||
- **Company**: Kingsrook, LLC
|
||||
- **Email**: contact@kingsrook.com
|
||||
- **Website**: https://qrun.io
|
||||
- **Main GitHub**: https://github.com/Kingsrook/qqq
|
||||
- **CircleCI Registry**: [kingsrook/qqq-orb](https://circleci.com/developer/orbs/orb/kingsrook/qqq-orb)
|
||||
|
||||
## 🙏 Acknowledgments
|
||||
|
||||
- **CircleCI Team**: For the excellent CI/CD platform and orb system
|
||||
- **Maven Team**: For the powerful Java build system
|
||||
- **npm Team**: For the Node.js package management system
|
||||
- **QQQ Framework Team**: For the underlying low-code platform
|
||||
- **Open Source Community**: For the tools and libraries that make this possible
|
||||
|
||||
---
|
||||
|
||||
**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**
|
||||
@@ -0,0 +1,3 @@
|
||||
# Security Policy
|
||||
|
||||
* See Project [Security Policy](https://github.com/Kingsrook/qqq/blob/develop/SECURITY.md)
|
||||
@@ -14,3 +14,4 @@ orbs:
|
||||
localstack: localstack/platform@2.1
|
||||
browser-tools: circleci/browser-tools@1.4.7
|
||||
slack: circleci/slack@5.2.1
|
||||
node: circleci/node@4.7
|
||||
File renamed without changes.
Executable
+17
@@ -0,0 +1,17 @@
|
||||
description: >
|
||||
Builds the package
|
||||
- Cleans and builds the package
|
||||
- Persists build artifacts to workspace for use in publishing jobs
|
||||
|
||||
steps:
|
||||
- run:
|
||||
name: "Clean and build"
|
||||
command: npm run clean-and-install
|
||||
# Persist build artifacts to workspace for use in publishing jobs
|
||||
- persist_to_workspace:
|
||||
root: .
|
||||
paths:
|
||||
- lib/ # Compiled TypeScript output
|
||||
- package.json # Updated package manifest
|
||||
- README.md # Documentation
|
||||
- LICENSE # License file
|
||||
Executable
+14
@@ -0,0 +1,14 @@
|
||||
description: >
|
||||
Installs Node.js dependencies
|
||||
- Installs Node.js dependencies using NPM
|
||||
- Builds the TypeScript project
|
||||
|
||||
steps:
|
||||
# Install packages with NPM, using CircleCI's optimized caching
|
||||
- node/install-packages:
|
||||
pkg-manager: npm
|
||||
cache-path: node_modules
|
||||
# Build TypeScript project after dependencies are installed
|
||||
- run:
|
||||
name: "Build TypeScript project"
|
||||
command: npm run prepublishOnly
|
||||
Executable
+18
@@ -0,0 +1,18 @@
|
||||
description: >
|
||||
Manages the version of the project
|
||||
- Adds SSH keys for Git operations
|
||||
- Sets up Git identity for version commits
|
||||
- Synchronizes NPM version
|
||||
- Commits version changes if modified
|
||||
|
||||
steps:
|
||||
- add_ssh_keys # injects the CircleCI User Key (write-capable)
|
||||
- run:
|
||||
name: Set up Git identity for version commits
|
||||
command: <<include(scripts/node_git_config.sh)>>
|
||||
- run:
|
||||
name: "Synchronize NPM version"
|
||||
command: <<include(scripts/sync-npm-version.sh)>>
|
||||
- run:
|
||||
name: Commit version changes if modified
|
||||
command: <<include(scripts/node_version_commit.sh)>>
|
||||
Executable
+12
@@ -0,0 +1,12 @@
|
||||
description: >
|
||||
Publishes the package to NPM
|
||||
- Sets up NPM authentication
|
||||
- Publishes the package to NPM
|
||||
|
||||
steps:
|
||||
- run:
|
||||
name: "Setup NPM authentication"
|
||||
command: <<include(scripts/node_npm_auth.sh)>>
|
||||
- run:
|
||||
name: "Publish to NPM"
|
||||
command: npm publish --access public
|
||||
Executable
+12
@@ -0,0 +1,12 @@
|
||||
description: >
|
||||
Runs the tests and linting
|
||||
- Runs the tests
|
||||
- Runs the linting
|
||||
|
||||
steps:
|
||||
- run:
|
||||
name: "Run tests"
|
||||
command: npm test
|
||||
- run:
|
||||
name: "Run linting"
|
||||
command: npm run lint
|
||||
@@ -5,7 +5,7 @@ description: >
|
||||
usage:
|
||||
version: 2.1
|
||||
orbs:
|
||||
qqq-orb: kingsrook/qqq-orb@2.1
|
||||
qqq-orb: kingsrook/qqq-orb@0.3.1
|
||||
|
||||
workflows:
|
||||
# Test workflow for feature branches
|
||||
|
||||
@@ -13,15 +13,9 @@ parameters:
|
||||
|
||||
steps:
|
||||
- checkout
|
||||
- manage_version
|
||||
- mvn_manage_version
|
||||
- frontend_build
|
||||
- frontend_test
|
||||
- frontend_package
|
||||
- mvn_jar_deploy
|
||||
- when:
|
||||
condition:
|
||||
or:
|
||||
- equal: ["snapshot", << parameters.branch_type >>]
|
||||
- equal: ["release_candidate", << parameters.branch_type >>]
|
||||
steps:
|
||||
- git_operations
|
||||
- git_operations
|
||||
@@ -10,21 +10,29 @@ parameters:
|
||||
type: string
|
||||
default: "snapshot"
|
||||
description: "Branch type: snapshot, release_candidate, release, or hotfix"
|
||||
check_middleware_api_versions:
|
||||
type: boolean
|
||||
default: false
|
||||
description: "Whether to run middleware API version checks"
|
||||
publish_asciidoc:
|
||||
type: boolean
|
||||
default: false
|
||||
description: "Whether to publish AsciiDoc documentation"
|
||||
|
||||
steps:
|
||||
- checkout
|
||||
- mvn_build
|
||||
- manage_version
|
||||
- mvn_manage_version
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- mvn_verify
|
||||
- check_middleware_api_versions
|
||||
- mvn_jar_deploy
|
||||
- when:
|
||||
condition:
|
||||
or:
|
||||
- equal: ["snapshot", << parameters.branch_type >>]
|
||||
- equal: ["release_candidate", << parameters.branch_type >>]
|
||||
condition: << parameters.check_middleware_api_versions >>
|
||||
steps:
|
||||
- git_operations
|
||||
- publish_asciidoc
|
||||
- check_middleware_api_versions
|
||||
- mvn_jar_deploy
|
||||
- git_operations
|
||||
- when:
|
||||
condition: << parameters.publish_asciidoc >>
|
||||
steps:
|
||||
- publish_asciidoc
|
||||
@@ -6,8 +6,17 @@ description: >
|
||||
|
||||
executor: localstack/default
|
||||
|
||||
parameters:
|
||||
check_middleware_api_versions:
|
||||
type: boolean
|
||||
default: false
|
||||
description: "Whether to run middleware API version checks"
|
||||
|
||||
steps:
|
||||
- checkout
|
||||
- mvn_build
|
||||
- mvn_verify
|
||||
- check_middleware_api_versions
|
||||
- when:
|
||||
condition: << parameters.check_middleware_api_versions >>
|
||||
steps:
|
||||
- check_middleware_api_versions
|
||||
@@ -0,0 +1,22 @@
|
||||
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
|
||||
|
||||
executor: localstack/default
|
||||
|
||||
parameters:
|
||||
branch_type:
|
||||
type: string
|
||||
default: "snapshot"
|
||||
description: "Branch type: snapshot, release_candidate, release, or hotfix"
|
||||
|
||||
steps:
|
||||
- checkout
|
||||
- node_install_dependencies
|
||||
- node_run_tests
|
||||
- node_manage_version
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- node_build_package
|
||||
- node_publish
|
||||
@@ -0,0 +1,17 @@
|
||||
description: >
|
||||
Unified test-only job for all branch types
|
||||
Handles testing based on branch type
|
||||
Supports: snapshot, release_candidate, release, and hotfix workflows
|
||||
|
||||
executor: localstack/default
|
||||
|
||||
parameters:
|
||||
branch_type:
|
||||
type: string
|
||||
default: "snapshot"
|
||||
description: "Branch type: snapshot, release_candidate, release, or hotfix"
|
||||
|
||||
steps:
|
||||
- checkout
|
||||
- node_install_dependencies
|
||||
- node_run_tests
|
||||
+239
-143
@@ -18,7 +18,7 @@ set -e
|
||||
###################
|
||||
## Configuration ##
|
||||
###################
|
||||
POM_FILE="pom.xml"
|
||||
POM_FILE="${POM_FILE:-pom.xml}"
|
||||
DRY_RUN=false
|
||||
|
||||
##################################
|
||||
@@ -33,9 +33,10 @@ fi
|
||||
## Get current branch and version ##
|
||||
####################################
|
||||
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
||||
CURRENT_VERSION=$(grep '<revision>' $POM_FILE | sed 's/.*<revision>//;s/<.*//')
|
||||
CURRENT_VERSION=$(grep '<revision>' "$POM_FILE" | sed 's/.*<revision>//;s/<.*//')
|
||||
|
||||
# Check if we're on a tag (HEAD means we're on a tag)
|
||||
CURRENT_TAG=""
|
||||
if [[ "$CURRENT_BRANCH" == "HEAD" ]]; then
|
||||
# Get the tag name we're on
|
||||
CURRENT_TAG=$(git describe --tags --exact-match HEAD 2>/dev/null || echo "")
|
||||
@@ -67,6 +68,12 @@ echo "Current version: $CURRENT_VERSION"
|
||||
############################################
|
||||
extract_version_parts() {
|
||||
local version=$1
|
||||
|
||||
# Remove 'v' prefix if present
|
||||
if [[ "$version" =~ ^v(.+)$ ]]; then
|
||||
version=${BASH_REMATCH[1]}
|
||||
fi
|
||||
|
||||
########################################
|
||||
## Handle RC versions like 1.5.0-RC.1 ##
|
||||
########################################
|
||||
@@ -81,6 +88,13 @@ extract_version_parts() {
|
||||
MAJOR=${BASH_REMATCH[1]}
|
||||
MINOR=${BASH_REMATCH[2]}
|
||||
PATCH=${BASH_REMATCH[3]}
|
||||
#############################################################
|
||||
## Handle feature-specific versions like 1.5.0-NEW-abc1234-SNAPSHOT ##
|
||||
#############################################################
|
||||
elif [[ "$version" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)-[A-Z]{3}-[a-f0-9]{7}-SNAPSHOT$ ]]; then
|
||||
MAJOR=${BASH_REMATCH[1]}
|
||||
MINOR=${BASH_REMATCH[2]}
|
||||
PATCH=${BASH_REMATCH[3]}
|
||||
#######################################
|
||||
## Handle stable versions like 1.5.0 ##
|
||||
#######################################
|
||||
@@ -94,140 +108,6 @@ extract_version_parts() {
|
||||
fi
|
||||
}
|
||||
|
||||
#############################################################
|
||||
## Function to calculate next version based on branch type ##
|
||||
#############################################################
|
||||
calculate_next_version() {
|
||||
local branch=$1
|
||||
|
||||
case "$branch" in
|
||||
"develop")
|
||||
#############################################################################
|
||||
## Check if we just merged a release branch back to develop ##
|
||||
## Look for very specific patterns that indicate a release completion ##
|
||||
## Only look at recent commits to avoid historical merges triggering bumps ##
|
||||
#############################################################################
|
||||
RECENT_RELEASE_MERGES=$(git log --oneline -10 --grep="Merge.*release.*into.*develop" --grep="Merge.*release.*back.*develop" --grep="Bump.*version.*after.*release.*v" --since="3 days ago" || true)
|
||||
|
||||
#######################################################################
|
||||
## Also check if current version suggests we're ready for next cycle ##
|
||||
#######################################################################
|
||||
if [[ -n "$RECENT_RELEASE_MERGES" ]] || [[ "$CURRENT_VERSION" =~ -RC\.[0-9]+$ ]] || [[ "$CURRENT_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||
#########################################################################
|
||||
## We just merged a release or have an RC/stable version, bump to next ##
|
||||
#########################################################################
|
||||
NEW_VERSION="$MAJOR.$((MINOR + 1)).0-SNAPSHOT"
|
||||
else
|
||||
################################################################
|
||||
## Keep current SNAPSHOT version - no recent release activity ##
|
||||
################################################################
|
||||
NEW_VERSION="$CURRENT_VERSION"
|
||||
fi
|
||||
;;
|
||||
|
||||
"main")
|
||||
###############################################################################
|
||||
## Main should always have stable versions ##
|
||||
## Check for version tags to detect releases instead of merge commits ##
|
||||
###############################################################################
|
||||
echo "In Main - Looking for the most recent version tag"
|
||||
|
||||
# If we're on a tag, use that tag; otherwise find the latest tag
|
||||
if [[ "$CURRENT_BRANCH" == "main" && -n "$CURRENT_TAG" ]]; then
|
||||
LATEST_TAG="$CURRENT_TAG"
|
||||
echo "Using current tag: $LATEST_TAG"
|
||||
else
|
||||
LATEST_TAG=$(git describe --tags --abbrev=0 --match="v*" 2>/dev/null || echo "")
|
||||
echo "Found latest tag: $LATEST_TAG"
|
||||
fi
|
||||
|
||||
if [[ -n "$LATEST_TAG" ]]; then
|
||||
# Extract version from tag (e.g., v1.5.0 -> 1.5.0)
|
||||
if [[ "$LATEST_TAG" =~ ^v([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
|
||||
TAG_VERSION=${BASH_REMATCH[1]}
|
||||
echo "Release tag: $LATEST_TAG (version: $TAG_VERSION)"
|
||||
|
||||
# Check if current version matches the tag
|
||||
if [[ "$CURRENT_VERSION" == "$TAG_VERSION" ]]; then
|
||||
################################################################
|
||||
## We're at the tagged release, keep stable version ##
|
||||
################################################################
|
||||
NEW_VERSION="$CURRENT_VERSION"
|
||||
echo "Version matches release tag, keeping stable version"
|
||||
elif [[ "$CURRENT_VERSION" =~ -RC\.[0-9]+$ ]]; then
|
||||
########################################################################
|
||||
## We have an RC version, convert to the tag version ##
|
||||
########################################################################
|
||||
NEW_VERSION="$TAG_VERSION"
|
||||
echo "Converting RC version to tag version: $NEW_VERSION"
|
||||
else
|
||||
#####################################################################
|
||||
## Keep current version (might be ahead of tag) ##
|
||||
#####################################################################
|
||||
NEW_VERSION="$CURRENT_VERSION"
|
||||
echo "Keeping current version (ahead of tag)"
|
||||
fi
|
||||
else
|
||||
echo "Warning: Tag format not recognized: $LATEST_TAG"
|
||||
NEW_VERSION="$CURRENT_VERSION"
|
||||
fi
|
||||
else
|
||||
#####################################################################
|
||||
## No tags found - main branch should always have a release tag ##
|
||||
#####################################################################
|
||||
echo "ERROR: No version tags found on main branch"
|
||||
echo "Main branch should always have a corresponding release tag (e.g., v1.5.0)"
|
||||
echo "Please create a release tag before deploying from main"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
||||
release/*)
|
||||
############################################################################
|
||||
## Extract major.minor from branch name (e.g., release/1.5 -> 1.5.0-RC.n) ##
|
||||
############################################################################
|
||||
if [[ "$branch" =~ release/([0-9]+)\.([0-9]+) ]]; then
|
||||
BRANCH_MAJOR=${BASH_REMATCH[1]}
|
||||
BRANCH_MINOR=${BASH_REMATCH[2]}
|
||||
|
||||
############################################
|
||||
## Check if we already have an RC version ##
|
||||
############################################
|
||||
if [[ "$CURRENT_VERSION" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)-RC\.([0-9]+)$ ]]; then
|
||||
################################################
|
||||
## Extract current RC number and increment it ##
|
||||
################################################
|
||||
CURRENT_RC=${BASH_REMATCH[4]}
|
||||
NEW_RC=$((CURRENT_RC + 1))
|
||||
NEW_VERSION="$BRANCH_MAJOR.$BRANCH_MINOR.0-RC.$NEW_RC"
|
||||
else
|
||||
###############################
|
||||
## First RC for this release ##
|
||||
###############################
|
||||
NEW_VERSION="$BRANCH_MAJOR.$BRANCH_MINOR.0-RC.1"
|
||||
fi
|
||||
else
|
||||
echo "ERROR: Invalid release branch format: $branch"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
||||
hotfix/*)
|
||||
###################################
|
||||
## Bump patch version for hotfix ##
|
||||
###################################
|
||||
NEW_VERSION="$MAJOR.$MINOR.$((PATCH + 1))"
|
||||
;;
|
||||
|
||||
feature/*|*)
|
||||
###############################################################
|
||||
## Feature branches inherit version from develop, no changes ##
|
||||
###############################################################
|
||||
NEW_VERSION="$CURRENT_VERSION"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
#########################################
|
||||
## Function to set version using Maven ##
|
||||
#########################################
|
||||
@@ -237,7 +117,6 @@ set_version() {
|
||||
if [[ "$DRY_RUN" == "true" ]]; then
|
||||
echo "DRY RUN: Would set version to: $new_version"
|
||||
echo "Command: mvn versions:set-property -Dproperty=revision -DnewVersion=$new_version -DgenerateBackupPoms=false"
|
||||
|
||||
return
|
||||
fi
|
||||
|
||||
@@ -247,12 +126,11 @@ set_version() {
|
||||
## Use Maven versions plugin to set version ##
|
||||
##############################################
|
||||
mvn versions:set-property -Dproperty=revision -DnewVersion="$new_version" -DgenerateBackupPoms=false
|
||||
|
||||
|
||||
#######################
|
||||
## Verify the change ##
|
||||
#######################
|
||||
ACTUAL_VERSION=$(grep "<revision>" $POM_FILE | sed 's/.*<revision>//;s/<.*//')
|
||||
ACTUAL_VERSION=$(grep "<revision>" "$POM_FILE" | sed 's/.*<revision>//;s/<.*//')
|
||||
if [[ "$ACTUAL_VERSION" == "$new_version" ]]; then
|
||||
echo "✅ Version successfully updated to: $ACTUAL_VERSION"
|
||||
else
|
||||
@@ -261,6 +139,195 @@ set_version() {
|
||||
fi
|
||||
}
|
||||
|
||||
#############################################
|
||||
## Branch Detection and Routing Functions ##
|
||||
#############################################
|
||||
|
||||
detect_branch_type() {
|
||||
local branch=$1
|
||||
|
||||
if [[ "$branch" == "main" ]]; then
|
||||
echo "main"
|
||||
elif [[ "$branch" == "develop" ]]; then
|
||||
echo "develop"
|
||||
elif [[ "$branch" =~ ^release/ ]]; then
|
||||
echo "release"
|
||||
elif [[ "$branch" =~ ^hotfix/ ]]; then
|
||||
echo "hotfix"
|
||||
elif [[ "$branch" =~ ^feature/ ]]; then
|
||||
echo "feature"
|
||||
else
|
||||
echo "unknown"
|
||||
fi
|
||||
}
|
||||
|
||||
#############################################
|
||||
## Branch-Specific Version Handlers ##
|
||||
#############################################
|
||||
|
||||
handle_main_branch() {
|
||||
echo "=== Handling MAIN branch ==="
|
||||
echo "Main branch should always have stable versions"
|
||||
echo "Looking for the most recent version tag"
|
||||
|
||||
# If we're on a tag, use that tag; otherwise find the latest tag
|
||||
local latest_tag=""
|
||||
if [[ -n "$CURRENT_TAG" ]]; then
|
||||
latest_tag="$CURRENT_TAG"
|
||||
echo "Using current tag: $latest_tag"
|
||||
else
|
||||
latest_tag=$(git describe --tags --abbrev=0 --match="v*" 2>/dev/null || echo "")
|
||||
echo "Found latest tag: $latest_tag"
|
||||
fi
|
||||
|
||||
if [[ -n "$latest_tag" ]]; then
|
||||
# Extract version from tag (e.g., v1.5.0 -> 1.5.0)
|
||||
if [[ "$latest_tag" =~ ^v([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
|
||||
local tag_version=${BASH_REMATCH[1]}
|
||||
echo "Release tag: $latest_tag (version: $tag_version)"
|
||||
|
||||
# Check if current version matches the tag
|
||||
if [[ "$CURRENT_VERSION" == "$tag_version" ]]; then
|
||||
echo "Version matches release tag, keeping stable version"
|
||||
NEW_VERSION="$CURRENT_VERSION"
|
||||
elif [[ "$CURRENT_VERSION" =~ -RC\.[0-9]+$ ]]; then
|
||||
echo "Converting RC version to tag version: $tag_version"
|
||||
NEW_VERSION="$tag_version"
|
||||
else
|
||||
NEW_VERSION="$tag_version"
|
||||
fi
|
||||
else
|
||||
echo "Warning: Tag format not recognized: $latest_tag"
|
||||
NEW_VERSION="$CURRENT_VERSION"
|
||||
fi
|
||||
else
|
||||
echo "ERROR: No version tags found on main branch"
|
||||
echo "Main branch should always have a corresponding release tag (e.g., v1.5.0)"
|
||||
echo "Please create a release tag before deploying from main"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
handle_develop_branch() {
|
||||
echo "=== Handling DEVELOP branch ==="
|
||||
echo "Develop branch manages SNAPSHOT versions"
|
||||
|
||||
# Check if we just merged a release branch back to develop
|
||||
local recent_release_merges
|
||||
recent_release_merges=$(git log --oneline -10 --grep="Merge.*release.*into.*develop" --grep="Merge.*release.*back.*develop" --grep="Bump.*version.*after.*release.*v" --since="3 days ago" || true)
|
||||
|
||||
# Also check if current version suggests we're ready for next cycle
|
||||
if [[ -n "$recent_release_merges" ]] || [[ "$CURRENT_VERSION" =~ -RC\.[0-9]+$ ]] || [[ "$CURRENT_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||
echo "Recent release activity detected or RC/stable version found"
|
||||
echo "Bumping to next minor version SNAPSHOT"
|
||||
NEW_VERSION="$MAJOR.$((MINOR + 1)).0-SNAPSHOT"
|
||||
else
|
||||
echo "No recent release activity, keeping current SNAPSHOT version"
|
||||
NEW_VERSION="$CURRENT_VERSION"
|
||||
fi
|
||||
}
|
||||
|
||||
handle_release_branch() {
|
||||
echo "=== Handling RELEASE branch ==="
|
||||
echo "Release branch manages RC versions"
|
||||
|
||||
# Extract major.minor from branch name (e.g., release/1.5 -> 1.5.0-RC.n)
|
||||
if [[ "$CURRENT_BRANCH" =~ release/([0-9]+)\.([0-9]+) ]]; then
|
||||
local branch_major=${BASH_REMATCH[1]}
|
||||
local branch_minor=${BASH_REMATCH[2]}
|
||||
|
||||
echo "Release branch: $branch_major.$branch_minor"
|
||||
|
||||
# Check if we already have an RC version
|
||||
if [[ "$CURRENT_VERSION" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)-RC\.([0-9]+)$ ]]; then
|
||||
# Extract current RC number and increment it
|
||||
local current_rc=${BASH_REMATCH[4]}
|
||||
local new_rc=$((current_rc + 1))
|
||||
echo "Incrementing RC from $current_rc to $new_rc"
|
||||
NEW_VERSION="$branch_major.$branch_minor.0-RC.$new_rc"
|
||||
else
|
||||
# First RC for this release
|
||||
echo "Creating first RC for this release"
|
||||
NEW_VERSION="$branch_major.$branch_minor.0-RC.1"
|
||||
fi
|
||||
else
|
||||
echo "ERROR: Invalid release branch format: $CURRENT_BRANCH"
|
||||
echo "Expected format: release/X.Y (e.g., release/1.5)"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
handle_hotfix_branch() {
|
||||
echo "=== Handling HOTFIX branch ==="
|
||||
echo "Hotfix branch bumps patch version"
|
||||
|
||||
NEW_VERSION="$MAJOR.$MINOR.$((PATCH + 1))"
|
||||
echo "Bumping patch version: $CURRENT_VERSION -> $NEW_VERSION"
|
||||
}
|
||||
|
||||
handle_feature_branch() {
|
||||
echo "=== Handling FEATURE branch ==="
|
||||
echo "Feature branches create unique SNAPSHOT versions"
|
||||
|
||||
# Extract feature name from branch (e.g., feature/new-feature -> new-feature)
|
||||
local feature_name
|
||||
if [[ "$CURRENT_BRANCH" =~ ^feature/(.+)$ ]]; then
|
||||
feature_name=${BASH_REMATCH[1]}
|
||||
else
|
||||
feature_name="unknown"
|
||||
fi
|
||||
|
||||
# Create safe abbreviation (first 3 characters, uppercase)
|
||||
local feature_abbrev
|
||||
feature_abbrev=$(echo "$feature_name" | cut -c1-3 | tr '[:lower:]' '[:upper:]')
|
||||
|
||||
# Generate short commit hash
|
||||
local commit_hash
|
||||
commit_hash=$(git rev-parse --short HEAD 2>/dev/null || echo "unknown")
|
||||
|
||||
# Create unique SNAPSHOT version
|
||||
if [[ "$CURRENT_VERSION" =~ ^([0-9]+\.[0-9]+\.[0-9]+)-SNAPSHOT$ ]]; then
|
||||
# Convert SNAPSHOT to feature-specific version
|
||||
local base_version=${BASH_REMATCH[1]}
|
||||
NEW_VERSION="$base_version-$feature_abbrev-$commit_hash-SNAPSHOT"
|
||||
echo "Creating feature-specific version: $NEW_VERSION"
|
||||
elif [[ "$CURRENT_VERSION" =~ ^([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
|
||||
# Convert stable version to feature-specific SNAPSHOT
|
||||
NEW_VERSION="$CURRENT_VERSION-$feature_abbrev-$commit_hash-SNAPSHOT"
|
||||
echo "Converting stable version to feature-specific SNAPSHOT: $NEW_VERSION"
|
||||
else
|
||||
# Check if it's already a feature-specific format
|
||||
if [[ "$CURRENT_VERSION" =~ ^([0-9]+\.[0-9]+\.[0-9]+)-([A-Z]{3})-([a-f0-9]{7})-SNAPSHOT$ ]]; then
|
||||
local base_version=${BASH_REMATCH[1]}
|
||||
local existing_abbrev=${BASH_REMATCH[2]}
|
||||
local existing_hash=${BASH_REMATCH[3]}
|
||||
|
||||
# Check if the commit hash has changed
|
||||
if [[ "$existing_hash" != "$commit_hash" ]]; then
|
||||
# Update to new commit hash
|
||||
NEW_VERSION="$base_version-$existing_abbrev-$commit_hash-SNAPSHOT"
|
||||
echo "Updating feature-specific version with new commit hash: $NEW_VERSION"
|
||||
else
|
||||
# Keep current version if commit hash hasn't changed
|
||||
NEW_VERSION="$CURRENT_VERSION"
|
||||
echo "Keeping current feature-specific version: $NEW_VERSION"
|
||||
fi
|
||||
else
|
||||
# Unknown format, keep as-is
|
||||
NEW_VERSION="$CURRENT_VERSION"
|
||||
echo "Keeping current version (unknown format): $NEW_VERSION"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
handle_unknown_branch() {
|
||||
echo "=== Handling UNKNOWN branch ==="
|
||||
echo "Unknown branch type, keeping current version"
|
||||
|
||||
NEW_VERSION="$CURRENT_VERSION"
|
||||
echo "Keeping current version: $NEW_VERSION"
|
||||
}
|
||||
|
||||
####################
|
||||
## Main execution ##
|
||||
####################
|
||||
@@ -278,9 +345,38 @@ main() {
|
||||
echo ""
|
||||
|
||||
############################
|
||||
## Calculate next version ##
|
||||
## Detect branch type and route ##
|
||||
############################
|
||||
calculate_next_version "$CURRENT_BRANCH"
|
||||
local branch_type
|
||||
branch_type=$(detect_branch_type "$CURRENT_BRANCH")
|
||||
echo "Detected branch type: $branch_type"
|
||||
echo ""
|
||||
|
||||
############################
|
||||
## Route to appropriate handler ##
|
||||
############################
|
||||
case "$branch_type" in
|
||||
"main")
|
||||
handle_main_branch
|
||||
;;
|
||||
"develop")
|
||||
handle_develop_branch
|
||||
;;
|
||||
"release")
|
||||
handle_release_branch
|
||||
;;
|
||||
"hotfix")
|
||||
handle_hotfix_branch
|
||||
;;
|
||||
"feature")
|
||||
handle_feature_branch
|
||||
;;
|
||||
*)
|
||||
handle_unknown_branch
|
||||
;;
|
||||
esac
|
||||
|
||||
echo ""
|
||||
echo "Calculated next version: $NEW_VERSION"
|
||||
echo ""
|
||||
|
||||
@@ -296,7 +392,7 @@ main() {
|
||||
###################
|
||||
echo ""
|
||||
echo "Changes made:"
|
||||
git diff $POM_FILE
|
||||
git diff "$POM_FILE"
|
||||
else
|
||||
echo "No version change needed. Current version is correct for branch: $CURRENT_BRANCH"
|
||||
fi
|
||||
@@ -308,4 +404,4 @@ main() {
|
||||
#######################
|
||||
## Run main function ##
|
||||
#######################
|
||||
main "$@"
|
||||
main "$@"
|
||||
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
@@ -27,7 +27,14 @@ if [[ -n "$(git status --porcelain pom.xml)" ]]; then
|
||||
NEW_VERSION=$(grep '<revision>' pom.xml | sed 's/.*<revision>//;s/<.*//')
|
||||
git add pom.xml
|
||||
git commit -m "Bump version to $NEW_VERSION [skip ci]"
|
||||
git push origin "HEAD:${CIRCLE_BRANCH}"
|
||||
|
||||
if [ -n "$CIRCLE_BRANCH" ]; then
|
||||
git push origin "HEAD:${CIRCLE_BRANCH}"
|
||||
else
|
||||
# Tag build: push to main (or your default branch)
|
||||
git push origin HEAD:main
|
||||
fi
|
||||
|
||||
echo "Version updated to: $NEW_VERSION and pushed"
|
||||
else
|
||||
echo "No version change needed"
|
||||
|
||||
Executable
+18
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
############################################################################
|
||||
## node_git_config.sh
|
||||
## Git Configuration Setup for Node.js Projects
|
||||
##
|
||||
## This script sets up Git identity for version commits in Node.js projects.
|
||||
## It configures the Git user email and name for CircleCI operations.
|
||||
##
|
||||
## Usage: Called by node_manage_version command
|
||||
## Output: Configures Git identity for CI operations
|
||||
############################################################################
|
||||
|
||||
set -e
|
||||
|
||||
echo "Setting up Git identity for version commits"
|
||||
git config user.email "ci@kingsrook.com"
|
||||
git config user.name "CircleCI"
|
||||
Executable
+24
@@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
|
||||
############################################################################
|
||||
## node_npm_auth.sh
|
||||
## NPM Authentication Setup Script
|
||||
##
|
||||
## This script configures NPM authentication for publishing to the public registry.
|
||||
## It sets up the authentication token and verifies the authentication.
|
||||
##
|
||||
## Process:
|
||||
## 1. Configures NPM authentication for public registry
|
||||
## 2. Verifies authentication by checking current user
|
||||
##
|
||||
## Usage: Called by node_publish command
|
||||
## Output: Sets up NPM authentication and verifies it
|
||||
############################################################################
|
||||
|
||||
set -e
|
||||
|
||||
echo "Configuring NPM authentication for public registry"
|
||||
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
|
||||
|
||||
echo "Verifying authentication by checking current user"
|
||||
npm whoami
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
|
||||
############################################################################
|
||||
## node_version_commit.sh
|
||||
## Node.js Version Commit Management Script
|
||||
##
|
||||
## This script handles committing version changes to Git for Node.js projects.
|
||||
## It checks if the package.json file has been modified and commits the changes if needed.
|
||||
## It also pushes the changes back to the current branch.
|
||||
##
|
||||
## Process:
|
||||
## 1. Checks if package.json has been modified
|
||||
## 2. Extracts the new version from package.json
|
||||
## 3. Commits the changes with skip ci flag
|
||||
## 4. Pushes changes to the current branch
|
||||
##
|
||||
## Usage: Called by node_manage_version command
|
||||
## Output: Commits and pushes version changes if package.json was modified
|
||||
############################################################################
|
||||
|
||||
set -e
|
||||
|
||||
echo "Checking for package.json version changes"
|
||||
if [[ -n "$(git status --porcelain package.json)" ]]; then
|
||||
NEW_VERSION=$(grep '"version"' package.json | sed 's/.*"version": "//;s/".*//')
|
||||
git add package.json
|
||||
git commit -m "Bump version to $NEW_VERSION [skip ci]"
|
||||
git push origin "HEAD:${CIRCLE_BRANCH}"
|
||||
echo "Version updated to: $NEW_VERSION and pushed"
|
||||
else
|
||||
echo "No version change needed"
|
||||
fi
|
||||
Executable
+105
@@ -0,0 +1,105 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# NPM Version Synchronization Script for qqq-frontend-core
|
||||
# This script updates package.json version based on the current GitFlow branch and versioning policy
|
||||
|
||||
PACKAGE_JSON="package.json"
|
||||
DRY_RUN=false
|
||||
|
||||
if [[ "$1" == "--dry-run" ]]; then
|
||||
DRY_RUN=true
|
||||
echo "DRY RUN MODE - No changes will be made"
|
||||
fi
|
||||
|
||||
# Get current branch
|
||||
CURRENT_BRANCH=$(git branch --show-current)
|
||||
echo "Current branch: $CURRENT_BRANCH"
|
||||
|
||||
# Get current NPM version
|
||||
NPM_VERSION=$(grep '"version"' $PACKAGE_JSON | sed 's/.*"version": "//;s/".*//')
|
||||
echo "Current NPM version: $NPM_VERSION"
|
||||
|
||||
# Determine target version based on GitFlow branch
|
||||
if [[ "$CURRENT_BRANCH" == "main" ]]; then
|
||||
# Main branch - should be a release version (e.g., 1.0.0)
|
||||
# Extract major.minor from current version
|
||||
MAJOR_MINOR="${NPM_VERSION%.*}"
|
||||
TARGET_VERSION="$MAJOR_MINOR.0"
|
||||
echo "Main branch detected - targeting release version: $TARGET_VERSION"
|
||||
elif [[ "$CURRENT_BRANCH" == "develop" ]]; then
|
||||
# Develop branch - should be a snapshot version (e.g., 1.0.127-SNAPSHOT)
|
||||
# Increment patch version for develop
|
||||
MAJOR_MINOR_PATCH="${NPM_VERSION%-*}"
|
||||
MAJOR_MINOR="${MAJOR_MINOR_PATCH%.*}"
|
||||
PATCH="${MAJOR_MINOR_PATCH##*.}"
|
||||
NEW_PATCH=$((PATCH + 1))
|
||||
TARGET_VERSION="$MAJOR_MINOR.$NEW_PATCH-SNAPSHOT"
|
||||
echo "Develop branch detected - targeting snapshot version: $TARGET_VERSION"
|
||||
elif [[ "$CURRENT_BRANCH" == release/* ]]; then
|
||||
# Release branch - should be a release candidate (e.g., 1.0.0-RC.1, 1.0.0-RC.2, etc.)
|
||||
RELEASE_VERSION=$(echo "$CURRENT_BRANCH" | sed 's/release\///')
|
||||
|
||||
# Check if current version is already an RC for this release
|
||||
if [[ "$NPM_VERSION" =~ ^$RELEASE_VERSION-RC\.([0-9]+)$ ]]; then
|
||||
# Increment existing RC number
|
||||
CURRENT_RC=${BASH_REMATCH[1]}
|
||||
NEW_RC=$((CURRENT_RC + 1))
|
||||
TARGET_VERSION="$RELEASE_VERSION-RC.$NEW_RC"
|
||||
echo "Release branch detected - incrementing RC from $NPM_VERSION to $TARGET_VERSION"
|
||||
else
|
||||
# First RC for this release
|
||||
TARGET_VERSION="$RELEASE_VERSION-RC.1"
|
||||
echo "Release branch detected - creating first RC: $TARGET_VERSION"
|
||||
fi
|
||||
elif [[ "$CURRENT_BRANCH" == hotfix/* ]]; then
|
||||
# Hotfix branch - should be a patch version (e.g., 1.0.1)
|
||||
HOTFIX_VERSION=$(echo "$CURRENT_BRANCH" | sed 's/hotfix\///')
|
||||
TARGET_VERSION="$HOTFIX_VERSION"
|
||||
echo "Hotfix branch detected - targeting patch version: $TARGET_VERSION"
|
||||
else
|
||||
# Feature branch - should be a snapshot version
|
||||
MAJOR_MINOR_PATCH="${NPM_VERSION%-*}"
|
||||
MAJOR_MINOR="${MAJOR_MINOR_PATCH%.*}"
|
||||
PATCH="${MAJOR_MINOR_PATCH##*.}"
|
||||
NEW_PATCH=$((PATCH + 1))
|
||||
TARGET_VERSION="$MAJOR_MINOR.$NEW_PATCH-SNAPSHOT"
|
||||
echo "Feature branch detected - targeting snapshot version: $TARGET_VERSION"
|
||||
fi
|
||||
|
||||
echo "Target version: $TARGET_VERSION"
|
||||
|
||||
if [[ "$NPM_VERSION" == "$TARGET_VERSION" ]]; then
|
||||
echo "✅ Versions are already synchronized"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ "$DRY_RUN" == "true" ]]; then
|
||||
echo "DRY RUN: Would update package.json version from '$NPM_VERSION' to '$TARGET_VERSION'"
|
||||
echo "Command: sed -i 's/\"version\": \"$NPM_VERSION\"/\"version\": \"$TARGET_VERSION\"/' $PACKAGE_JSON"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Updating package.json version from '$NPM_VERSION' to '$TARGET_VERSION'"
|
||||
|
||||
# Update version in package.json (macOS compatible)
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
sed -i '' "s/\"version\": \"$NPM_VERSION\"/\"version\": \"$TARGET_VERSION\"/" $PACKAGE_JSON
|
||||
else
|
||||
sed -i "s/\"version\": \"$NPM_VERSION\"/\"version\": \"$TARGET_VERSION\"/" $PACKAGE_JSON
|
||||
fi
|
||||
|
||||
# Verify the update
|
||||
ACTUAL_NPM_VERSION=$(grep '"version"' $PACKAGE_JSON | sed 's/.*"version": "//;s/".*//')
|
||||
if [[ "$ACTUAL_NPM_VERSION" == "$TARGET_VERSION" ]]; then
|
||||
echo "✅ NPM version successfully updated to: $ACTUAL_NPM_VERSION"
|
||||
else
|
||||
echo "❌ NPM version update failed. Expected: $TARGET_VERSION, Got: $ACTUAL_NPM_VERSION"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "=== NPM version synchronization complete ==="
|
||||
echo "Previous: $NPM_VERSION"
|
||||
echo "Current: $ACTUAL_NPM_VERSION"
|
||||
echo "Branch: $CURRENT_BRANCH"
|
||||
+113
@@ -0,0 +1,113 @@
|
||||
# Calculate Version Script Test Suite
|
||||
|
||||
This directory contains comprehensive tests for the `calculate_version.sh` script.
|
||||
|
||||
## Test Files
|
||||
|
||||
- `test_calculate_version.sh` - Main test suite with comprehensive test cases
|
||||
- `run_tests.sh` - Test runner with different output modes
|
||||
- `README.md` - This documentation
|
||||
|
||||
## Running Tests
|
||||
|
||||
### Quick Test Run
|
||||
```bash
|
||||
./tests/run_tests.sh
|
||||
```
|
||||
|
||||
### Verbose Test Run
|
||||
```bash
|
||||
./tests/run_tests.sh --verbose
|
||||
```
|
||||
|
||||
### CI Mode (minimal output)
|
||||
```bash
|
||||
./tests/run_tests.sh --ci
|
||||
```
|
||||
|
||||
### Direct Test Suite
|
||||
```bash
|
||||
./tests/test_calculate_version.sh
|
||||
./tests/test_calculate_version.sh --verbose
|
||||
```
|
||||
|
||||
## Test Coverage
|
||||
|
||||
The test suite covers:
|
||||
|
||||
### Branch Types
|
||||
- **Main Branch**: Tests stable version handling, tag detection, RC conversion
|
||||
- **Develop Branch**: Tests SNAPSHOT version management, release detection
|
||||
- **Release Branch**: Tests RC version creation and incrementing
|
||||
- **Hotfix Branch**: Tests patch version bumping
|
||||
- **Feature Branch**: Tests version inheritance
|
||||
|
||||
### Edge Cases
|
||||
- Invalid branch formats
|
||||
- Unknown branch types
|
||||
- Missing tags on main branch
|
||||
- Various version formats (stable, SNAPSHOT, RC)
|
||||
|
||||
### Version Parsing
|
||||
- Standard versions: `1.0.0`
|
||||
- SNAPSHOT versions: `1.0.0-SNAPSHOT`
|
||||
- RC versions: `1.0.0-RC.1`, `1.0.0-RC.10`
|
||||
- Multi-digit versions: `10.20.30`
|
||||
|
||||
## Test Environment
|
||||
|
||||
The test suite:
|
||||
1. Creates a temporary test directory
|
||||
2. Initializes a test git repository
|
||||
3. Creates test pom.xml files with different versions
|
||||
4. Creates test branches and tags
|
||||
5. Runs the calculate_version.sh script
|
||||
6. Validates the output
|
||||
7. Cleans up test data
|
||||
|
||||
## Integration with Make
|
||||
|
||||
The tests are integrated into the Makefile and can be run with:
|
||||
```bash
|
||||
make test-scripts
|
||||
```
|
||||
|
||||
## Test Results
|
||||
|
||||
The test suite provides:
|
||||
- ✅ Pass/fail status for each test
|
||||
- 📊 Summary statistics
|
||||
- 🔍 Detailed output in verbose mode
|
||||
- 🚫 Clean exit codes for CI integration
|
||||
|
||||
## Adding New Tests
|
||||
|
||||
To add new test cases:
|
||||
|
||||
1. Add a new test function in `test_calculate_version.sh`
|
||||
2. Call `run_test` with appropriate parameters:
|
||||
```bash
|
||||
run_test "Test Name" "branch_name" "current_version" "expected_version" "tag_name"
|
||||
```
|
||||
3. Add the test function to the main execution flow
|
||||
4. Update this README if needed
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Common Issues
|
||||
|
||||
1. **Permission denied**: Make sure test scripts are executable
|
||||
```bash
|
||||
chmod +x tests/*.sh
|
||||
```
|
||||
|
||||
2. **Git not found**: Ensure git is installed and available in PATH
|
||||
|
||||
3. **Test failures**: Run with `--verbose` to see detailed output
|
||||
```bash
|
||||
./tests/run_tests.sh --verbose
|
||||
```
|
||||
|
||||
### Debug Mode
|
||||
|
||||
For debugging, you can run individual test functions by modifying the main function in `test_calculate_version.sh` to call only specific test functions.
|
||||
Executable
+82
@@ -0,0 +1,82 @@
|
||||
#!/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]
|
||||
############################################################################
|
||||
|
||||
set -e
|
||||
|
||||
###################
|
||||
## Configuration ##
|
||||
###################
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
TEST_SCRIPT="$SCRIPT_DIR/test_calculate_version.sh"
|
||||
VERBOSE=false
|
||||
CI_MODE=false
|
||||
|
||||
##################################
|
||||
## Parse command line arguments ##
|
||||
##################################
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
--verbose)
|
||||
VERBOSE=true
|
||||
shift
|
||||
;;
|
||||
--ci)
|
||||
CI_MODE=true
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 [--verbose] [--ci]"
|
||||
echo " --verbose Show detailed test output"
|
||||
echo " --ci CI mode (minimal output, exit codes for CI)"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
####################
|
||||
## Main execution ##
|
||||
####################
|
||||
main() {
|
||||
echo "🧪 Running calculate_version.sh test suite..."
|
||||
|
||||
# Verify test script exists
|
||||
if [[ ! -f "$TEST_SCRIPT" ]]; then
|
||||
echo "❌ Test script not found: $TEST_SCRIPT"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 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
|
||||
echo "Running tests in CI mode..."
|
||||
if "$TEST_SCRIPT" $test_args > /tmp/test_output.log 2>&1; then
|
||||
echo "✅ All tests passed!"
|
||||
exit 0
|
||||
else
|
||||
echo "❌ Tests failed!"
|
||||
echo "Test output:"
|
||||
cat /tmp/test_output.log
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
# Interactive mode: full output
|
||||
"$TEST_SCRIPT" $test_args
|
||||
fi
|
||||
}
|
||||
|
||||
# Run main function
|
||||
main "$@"
|
||||
Executable
+421
@@ -0,0 +1,421 @@
|
||||
#!/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]
|
||||
############################################################################
|
||||
|
||||
set -e
|
||||
|
||||
###################
|
||||
## Configuration ##
|
||||
###################
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
|
||||
CALCULATE_VERSION_SCRIPT="$PROJECT_ROOT/src/scripts/calculate_version.sh"
|
||||
TEST_DIR="$PROJECT_ROOT/tests/test_data"
|
||||
VERBOSE=false
|
||||
|
||||
# Test counters
|
||||
TESTS_RUN=0
|
||||
TESTS_PASSED=0
|
||||
TESTS_FAILED=0
|
||||
|
||||
##################################
|
||||
## Parse command line arguments ##
|
||||
##################################
|
||||
if [[ "$1" == "--verbose" ]]; then
|
||||
VERBOSE=true
|
||||
fi
|
||||
|
||||
####################################
|
||||
## Test Framework Functions ##
|
||||
####################################
|
||||
|
||||
# Create a temporary directory for test data
|
||||
setup_test_environment() {
|
||||
echo "Setting up test environment..."
|
||||
|
||||
# Remove existing test directory if it exists
|
||||
if [[ -d "$TEST_DIR" ]]; then
|
||||
rm -rf "$TEST_DIR"
|
||||
fi
|
||||
|
||||
# Create fresh test directory
|
||||
mkdir -p "$TEST_DIR"
|
||||
|
||||
# Create a test git repository
|
||||
cd "$TEST_DIR"
|
||||
git init --quiet
|
||||
git config user.name "Test User"
|
||||
git config user.email "test@example.com"
|
||||
|
||||
echo "✅ Test environment ready"
|
||||
}
|
||||
|
||||
# Clean up test environment
|
||||
cleanup_test_environment() {
|
||||
echo "Cleaning up test environment..."
|
||||
cd "$PROJECT_ROOT"
|
||||
rm -rf "$TEST_DIR"
|
||||
echo "✅ Cleanup complete"
|
||||
}
|
||||
|
||||
# Create a test pom.xml file
|
||||
create_test_pom() {
|
||||
local version="$1"
|
||||
cat > "$TEST_DIR/pom.xml" << EOF
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.example</groupId>
|
||||
<artifactId>test-project</artifactId>
|
||||
<version>1.0.0</version>
|
||||
|
||||
<properties>
|
||||
<revision>$version</revision>
|
||||
</properties>
|
||||
</project>
|
||||
EOF
|
||||
}
|
||||
|
||||
# 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
|
||||
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
|
||||
if [[ -n "$tag_name" ]]; then
|
||||
git tag -a "$tag_name" -m "Test tag $tag_name" 2>/dev/null || true
|
||||
fi
|
||||
}
|
||||
|
||||
# Run a test case
|
||||
run_test() {
|
||||
local test_name="$1"
|
||||
local branch_name="$2"
|
||||
local current_version="$3"
|
||||
local expected_version="$4"
|
||||
local tag_name="$5"
|
||||
|
||||
TESTS_RUN=$((TESTS_RUN + 1))
|
||||
|
||||
echo "🧪 Test: $test_name"
|
||||
|
||||
# Setup test case
|
||||
create_test_pom "$current_version"
|
||||
create_test_branch "$branch_name" "$tag_name"
|
||||
|
||||
# Run the script
|
||||
cd "$TEST_DIR"
|
||||
local output
|
||||
local exit_code=0
|
||||
|
||||
if [[ "$VERBOSE" == "true" ]]; then
|
||||
echo " Running: POM_FILE=pom.xml $CALCULATE_VERSION_SCRIPT --dry-run"
|
||||
fi
|
||||
|
||||
output=$(cd "$TEST_DIR" && POM_FILE=pom.xml "$CALCULATE_VERSION_SCRIPT" --dry-run 2>&1) || exit_code=$?
|
||||
|
||||
# Check if script ran successfully
|
||||
if [[ $exit_code -ne 0 ]]; then
|
||||
echo " ❌ FAILED: Script exited with code $exit_code"
|
||||
echo " Output: $output"
|
||||
TESTS_FAILED=$((TESTS_FAILED + 1))
|
||||
return 1
|
||||
fi
|
||||
|
||||
# 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
|
||||
if [[ "$expected_version" == *"*"* ]]; then
|
||||
# Convert wildcard pattern to regex
|
||||
local regex_pattern
|
||||
# shellcheck disable=SC2001
|
||||
regex_pattern=$(echo "$expected_version" | sed 's/\*/[a-f0-9]{7}/g')
|
||||
|
||||
if [[ "$calculated_version" =~ ^$regex_pattern$ ]]; then
|
||||
echo " ✅ PASSED: Expected pattern $expected_version, got $calculated_version"
|
||||
TESTS_PASSED=$((TESTS_PASSED + 1))
|
||||
return 0
|
||||
else
|
||||
echo " ❌ FAILED: Expected pattern $expected_version, got $calculated_version"
|
||||
if [[ "$VERBOSE" == "true" ]]; then
|
||||
echo " Full output:"
|
||||
# Add indentation to each line
|
||||
while IFS= read -r line; do
|
||||
echo " $line"
|
||||
done <<< "$output"
|
||||
fi
|
||||
TESTS_FAILED=$((TESTS_FAILED + 1))
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
# Exact match
|
||||
if [[ "$calculated_version" == "$expected_version" ]]; then
|
||||
echo " ✅ PASSED: Expected $expected_version, got $calculated_version"
|
||||
TESTS_PASSED=$((TESTS_PASSED + 1))
|
||||
return 0
|
||||
else
|
||||
echo " ❌ FAILED: Expected $expected_version, got $calculated_version"
|
||||
if [[ "$VERBOSE" == "true" ]]; then
|
||||
echo " Full output:"
|
||||
# Add indentation to each line
|
||||
while IFS= read -r line; do
|
||||
echo " $line"
|
||||
done <<< "$output"
|
||||
fi
|
||||
TESTS_FAILED=$((TESTS_FAILED + 1))
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Print test summary
|
||||
print_summary() {
|
||||
echo ""
|
||||
echo "=== Test Summary ==="
|
||||
echo "Tests run: $TESTS_RUN"
|
||||
echo "Tests passed: $TESTS_PASSED"
|
||||
echo "Tests failed: $TESTS_FAILED"
|
||||
|
||||
if [[ $TESTS_FAILED -eq 0 ]]; then
|
||||
echo "🎉 All tests passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ Some tests failed!"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
####################################
|
||||
## Test Cases ##
|
||||
####################################
|
||||
|
||||
# Test main branch scenarios
|
||||
test_main_branch() {
|
||||
echo ""
|
||||
echo "=== Testing MAIN Branch ==="
|
||||
|
||||
# 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
|
||||
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
|
||||
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)
|
||||
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
|
||||
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() {
|
||||
echo ""
|
||||
echo "=== Testing DEVELOP Branch ==="
|
||||
|
||||
# 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)
|
||||
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)
|
||||
run_test "Develop branch with stable version" "develop" "1.5.0" "1.6.0-SNAPSHOT" ""
|
||||
}
|
||||
|
||||
# Test release branch scenarios
|
||||
test_release_branch() {
|
||||
echo ""
|
||||
echo "=== Testing RELEASE Branch ==="
|
||||
|
||||
# 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
|
||||
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
|
||||
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() {
|
||||
echo ""
|
||||
echo "=== Testing HOTFIX Branch ==="
|
||||
|
||||
# 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
|
||||
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() {
|
||||
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 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 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 edge cases
|
||||
test_edge_cases() {
|
||||
echo ""
|
||||
echo "=== Testing Edge Cases ==="
|
||||
|
||||
# Test 1: Invalid release branch format (should fail)
|
||||
echo "🧪 Test: Invalid release branch format (should fail)"
|
||||
TESTS_RUN=$((TESTS_RUN + 1))
|
||||
|
||||
create_test_pom "1.5.0-SNAPSHOT"
|
||||
create_test_branch "release/invalid" ""
|
||||
|
||||
cd "$TEST_DIR"
|
||||
local output
|
||||
local exit_code=0
|
||||
|
||||
output=$(cd "$TEST_DIR" && POM_FILE=pom.xml "$CALCULATE_VERSION_SCRIPT" --dry-run 2>&1) || exit_code=$?
|
||||
|
||||
if [[ $exit_code -ne 0 ]]; then
|
||||
echo " ✅ PASSED: Script correctly failed with invalid release branch format"
|
||||
TESTS_PASSED=$((TESTS_PASSED + 1))
|
||||
else
|
||||
echo " ❌ FAILED: Script should have failed with invalid release branch format"
|
||||
TESTS_FAILED=$((TESTS_FAILED + 1))
|
||||
fi
|
||||
|
||||
# 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)
|
||||
echo "🧪 Test: Main branch with no tags (should fail)"
|
||||
TESTS_RUN=$((TESTS_RUN + 1))
|
||||
|
||||
create_test_pom "1.5.0-SNAPSHOT"
|
||||
create_test_branch "main" "" # No tag
|
||||
|
||||
cd "$TEST_DIR"
|
||||
output=$(cd "$TEST_DIR" && POM_FILE=pom.xml "$CALCULATE_VERSION_SCRIPT" --dry-run 2>&1) || exit_code=$?
|
||||
|
||||
if [[ $exit_code -ne 0 ]]; then
|
||||
echo " ✅ PASSED: Script correctly failed with no tags on main branch"
|
||||
TESTS_PASSED=$((TESTS_PASSED + 1))
|
||||
else
|
||||
echo " ❌ FAILED: Script should have failed with no tags on main branch"
|
||||
TESTS_FAILED=$((TESTS_FAILED + 1))
|
||||
fi
|
||||
}
|
||||
|
||||
# Test version parsing
|
||||
test_version_parsing() {
|
||||
echo ""
|
||||
echo "=== Testing Version Parsing ==="
|
||||
|
||||
# Test various version formats
|
||||
local test_versions=(
|
||||
"1.0.0"
|
||||
"1.0.0-SNAPSHOT"
|
||||
"1.0.0-RC.1"
|
||||
"1.0.0-RC.10"
|
||||
"10.20.30"
|
||||
"10.20.30-SNAPSHOT"
|
||||
"10.20.30-RC.5"
|
||||
"v1.0.0"
|
||||
"v1.0.0-SNAPSHOT"
|
||||
"v1.0.0-RC.1"
|
||||
"v10.20.30"
|
||||
)
|
||||
|
||||
for version in "${test_versions[@]}"; do
|
||||
echo "🧪 Testing version parsing: $version"
|
||||
|
||||
# Create a simple test to verify version parsing doesn't crash
|
||||
create_test_pom "$version"
|
||||
create_test_branch "main" ""
|
||||
|
||||
cd "$TEST_DIR"
|
||||
local output
|
||||
local exit_code=0
|
||||
|
||||
output=$(cd "$TEST_DIR" && POM_FILE=pom.xml "$CALCULATE_VERSION_SCRIPT" --dry-run 2>&1) || exit_code=$?
|
||||
|
||||
if [[ $exit_code -eq 0 ]]; then
|
||||
echo " ✅ PASSED: Version $version parsed successfully"
|
||||
TESTS_PASSED=$((TESTS_PASSED + 1))
|
||||
else
|
||||
echo " ❌ FAILED: Version $version parsing failed"
|
||||
echo " Output: $output"
|
||||
TESTS_FAILED=$((TESTS_FAILED + 1))
|
||||
fi
|
||||
|
||||
TESTS_RUN=$((TESTS_RUN + 1))
|
||||
done
|
||||
}
|
||||
|
||||
####################
|
||||
## Main execution ##
|
||||
####################
|
||||
main() {
|
||||
echo "=== QQQ Version Calculator Test Suite ==="
|
||||
echo "Testing script: $CALCULATE_VERSION_SCRIPT"
|
||||
echo ""
|
||||
|
||||
# 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
|
||||
|
||||
# Run all test suites
|
||||
test_main_branch
|
||||
test_develop_branch
|
||||
test_release_branch
|
||||
test_hotfix_branch
|
||||
test_feature_branch
|
||||
test_edge_cases
|
||||
test_version_parsing
|
||||
|
||||
# Cleanup and show results
|
||||
cleanup_test_environment
|
||||
print_summary
|
||||
}
|
||||
|
||||
# Run main function
|
||||
main "$@"
|
||||
Reference in new issue
Block a user