From 9037bebeb532475af68921cefff348c4a85374bd Mon Sep 17 00:00:00 2001 From: skola Date: Mon, 6 Oct 2025 15:38:51 -0400 Subject: [PATCH 01/30] fix: remove unused imports --- .pre-commit-config.yaml | 23 +- .script/auto_version_increment.py | 414 +++++++++++++++++++++++++ .script/pre_push_version_increment.py | 39 +++ .script/setup_pysherlock_automation.py | 387 +++++++++++++++++++++++ .script/test_version_automation.py | 333 ++++++++++++++++++++ 5 files changed, 1191 insertions(+), 5 deletions(-) create mode 100644 .script/auto_version_increment.py create mode 100644 .script/pre_push_version_increment.py create mode 100644 .script/setup_pysherlock_automation.py create mode 100644 .script/test_version_automation.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f7e408eac..f0cb01506 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -59,9 +59,22 @@ repos: hooks: - id: check-github-workflows -- repo: https://github.com/ansys/pre-commit-hooks - rev: v0.5.2 +# Temporarily disabled due to Windows symlink permissions +# - repo: https://github.com/ansys/pre-commit-hooks +# rev: v0.5.2 +# hooks: +# - id: add-license-headers +# args: +# - --start_year=2021 + +# Automatic version increment on pre-push +- repo: local hooks: - - id: add-license-headers - args: - - --start_year=2021 + - id: auto-version-increment + name: Auto Version Increment + entry: python3 pre_push_version_increment.py + language: system + stages: [pre-push] + always_run: true + pass_filenames: false + description: "Automatically increment version based on changes" diff --git a/.script/auto_version_increment.py b/.script/auto_version_increment.py new file mode 100644 index 000000000..fe2b8b20c --- /dev/null +++ b/.script/auto_version_increment.py @@ -0,0 +1,414 @@ +#!/usr/bin/env python3 +""" +Automatic Version Incrementer for PySherlock + +This script automatically increments the version in pyproject.toml based on: +1. Changelog entries (using towncrier fragments) +2. Git commit messages +3. File changes analysis + +It runs as a pre-push hook to automatically bump version before merging. +""" + +from enum import Enum +from pathlib import Path +import re +import subprocess +import sys +from typing import List, Optional, Tuple + +import toml + + +class VersionBumpType(Enum): + PATCH = "patch" + MINOR = "minor" + MAJOR = "major" + + +class Colors: + RED = "\033[0;31m" + GREEN = "\033[0;32m" + YELLOW = "\033[1;33m" + BLUE = "\033[0;34m" + BOLD = "\033[1m" + NC = "\033[0m" + + +def log(message: str, color: str = Colors.NC): + """Print colored log message.""" + print(f"{color}{message}{Colors.NC}") + + +def run_git_command(command: List[str]) -> Tuple[bool, str]: + """Run git command and return success status and output.""" + try: + result = subprocess.run(["git"] + command, capture_output=True, text=True, check=True) + return True, result.stdout.strip() + except subprocess.CalledProcessError as e: + return False, e.stderr.strip() if e.stderr else str(e) + + +def parse_version(version_str: str) -> Tuple[int, int, int, str]: + """Parse semantic version string into components.""" + # Handle dev versions like "0.12.dev0" + if ".dev" in version_str: + version_str = version_str.split(".dev")[0] + + # Parse semantic version + match = re.match(r"^(\d+)\.(\d+)\.(\d+)(.*)$", version_str) + if match: + major = int(match.group(1)) + minor = int(match.group(2)) + patch = int(match.group(3)) + suffix = match.group(4) + return major, minor, patch, suffix + + # Fallback for incomplete versions + parts = version_str.split(".") + major = int(parts[0]) if len(parts) > 0 else 0 + minor = int(parts[1]) if len(parts) > 1 else 0 + patch = int(parts[2]) if len(parts) > 2 else 0 + return major, minor, patch, "" + + +def increment_version(version_str: str, bump_type: VersionBumpType) -> str: + """Increment version based on bump type.""" + major, minor, patch, suffix = parse_version(version_str) + + if bump_type == VersionBumpType.MAJOR: + major += 1 + minor = 0 + patch = 0 + elif bump_type == VersionBumpType.MINOR: + minor += 1 + patch = 0 + else: # PATCH + patch += 1 + + # Remove dev suffix for releases + return f"{major}.{minor}.{patch}" + + +def analyze_changelog_fragments() -> VersionBumpType: + """Analyze towncrier changelog fragments to determine version bump.""" + changelog_dir = Path("doc/changelog.d") + if not changelog_dir.exists(): + return VersionBumpType.PATCH + + fragment_files = list(changelog_dir.glob("*.*.md")) + if not fragment_files: + return VersionBumpType.PATCH + + # Analyze fragment types for version bump determination + has_breaking = False + has_feature = False + has_fix = False + + for fragment in fragment_files: + fragment_name = fragment.stem + if any(keyword in fragment_name.lower() for keyword in ["added", "changed"]): + if any( + breaking in fragment.read_text().lower() + for breaking in ["breaking", "breaking change", "incompatible"] + ): + has_breaking = True + else: + has_feature = True + elif "fixed" in fragment_name.lower(): + has_fix = True + + # Determine bump type based on changes + if has_breaking: + return VersionBumpType.MAJOR + elif has_feature: + return VersionBumpType.MINOR + else: + return VersionBumpType.PATCH + + +def analyze_commit_messages() -> VersionBumpType: + """Analyze commit messages since last tag to determine version bump.""" + # Get commits since last tag + success, output = run_git_command(["describe", "--tags", "--abbrev=0"]) + if not success: + # No tags exist, analyze all commits on branch + success, output = run_git_command(["log", "--oneline", "origin/main..HEAD"]) + else: + last_tag = output + success, output = run_git_command(["log", f"{last_tag}..HEAD", "--oneline"]) + + if not success or not output: + return VersionBumpType.PATCH + + commit_messages = output.lower() + + # Check for breaking changes + breaking_keywords = [ + "breaking change", + "breaking:", + "break:", + "major:", + "incompatible", + "remove", + "delete api", + ] + if any(keyword in commit_messages for keyword in breaking_keywords): + return VersionBumpType.MAJOR + + # Check for new features + feature_keywords = [ + "feat:", + "feature:", + "add:", + "new:", + "minor:", + "implement", + "enhance", + "improvement", + ] + if any(keyword in commit_messages for keyword in feature_keywords): + return VersionBumpType.MINOR + + # Default to patch for fixes, docs, etc. + return VersionBumpType.PATCH + + +def analyze_code_changes() -> VersionBumpType: + """Analyze code changes to determine appropriate version bump.""" + # Get changed files + success, output = run_git_command(["diff", "--name-only", "origin/main..HEAD"]) + + if not success: + return VersionBumpType.PATCH + + changed_files = output.split("\n") if output else [] + + # Analyze types of changes + has_api_changes = False + has_new_features = False + has_breaking_changes = False + + for file in changed_files: + file_lower = file.lower() + + # Check for API changes + if any( + pattern in file + for pattern in ["src/ansys/sherlock/core/", "__init__.py", "api", "interface"] + ): + # Get the actual diff to analyze + success, diff_output = run_git_command(["diff", "origin/main..HEAD", "--", file]) + + if success and diff_output: + diff_lower = diff_output.lower() + + # Look for breaking changes + if any( + pattern in diff_lower + for pattern in [ + "-def ", + "-class ", + "removed", + "deprecated", + "raise notimplementederror", + "breaking", + ] + ): + has_breaking_changes = True + + # Look for new features (new functions/classes) + if any( + pattern in diff_lower + for pattern in ["+def ", "+class ", "new feature", "implement"] + ): + has_new_features = True + + # Look for API changes + if "+def " in diff_lower or "+class " in diff_lower: + has_api_changes = True + + # Determine version bump + if has_breaking_changes: + return VersionBumpType.MAJOR + elif has_new_features or has_api_changes: + return VersionBumpType.MINOR + else: + return VersionBumpType.PATCH + + +def determine_version_bump() -> VersionBumpType: + """Determine the appropriate version bump by analyzing multiple sources.""" + log("๐Ÿ” Analyzing changes to determine version bump...", Colors.BLUE) + + # Analyze different sources + changelog_bump = analyze_changelog_fragments() + commit_bump = analyze_commit_messages() + code_bump = analyze_code_changes() + + log(f"๐Ÿ“‹ Changelog analysis suggests: {changelog_bump.value}", Colors.BLUE) + log(f"๐Ÿ’ฌ Commit message analysis suggests: {commit_bump.value}", Colors.BLUE) + log(f"๐Ÿ“ Code changes analysis suggests: {code_bump.value}", Colors.BLUE) + + # Choose the highest priority bump type + bump_priority = {VersionBumpType.MAJOR: 3, VersionBumpType.MINOR: 2, VersionBumpType.PATCH: 1} + + all_bumps = [changelog_bump, commit_bump, code_bump] + final_bump = max(all_bumps, key=lambda x: bump_priority[x]) + + log(f"๐ŸŽฏ Final decision: {final_bump.value} version bump", Colors.GREEN) + return final_bump + + +def get_current_version() -> Optional[str]: + """Get current version from pyproject.toml.""" + try: + with open("pyproject.toml", "r") as f: + data = toml.load(f) + return data.get("project", {}).get("version") + except Exception as e: + log(f"Error reading pyproject.toml: {e}", Colors.RED) + return None + + +def update_version_in_pyproject(new_version: str) -> bool: + """Update version in pyproject.toml file.""" + try: + with open("pyproject.toml", "r") as f: + content = f.read() + + # Replace version using regex to preserve formatting + updated_content = re.sub( + r'^version = "[^"]*"', f'version = "{new_version}"', content, flags=re.MULTILINE + ) + + if updated_content == content: + log("โŒ Could not find version field in pyproject.toml", Colors.RED) + return False + + with open("pyproject.toml", "w") as f: + f.write(updated_content) + + return True + except Exception as e: + log(f"Error updating pyproject.toml: {e}", Colors.RED) + return False + + +def should_skip_version_increment() -> bool: + """Check if version increment should be skipped.""" + current_branch = "" + success, output = run_git_command(["rev-parse", "--abbrev-ref", "HEAD"]) + if success: + current_branch = output + + # Skip on main branch + if current_branch in ["main", "master"]: + log("โ„น๏ธ On main branch, skipping auto-increment", Colors.YELLOW) + return True + + # Skip if no changes since main + success, output = run_git_command(["diff", "--name-only", "origin/main..HEAD"]) + + if not success or not output.strip(): + log("โ„น๏ธ No changes detected, skipping auto-increment", Colors.YELLOW) + return True + + # Check if version was already manually updated + success, output = run_git_command( + ["diff", "origin/main..HEAD", "--name-only", "pyproject.toml"] + ) + + if success and "pyproject.toml" in output: + # Check if version line was changed + success, diff_output = run_git_command(["diff", "origin/main..HEAD", "pyproject.toml"]) + + if success and "version = " in diff_output: + log("โ„น๏ธ Version already manually updated, skipping auto-increment", Colors.YELLOW) + return True + + return False + + +def commit_version_change(old_version: str, new_version: str, bump_type: VersionBumpType): + """Commit the version change.""" + log("๐Ÿ“ Committing version change...", Colors.BLUE) + + # Stage the pyproject.toml file + success, _ = run_git_command(["add", "pyproject.toml"]) + if not success: + log("โŒ Failed to stage pyproject.toml", Colors.RED) + return False + + # Create commit message + commit_msg = f"chore: bump version from {old_version} to {new_version} ({bump_type.value})" + + # Commit the change + success, _ = run_git_command(["commit", "-m", commit_msg]) + if not success: + log("โŒ Failed to commit version change", Colors.RED) + return False + + log(f"โœ… Committed version bump: {old_version} โ†’ {new_version}", Colors.GREEN) + return True + + +def main(): + """Main entry point for automatic version incrementer.""" + log("๐Ÿš€ Automatic Version Incrementer for PySherlock", Colors.BOLD) + + # Check if we're in a git repository + if not Path(".git").exists(): + log("โŒ Not in a git repository", Colors.RED) + return 1 + + # Check if pyproject.toml exists + if not Path("pyproject.toml").exists(): + log("โŒ pyproject.toml not found", Colors.RED) + return 1 + + # Check if we should skip version increment + if should_skip_version_increment(): + return 0 + + # Get current version + current_version = get_current_version() + if not current_version: + log("โŒ Could not read current version", Colors.RED) + return 1 + + log(f"๐Ÿ“ฆ Current version: {current_version}", Colors.BLUE) + + # Determine version bump type + bump_type = determine_version_bump() + + # Calculate new version + new_version = increment_version(current_version, bump_type) + + log(f"๐ŸŽฏ Bumping version: {current_version} โ†’ {new_version} ({bump_type.value})", Colors.GREEN) + + # Confirm with user (optional - can be disabled for full automation) + if "--no-confirm" not in sys.argv: + response = input(f"\nProceed with version bump to {new_version}? (Y/n): ").lower().strip() + if response and response not in ["y", "yes"]: + log("โŒ Version bump cancelled by user", Colors.YELLOW) + return 1 + + # Update version in pyproject.toml + if not update_version_in_pyproject(new_version): + return 1 + + log(f"โœ… Updated pyproject.toml with version {new_version}", Colors.GREEN) + + # Commit the change + if not commit_version_change(current_version, new_version, bump_type): + return 1 + + log("\n๐ŸŽ‰ Version auto-increment completed successfully!", Colors.GREEN) + log(f"๐Ÿ“ฆ New version: {new_version}", Colors.BOLD) + + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/.script/pre_push_version_increment.py b/.script/pre_push_version_increment.py new file mode 100644 index 000000000..a9124cba3 --- /dev/null +++ b/.script/pre_push_version_increment.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python3 +""" +Pre-push hook for automatic version increment + +This script is called as a pre-push hook to automatically increment +the version before pushing changes to the repository. +""" + +from pathlib import Path +import subprocess +import sys + + +def main(): + """Pre-push hook entry point.""" + # Get the directory where this script is located + script_dir = Path(__file__).parent + + # Path to the main auto increment script + auto_increment_script = script_dir / "auto_version_increment.py" + + if not auto_increment_script.exists(): + print("โŒ Auto increment script not found:", auto_increment_script) + return 1 + + # Run the auto increment script with no confirmation (automated) + try: + result = subprocess.run( + [sys.executable, str(auto_increment_script), "--no-confirm"], check=False + ) + + return result.returncode + except Exception as e: + print(f"โŒ Error running auto increment: {e}") + return 1 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/.script/setup_pysherlock_automation.py b/.script/setup_pysherlock_automation.py new file mode 100644 index 000000000..0eb206200 --- /dev/null +++ b/.script/setup_pysherlock_automation.py @@ -0,0 +1,387 @@ +#!/usr/bin/env python3 +""" +Setup automatic version increment for PySherlock + +This script sets up the automation to automatically increment versions +in PySherlock when changes are pushed. +""" + +from pathlib import Path +import shutil +import subprocess +import sys + + +class Colors: + RED = "\033[0;31m" + GREEN = "\033[0;32m" + YELLOW = "\033[1;33m" + BLUE = "\033[0;34m" + BOLD = "\033[1m" + NC = "\033[0m" + + +def log(message: str, color: str = Colors.NC): + """Print colored log message.""" + print(f"{color}{message}{Colors.NC}") + + +def run_command(command: list, check: bool = True) -> tuple[bool, str]: + """Run a command and return success status and output.""" + try: + result = subprocess.run(command, capture_output=True, text=True, check=check) + return True, result.stdout.strip() + except subprocess.CalledProcessError as e: + return False, e.stderr.strip() if e.stderr else str(e) + + +def check_prerequisites(): + """Check if all prerequisites are installed.""" + log("๐Ÿ” Checking prerequisites...", Colors.BLUE) + + # Check if we're in PySherlock repository + if not Path("pyproject.toml").exists(): + log("โŒ pyproject.toml not found. Are you in the PySherlock repository?", Colors.RED) + return False + + # Check if it's actually PySherlock + try: + with open("pyproject.toml", "r") as f: + content = f.read() + if "ansys-sherlock-core" not in content and "pysherlock" not in content.lower(): + log("โŒ This doesn't appear to be the PySherlock repository", Colors.RED) + return False + except Exception as e: + log(f"โŒ Error reading pyproject.toml: {e}", Colors.RED) + return False + + # Check git + success, _ = run_command(["git", "--version"]) + if not success: + log("โŒ Git is not installed or not accessible", Colors.RED) + return False + + # Check Python + success, _ = run_command([sys.executable, "--version"]) + if not success: + log("โŒ Python is not accessible", Colors.RED) + return False + + log("โœ… Prerequisites check passed", Colors.GREEN) + return True + + +def install_dependencies(): + """Install required dependencies.""" + log("๐Ÿ“ฆ Installing dependencies...", Colors.BLUE) + + dependencies = ["toml", "pre-commit"] + + for dep in dependencies: + log(f"Installing {dep}...", Colors.BLUE) + success, output = run_command([sys.executable, "-m", "pip", "install", dep]) + + if not success: + log(f"โŒ Failed to install {dep}: {output}", Colors.RED) + return False + + log(f"โœ… {dep} installed successfully", Colors.GREEN) + + return True + + +def setup_automation_scripts(): + """Copy automation scripts to PySherlock repository.""" + log("๐Ÿ“„ Setting up automation scripts...", Colors.BLUE) + + # Create automation directory in PySherlock + automation_dir = Path(".pysherlock-automation") + automation_dir.mkdir(exist_ok=True) + + # Get current script directory + current_dir = Path(__file__).parent + + # Scripts to copy + scripts_to_copy = ["auto_version_increment.py", "pre_push_version_increment.py"] + + for script in scripts_to_copy: + source = current_dir / script + dest = automation_dir / script + + if not source.exists(): + log(f"โŒ Source script not found: {source}", Colors.RED) + return False + + try: + shutil.copy2(source, dest) + # Make executable + dest.chmod(0o755) + log(f"โœ… Copied {script}", Colors.GREEN) + except Exception as e: + log(f"โŒ Failed to copy {script}: {e}", Colors.RED) + return False + + log("โœ… Automation scripts set up successfully", Colors.GREEN) + return True + + +def update_precommit_config(): + """Update or create pre-commit configuration.""" + log("โš™๏ธ Updating pre-commit configuration...", Colors.BLUE) + + precommit_config = Path(".pre-commit-config.yaml") + current_dir = Path(__file__).parent + template_config = current_dir / "pysherlock_precommit_config.yaml" + + if not template_config.exists(): + log("โŒ Template pre-commit config not found", Colors.RED) + return False + + # Backup existing config if it exists + if precommit_config.exists(): + backup_path = Path(".pre-commit-config.yaml.backup") + shutil.copy2(precommit_config, backup_path) + log(f"โœ… Backed up existing config to {backup_path}", Colors.YELLOW) + + # Read template and update paths + try: + with open(template_config, "r") as f: + config_content = f.read() + + # Update the entry path to use the automation directory + config_content = config_content.replace( + "entry: python pre_push_version_increment.py", + "entry: python .pysherlock-automation/pre_push_version_increment.py", + ) + + with open(precommit_config, "w") as f: + f.write(config_content) + + log("โœ… Pre-commit configuration updated", Colors.GREEN) + return True + + except Exception as e: + log(f"โŒ Failed to update pre-commit config: {e}", Colors.RED) + return False + + +def install_precommit_hooks(): + """Install pre-commit hooks.""" + log("๐Ÿช Installing pre-commit hooks...", Colors.BLUE) + + # Install pre-commit hooks + success, output = run_command(["pre-commit", "install"]) + if not success: + log(f"โŒ Failed to install pre-commit hooks: {output}", Colors.RED) + return False + + # Install pre-push hooks specifically + success, output = run_command(["pre-commit", "install", "--hook-type", "pre-push"]) + if not success: + log(f"โŒ Failed to install pre-push hooks: {output}", Colors.RED) + return False + + log("โœ… Pre-commit hooks installed successfully", Colors.GREEN) + return True + + +def test_setup(): + """Test the setup by running a dry-run.""" + log("๐Ÿงช Testing setup...", Colors.BLUE) + + # Test the auto increment script + script_path = Path(".pysherlock-automation/auto_version_increment.py") + if not script_path.exists(): + log("โŒ Auto increment script not found", Colors.RED) + return False + + # Run with --help to test if it works + success, output = run_command([sys.executable, str(script_path), "--help"], check=False) + + if success or "usage:" in output.lower() or "automatic version" in output.lower(): + log("โœ… Auto increment script is working", Colors.GREEN) + else: + log("โš ๏ธ Auto increment script test inconclusive", Colors.YELLOW) + + # Test pre-commit + success, output = run_command(["pre-commit", "--version"]) + if not success: + log("โŒ Pre-commit test failed", Colors.RED) + return False + + log("โœ… Setup test completed", Colors.GREEN) + return True + + +def create_usage_instructions(): + """Create usage instructions file.""" + log("๐Ÿ“š Creating usage instructions...", Colors.BLUE) + + instructions = """# PySherlock Automatic Version Increment + +This automation has been set up to automatically increment the version in `pyproject.toml` +when you push changes to the repository. + +## How it works + +1. **Pre-push Hook**: When you run `git push`, the pre-push hook automatically analyzes your changes +2. **Smart Analysis**: The system looks at: + - Towncrier changelog fragments in `doc/changelog.d/` + - Git commit messages + - Code changes in the repository +3. **Version Bump**: Based on the analysis, it determines whether to do a: + - **PATCH** bump (x.y.Z) - for bug fixes, docs, small changes + - **MINOR** bump (x.Y.0) - for new features, enhancements + - **MAJOR** bump (X.0.0) - for breaking changes, API changes +4. **Automatic Update**: Updates `pyproject.toml` and commits the change + +## Usage + +### Normal Development Flow +```bash +# Make your changes +git add . +git commit -m "fix: resolve issue with connection timeout" + +# Push your changes - version will be auto-incremented +git push origin your-branch +``` + +### Manual Version Control +If you want to manually control the version increment, you can run: + +```bash +# Run manually with confirmation prompt +python .pysherlock-automation/auto_version_increment.py + +# Run without confirmation (automated) +python .pysherlock-automation/auto_version_increment.py --no-confirm +``` + +### Changelog Integration +The system works best with towncrier changelog fragments: + +```bash +# Create changelog fragment for a bug fix +echo "Fixed connection timeout issue." > doc/changelog.d/123.fixed.md + +# Create changelog fragment for a new feature +echo "Added new authentication method." > doc/changelog.d/124.added.md + +# Commit and push - version will be incremented appropriately +git add . && git commit -m "fix: connection timeout" && git push +``` + +## Configuration + +### Version Bump Rules +- **MAJOR** (breaking changes): + - Breaking changes in commit messages + - API changes that remove/modify existing functions + - Changelog fragments indicating breaking changes + +- **MINOR** (new features): + - New features in commit messages (`feat:`, `feature:`, `add:`) + - New functions/classes added to API + - Changelog fragments with new features + +- **PATCH** (bug fixes): + - Bug fixes, documentation updates, small improvements + - Default for changes that don't match MAJOR/MINOR criteria + +### Skipping Auto-increment +The system automatically skips version increment when: +- You're on the main branch +- No changes detected since main branch +- Version was already manually updated in the PR + +### Troubleshooting + +If the auto-increment fails: +1. Check that all dependencies are installed: `pip install toml pre-commit` +2. Ensure you're in the PySherlock repository root +3. Check that `pyproject.toml` exists and is readable +4. Run manually to see detailed error messages + +### Disabling +To temporarily disable auto-increment: +```bash +# Skip pre-push hooks for one push +git push --no-verify + +# Or remove the hook temporarily +pre-commit uninstall --hook-type pre-push +``` + +To re-enable: +```bash +pre-commit install --hook-type pre-push +``` + +## Files Created +- `.pysherlock-automation/` - Contains automation scripts +- `.pre-commit-config.yaml` - Updated with version increment hook +- `PYSHERLOCK_VERSION_AUTOMATION.md` - This documentation + +## Support +If you encounter issues with the version automation, check: +1. The automation scripts in `.pysherlock-automation/` +2. Pre-commit hook configuration in `.pre-commit-config.yaml` +3. Run the automation manually for debugging +""" + + try: + with open("PYSHERLOCK_VERSION_AUTOMATION.md", "w") as f: + f.write(instructions) + log("โœ… Usage instructions created: PYSHERLOCK_VERSION_AUTOMATION.md", Colors.GREEN) + return True + except Exception as e: + log(f"โŒ Failed to create instructions: {e}", Colors.RED) + return False + + +def main(): + """Main setup function.""" + log("๐Ÿš€ PySherlock Automatic Version Increment Setup", Colors.BOLD) + log("=" * 50, Colors.BOLD) + + # Check prerequisites + if not check_prerequisites(): + return 1 + + # Install dependencies + if not install_dependencies(): + return 1 + + # Setup automation scripts + if not setup_automation_scripts(): + return 1 + + # Update pre-commit configuration + if not update_precommit_config(): + return 1 + + # Install pre-commit hooks + if not install_precommit_hooks(): + return 1 + + # Test setup + if not test_setup(): + log("โš ๏ธ Setup completed but tests failed. Please check manually.", Colors.YELLOW) + + # Create usage instructions + create_usage_instructions() + + log("\n" + "=" * 50, Colors.BOLD) + log("๐ŸŽ‰ Setup completed successfully!", Colors.GREEN) + log("\nNext steps:", Colors.BOLD) + log("1. Review PYSHERLOCK_VERSION_AUTOMATION.md for usage instructions", Colors.BLUE) + log("2. Test the setup by making a small change and pushing", Colors.BLUE) + log("3. The version will be automatically incremented on git push", Colors.BLUE) + log("\nHappy coding! ๐Ÿโœจ", Colors.GREEN) + + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/.script/test_version_automation.py b/.script/test_version_automation.py new file mode 100644 index 000000000..92ba194ac --- /dev/null +++ b/.script/test_version_automation.py @@ -0,0 +1,333 @@ +#!/usr/bin/env python3 +""" +Test script for PySherlock automatic version increment + +This script tests the version increment functionality in different scenarios. +""" + +from pathlib import Path +import shutil +import subprocess +import sys +import tempfile + +import toml + + +class Colors: + RED = "\033[0;31m" + GREEN = "\033[0;32m" + YELLOW = "\033[1;33m" + BLUE = "\033[0;34m" + BOLD = "\033[1m" + NC = "\033[0m" + + +def log(message: str, color: str = Colors.NC): + """Print colored log message.""" + print(f"{color}{message}{Colors.NC}") + + +def run_command(command: list, cwd: Path = None) -> tuple[bool, str]: + """Run a command and return success status and output.""" + try: + result = subprocess.run(command, capture_output=True, text=True, check=True, cwd=cwd) + return True, result.stdout.strip() + except subprocess.CalledProcessError as e: + return False, e.stderr.strip() if e.stderr else str(e) + + +def create_test_pyproject_toml(test_dir: Path, version: str = "0.12.dev0"): + """Create a test pyproject.toml file.""" + pyproject_content = f"""[build-system] +requires = ["flit_core >=3.2,<4"] +build-backend = "flit_core.buildapi" + +[project] +name = "ansys-sherlock-core" +version = "{version}" +description = "A Python wrapper for Ansys Sherlock" +readme = "README.rst" +requires-python = ">=3.10,<4" +license = {{file = "LICENSE"}} + +[project.urls] +Source = "https://github.com/ansys/pysherlock" +Tracker = "https://github.com/ansys/pysherlock/issues" +""" + + pyproject_file = test_dir / "pyproject.toml" + with open(pyproject_file, "w") as f: + f.write(pyproject_content) + + return pyproject_file + + +def create_test_git_repo(test_dir: Path): + """Initialize a test git repository.""" + commands = [ + ["git", "init"], + ["git", "config", "user.email", "test@example.com"], + ["git", "config", "user.name", "Test User"], + ["git", "add", "."], + ["git", "commit", "-m", "Initial commit"], + ] + + for cmd in commands: + success, output = run_command(cmd, test_dir) + if not success: + log(f"Failed to run {' '.join(cmd)}: {output}", Colors.RED) + return False + + return True + + +def test_version_parsing(): + """Test version parsing functionality.""" + log("๐Ÿงช Testing version parsing...", Colors.BLUE) + + # Import the auto increment module + current_dir = Path(__file__).parent + auto_increment_script = current_dir / "auto_version_increment.py" + + if not auto_increment_script.exists(): + log("โŒ Auto increment script not found", Colors.RED) + return False + + # Test version parsing by running the script with a test + test_cases = [ + ("0.12.dev0", "patch", "0.12.1"), + ("0.12.1", "minor", "0.13.0"), + ("0.12.1", "major", "1.0.0"), + ("1.2.3", "patch", "1.2.4"), + ] + + # Create a simple test + test_code = """ +import sys +sys.path.append(".") +from auto_version_increment import parse_version, increment_version, VersionBumpType + +test_cases = [ + ("0.12.dev0", VersionBumpType.PATCH, "0.12.1"), + ("0.12.1", VersionBumpType.MINOR, "0.13.0"), + ("0.12.1", VersionBumpType.MAJOR, "1.0.0"), + ("1.2.3", VersionBumpType.PATCH, "1.2.4"), +] + +all_passed = True +for version, bump_type, expected in test_cases: + result = increment_version(version, bump_type) + if result != expected: + print(f"FAIL: {version} + {bump_type.value} = {result}, expected {expected}") + all_passed = False + else: + print(f"PASS: {version} + {bump_type.value} = {result}") + +sys.exit(0 if all_passed else 1) +""" + + with tempfile.NamedTemporaryFile(mode="w", suffix=".py", delete=False) as f: + f.write(test_code) + test_file = f.name + + try: + success, output = run_command([sys.executable, test_file], current_dir) + if success: + log("โœ… Version parsing tests passed", Colors.GREEN) + return True + else: + log(f"โŒ Version parsing tests failed: {output}", Colors.RED) + return False + finally: + Path(test_file).unlink(missing_ok=True) + + +def test_version_increment_in_isolated_repo(): + """Test version increment in an isolated test repository.""" + log("๐Ÿงช Testing version increment in isolated repository...", Colors.BLUE) + + with tempfile.TemporaryDirectory() as temp_dir: + test_dir = Path(temp_dir) + + # Create test pyproject.toml + create_test_pyproject_toml(test_dir, "0.12.dev0") + + # Create test git repo + if not create_test_git_repo(test_dir): + return False + + # Copy auto increment script + current_dir = Path(__file__).parent + auto_increment_script = current_dir / "auto_version_increment.py" + shutil.copy2(auto_increment_script, test_dir / "auto_version_increment.py") + shutil.copy2( + current_dir / "pre_push_version_increment.py", + test_dir / "pre_push_version_increment.py", + ) + + # Create some changelog fragments + changelog_dir = test_dir / "doc" / "changelog.d" + changelog_dir.mkdir(parents=True) + + # Add a bug fix fragment + with open(changelog_dir / "123.fixed.md", "w") as f: + f.write("Fixed connection timeout issue.") + + # Commit the changelog + run_command(["git", "add", "."], test_dir) + run_command(["git", "commit", "-m", "Add changelog fragment"], test_dir) + + # Run the auto increment script + success, output = run_command( + [sys.executable, "auto_version_increment.py", "--no-confirm"], test_dir + ) + + if not success: + log(f"โŒ Auto increment failed: {output}", Colors.RED) + return False + + # Check if version was updated + try: + with open(test_dir / "pyproject.toml", "r") as f: + data = toml.load(f) + new_version = data["project"]["version"] + + if new_version == "0.12.1": + log(f"โœ… Version correctly incremented: 0.12.dev0 โ†’ {new_version}", Colors.GREEN) + return True + else: + log( + f"โŒ Version increment incorrect: expected 0.12.1, got {new_version}", + Colors.RED, + ) + return False + + except Exception as e: + log(f"โŒ Failed to read updated version: {e}", Colors.RED) + return False + + +def test_bump_type_detection(): + """Test bump type detection based on commit messages.""" + log("๐Ÿงช Testing bump type detection...", Colors.BLUE) + + test_scenarios = [ + { + "commit_msg": "fix: resolve connection timeout", + "expected_bump": "patch", + "description": "Bug fix should trigger patch bump", + }, + { + "commit_msg": "feat: add new authentication method", + "expected_bump": "minor", + "description": "New feature should trigger minor bump", + }, + { + "commit_msg": "BREAKING CHANGE: remove deprecated API", + "expected_bump": "major", + "description": "Breaking change should trigger major bump", + }, + ] + + all_passed = True + + for scenario in test_scenarios: + # This is a simplified test - in practice we'd need to create commits + # and test the actual commit message analysis + log(f" ๐Ÿ“ {scenario['description']}", Colors.BLUE) + + # Check if commit message contains expected keywords + commit_msg = scenario["commit_msg"].lower() + expected_bump = scenario["expected_bump"] + + if expected_bump == "major" and any( + keyword in commit_msg for keyword in ["breaking change", "breaking:", "major:"] + ): + log(f" โœ… Correctly detected {expected_bump} bump", Colors.GREEN) + elif expected_bump == "minor" and any( + keyword in commit_msg for keyword in ["feat:", "feature:", "add:", "new:"] + ): + log(f" โœ… Correctly detected {expected_bump} bump", Colors.GREEN) + elif expected_bump == "patch": + log(f" โœ… Correctly detected {expected_bump} bump (default)", Colors.GREEN) + else: + log(f" โŒ Failed to detect {expected_bump} bump", Colors.RED) + all_passed = False + + return all_passed + + +def test_script_integration(): + """Test that scripts can be imported and run.""" + log("๐Ÿงช Testing script integration...", Colors.BLUE) + + current_dir = Path(__file__).parent + scripts = [ + "auto_version_increment.py", + "pre_push_version_increment.py", + "setup_pysherlock_automation.py", + ] + + all_passed = True + + for script in scripts: + script_path = current_dir / script + if not script_path.exists(): + log(f"โŒ Script not found: {script}", Colors.RED) + all_passed = False + continue + + # Test that script can be executed (at least imported/parsed) + success, output = run_command([sys.executable, "-m", "py_compile", str(script_path)]) + + if success: + log(f"โœ… {script} syntax is valid", Colors.GREEN) + else: + log(f"โŒ {script} has syntax errors: {output}", Colors.RED) + all_passed = False + + return all_passed + + +def main(): + """Run all tests.""" + log("๐Ÿš€ Testing PySherlock Automatic Version Increment", Colors.BOLD) + log("=" * 60, Colors.BOLD) + + tests = [ + ("Script Integration", test_script_integration), + ("Version Parsing", test_version_parsing), + ("Bump Type Detection", test_bump_type_detection), + ("Version Increment (Isolated)", test_version_increment_in_isolated_repo), + ] + + passed = 0 + failed = 0 + + for test_name, test_func in tests: + log(f"\n๐Ÿ” Running test: {test_name}", Colors.BOLD) + try: + if test_func(): + passed += 1 + log(f"โœ… {test_name} PASSED", Colors.GREEN) + else: + failed += 1 + log(f"โŒ {test_name} FAILED", Colors.RED) + except Exception as e: + failed += 1 + log(f"โŒ {test_name} ERROR: {e}", Colors.RED) + + log("\n" + "=" * 60, Colors.BOLD) + log(f"๐Ÿ“Š Test Results: {passed} passed, {failed} failed", Colors.BOLD) + + if failed == 0: + log("๐ŸŽ‰ All tests passed!", Colors.GREEN) + return 0 + else: + log("โŒ Some tests failed. Check the output above.", Colors.RED) + return 1 + + +if __name__ == "__main__": + sys.exit(main()) From 0d2bf31a4a9b5f0aac1bc409a8c217555b4c548b Mon Sep 17 00:00:00 2001 From: skola Date: Mon, 6 Oct 2025 15:45:58 -0400 Subject: [PATCH 02/30] feat: add test feature for version increment --- doc/changelog.d/700.added.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/changelog.d/700.added.md diff --git a/doc/changelog.d/700.added.md b/doc/changelog.d/700.added.md new file mode 100644 index 000000000..b2c83e734 --- /dev/null +++ b/doc/changelog.d/700.added.md @@ -0,0 +1 @@ +Added new test feature for version increment testing From e31c2d8691a4c9f0f3a3400ed3d05ca65b1eae1d Mon Sep 17 00:00:00 2001 From: skola Date: Mon, 6 Oct 2025 15:46:38 -0400 Subject: [PATCH 03/30] chore: bump version from 0.12.dev0 to 1.0.0 (major) --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index a74bf772c..3c190efce 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "flit_core.buildapi" [project] name = "ansys-sherlock-core" -version = "0.12.dev0" +version = "1.0.0" description = "A python wrapper for Ansys Sherlock" readme = "README.rst" requires-python = ">=3.10,<4" From 245844d4020efb5a2fb88a25d6da93afa0d8e17b Mon Sep 17 00:00:00 2001 From: skola Date: Mon, 6 Oct 2025 15:50:37 -0400 Subject: [PATCH 04/30] fix: minor bug fix for testing version increment --- doc/changelog.d/701.bugfix.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/changelog.d/701.bugfix.md diff --git a/doc/changelog.d/701.bugfix.md b/doc/changelog.d/701.bugfix.md new file mode 100644 index 000000000..858705b12 --- /dev/null +++ b/doc/changelog.d/701.bugfix.md @@ -0,0 +1 @@ +Fixed a minor issue in version increment testing From f38dcf14140cb826a8c214801bb817c40728ca16 Mon Sep 17 00:00:00 2001 From: skola Date: Mon, 6 Oct 2025 15:52:50 -0400 Subject: [PATCH 05/30] feat: new feature for version increment test --- doc/changelog.d/702.feature.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/changelog.d/702.feature.md diff --git a/doc/changelog.d/702.feature.md b/doc/changelog.d/702.feature.md new file mode 100644 index 000000000..a6d68920c --- /dev/null +++ b/doc/changelog.d/702.feature.md @@ -0,0 +1 @@ +Added new feature for testing minor version increment From 0d9e3e66c7a3fe2c52cddcfbf6870826294aabf8 Mon Sep 17 00:00:00 2001 From: skola Date: Mon, 6 Oct 2025 15:53:56 -0400 Subject: [PATCH 06/30] fix: update pre-commit hook to use python instead of python3 --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f0cb01506..6e4bce236 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -72,7 +72,7 @@ repos: hooks: - id: auto-version-increment name: Auto Version Increment - entry: python3 pre_push_version_increment.py + entry: python pre_push_version_increment.py language: system stages: [pre-push] always_run: true From 9e734a2b4715bc0f1ce36aaed3cbdb0e0909499b Mon Sep 17 00:00:00 2001 From: skola Date: Mon, 6 Oct 2025 15:54:25 -0400 Subject: [PATCH 07/30] fix: update script path in pre-commit hook --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6e4bce236..b97d9554f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -72,7 +72,7 @@ repos: hooks: - id: auto-version-increment name: Auto Version Increment - entry: python pre_push_version_increment.py + entry: python .script/pre_push_version_increment.py language: system stages: [pre-push] always_run: true From d49d5fd5a76c36e3460c6582c05d12dccecc650a Mon Sep 17 00:00:00 2001 From: skola Date: Mon, 6 Oct 2025 15:54:59 -0400 Subject: [PATCH 08/30] fix: set UTF-8 encoding for version increment script --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b97d9554f..ae070fc3c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -72,7 +72,7 @@ repos: hooks: - id: auto-version-increment name: Auto Version Increment - entry: python .script/pre_push_version_increment.py + entry: cmd /c "chcp 65001 > NUL && python .script/pre_push_version_increment.py" language: system stages: [pre-push] always_run: true From b52ba144cc4537e3858e23f8d1373f74c46792bb Mon Sep 17 00:00:00 2001 From: skola Date: Mon, 6 Oct 2025 16:15:21 -0400 Subject: [PATCH 09/30] feat: add test feature for version increment --- doc/changelog.d/803.feature.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/changelog.d/803.feature.md diff --git a/doc/changelog.d/803.feature.md b/doc/changelog.d/803.feature.md new file mode 100644 index 000000000..4b7c2981e --- /dev/null +++ b/doc/changelog.d/803.feature.md @@ -0,0 +1 @@ +Added new feature for version increment testing in current branch From ceafb6e41c8fd7c6958a950f00f96b42bfb3ff1e Mon Sep 17 00:00:00 2001 From: skola Date: Mon, 6 Oct 2025 16:16:39 -0400 Subject: [PATCH 10/30] fix: allow version increment in test branch --- .script/auto_version_increment.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.script/auto_version_increment.py b/.script/auto_version_increment.py index fe2b8b20c..6abbdee13 100644 --- a/.script/auto_version_increment.py +++ b/.script/auto_version_increment.py @@ -314,6 +314,10 @@ def should_skip_version_increment() -> bool: log("โ„น๏ธ No changes detected, skipping auto-increment", Colors.YELLOW) return True + # Always allow version increment in test branches + if "optimization/version-check" in current_branch: + return False + # Check if version was already manually updated success, output = run_git_command( ["diff", "origin/main..HEAD", "--name-only", "pyproject.toml"] From 1a4ce33b4b9886c4ea0bbaff7d93cd63e4d12a74 Mon Sep 17 00:00:00 2001 From: skola Date: Mon, 6 Oct 2025 16:16:53 -0400 Subject: [PATCH 11/30] chore: bump version from 1.0.0 to 2.0.0 (major) --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 3c190efce..a02e3fc3d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "flit_core.buildapi" [project] name = "ansys-sherlock-core" -version = "1.0.0" +version = "2.0.0" description = "A python wrapper for Ansys Sherlock" readme = "README.rst" requires-python = ">=3.10,<4" From ef1c713ad5028a31e9e5fdebb851d1deeca24a55 Mon Sep 17 00:00:00 2001 From: skola Date: Mon, 6 Oct 2025 16:17:24 -0400 Subject: [PATCH 12/30] feat: add another test feature --- doc/changelog.d/804.feature.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/changelog.d/804.feature.md diff --git a/doc/changelog.d/804.feature.md b/doc/changelog.d/804.feature.md new file mode 100644 index 000000000..4baf0bfd2 --- /dev/null +++ b/doc/changelog.d/804.feature.md @@ -0,0 +1 @@ +Added another feature to test version increment From 7b659dfaa8df5113d5c6f619bbdce97f6b8d20ad Mon Sep 17 00:00:00 2001 From: skola Date: Mon, 6 Oct 2025 16:17:30 -0400 Subject: [PATCH 13/30] chore: bump version from 2.0.0 to 3.0.0 (major) --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index a02e3fc3d..0ba1e8340 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "flit_core.buildapi" [project] name = "ansys-sherlock-core" -version = "2.0.0" +version = "3.0.0" description = "A python wrapper for Ansys Sherlock" readme = "README.rst" requires-python = ">=3.10,<4" From dc4bea64ee33761b0fe6280718a4fe376fc1f190 Mon Sep 17 00:00:00 2001 From: skola Date: Mon, 6 Oct 2025 16:18:39 -0400 Subject: [PATCH 14/30] test: reset version for increment testing --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 0ba1e8340..3c190efce 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "flit_core.buildapi" [project] name = "ansys-sherlock-core" -version = "3.0.0" +version = "1.0.0" description = "A python wrapper for Ansys Sherlock" readme = "README.rst" requires-python = ">=3.10,<4" From bcc3d49d319946e770a62e80a644775d55c5b0aa Mon Sep 17 00:00:00 2001 From: skola Date: Mon, 6 Oct 2025 16:18:45 -0400 Subject: [PATCH 15/30] chore: bump version from 1.0.0 to 2.0.0 (major) --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 3c190efce..a02e3fc3d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "flit_core.buildapi" [project] name = "ansys-sherlock-core" -version = "1.0.0" +version = "2.0.0" description = "A python wrapper for Ansys Sherlock" readme = "README.rst" requires-python = ">=3.10,<4" From ea9cd71a4ef65173ca12f6fd83c534b4c8c12f7d Mon Sep 17 00:00:00 2001 From: skola Date: Mon, 6 Oct 2025 16:19:22 -0400 Subject: [PATCH 16/30] fix: patch version test - error handling --- doc/changelog.d/805.fixed.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/changelog.d/805.fixed.md diff --git a/doc/changelog.d/805.fixed.md b/doc/changelog.d/805.fixed.md new file mode 100644 index 000000000..8ae75bada --- /dev/null +++ b/doc/changelog.d/805.fixed.md @@ -0,0 +1 @@ +Fixed a minor bug in error handling From cf0bbde6ba1d4b887460d3a3eec73939511d09a9 Mon Sep 17 00:00:00 2001 From: skola Date: Mon, 6 Oct 2025 16:19:28 -0400 Subject: [PATCH 17/30] chore: bump version from 2.0.0 to 3.0.0 (major) --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index a02e3fc3d..0ba1e8340 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "flit_core.buildapi" [project] name = "ansys-sherlock-core" -version = "2.0.0" +version = "3.0.0" description = "A python wrapper for Ansys Sherlock" readme = "README.rst" requires-python = ">=3.10,<4" From 762efc2ab5c0a633bb4ca9dd71c24e7fb88f1f46 Mon Sep 17 00:00:00 2001 From: skola Date: Mon, 6 Oct 2025 16:20:14 -0400 Subject: [PATCH 18/30] feat: minor version test - new feature --- doc/changelog.d/806.added.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/changelog.d/806.added.md diff --git a/doc/changelog.d/806.added.md b/doc/changelog.d/806.added.md new file mode 100644 index 000000000..b3b4f83b9 --- /dev/null +++ b/doc/changelog.d/806.added.md @@ -0,0 +1 @@ +Added new testing feature for version increment From 3a3700aed683e7bd42604bd7e8efcd41e10ffe92 Mon Sep 17 00:00:00 2001 From: skola Date: Mon, 6 Oct 2025 16:20:20 -0400 Subject: [PATCH 19/30] chore: bump version from 3.0.0 to 4.0.0 (major) --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 0ba1e8340..ebe6aba4a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "flit_core.buildapi" [project] name = "ansys-sherlock-core" -version = "3.0.0" +version = "4.0.0" description = "A python wrapper for Ansys Sherlock" readme = "README.rst" requires-python = ">=3.10,<4" From 16817daf95284c6ed5f7b5442a962fcfc47d01fb Mon Sep 17 00:00:00 2001 From: skola Date: Mon, 6 Oct 2025 16:20:54 -0400 Subject: [PATCH 20/30] BREAKING CHANGE: major version test - remove deprecated APIs --- doc/changelog.d/807.breaking.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/changelog.d/807.breaking.md diff --git a/doc/changelog.d/807.breaking.md b/doc/changelog.d/807.breaking.md new file mode 100644 index 000000000..70e90d1e3 --- /dev/null +++ b/doc/changelog.d/807.breaking.md @@ -0,0 +1 @@ +Breaking change: Removed deprecated API methods From 030f17153eb071c2f3e823c9b8afc0a0ca531d6e Mon Sep 17 00:00:00 2001 From: skola Date: Mon, 6 Oct 2025 16:21:01 -0400 Subject: [PATCH 21/30] chore: bump version from 4.0.0 to 5.0.0 (major) --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index ebe6aba4a..04bdb75bc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "flit_core.buildapi" [project] name = "ansys-sherlock-core" -version = "4.0.0" +version = "5.0.0" description = "A python wrapper for Ansys Sherlock" readme = "README.rst" requires-python = ">=3.10,<4" From c763e1ffd0665d93d4b19b08ee27d7d09c92c799 Mon Sep 17 00:00:00 2001 From: skola Date: Mon, 6 Oct 2025 16:29:15 -0400 Subject: [PATCH 22/30] fix: error handling in connection manager --- doc/changelog.d/800.fixed.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 doc/changelog.d/800.fixed.md diff --git a/doc/changelog.d/800.fixed.md b/doc/changelog.d/800.fixed.md new file mode 100644 index 000000000..e69de29bb From 1b3c631227037ee898e48e0d0bf87d8937f0151f Mon Sep 17 00:00:00 2001 From: skola Date: Mon, 6 Oct 2025 16:29:50 -0400 Subject: [PATCH 23/30] feat: new API for advanced data analysis --- doc/changelog.d/801.added.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/changelog.d/801.added.md diff --git a/doc/changelog.d/801.added.md b/doc/changelog.d/801.added.md new file mode 100644 index 000000000..de06e642a --- /dev/null +++ b/doc/changelog.d/801.added.md @@ -0,0 +1 @@ +Added new API for advanced data analysis From bf4d133663e53b0be288912f01471299a74bc6c2 Mon Sep 17 00:00:00 2001 From: skola Date: Mon, 6 Oct 2025 16:30:14 -0400 Subject: [PATCH 24/30] BREAKING CHANGE: remove deprecated auth methods --- doc/changelog.d/802.changed.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/changelog.d/802.changed.md diff --git a/doc/changelog.d/802.changed.md b/doc/changelog.d/802.changed.md new file mode 100644 index 000000000..9c77cbbc3 --- /dev/null +++ b/doc/changelog.d/802.changed.md @@ -0,0 +1 @@ +BREAKING CHANGE: Removed deprecated authentication methods. Users must migrate to the new authentication system. From 1b8b6c692fd6a3f9fa25d71cef9a864f909cce5c Mon Sep 17 00:00:00 2001 From: skola Date: Mon, 6 Oct 2025 16:30:32 -0400 Subject: [PATCH 25/30] chore: bump version from 5.0.0 to 6.0.0 (major) --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 04bdb75bc..0b0d14e9d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "flit_core.buildapi" [project] name = "ansys-sherlock-core" -version = "5.0.0" +version = "6.0.0" description = "A python wrapper for Ansys Sherlock" readme = "README.rst" requires-python = ">=3.10,<4" From bd38b20a6b69a5592302ae43d3d60c938a5bd609 Mon Sep 17 00:00:00 2001 From: skola Date: Mon, 6 Oct 2025 16:41:09 -0400 Subject: [PATCH 26/30] chore: update pre-commit hooks and remove obsolete changelog entries --- .pre-commit-config.yaml | 14 +++++++------- doc/changelog.d/700.added.md | 1 - doc/changelog.d/701.bugfix.md | 1 - doc/changelog.d/702.feature.md | 1 - doc/changelog.d/800.fixed.md | 0 doc/changelog.d/801.added.md | 1 - doc/changelog.d/802.changed.md | 1 - doc/changelog.d/803.feature.md | 1 - doc/changelog.d/804.feature.md | 1 - doc/changelog.d/805.fixed.md | 1 - doc/changelog.d/806.added.md | 1 - doc/changelog.d/807.breaking.md | 1 - pyproject.toml | 2 +- 13 files changed, 8 insertions(+), 18 deletions(-) delete mode 100644 doc/changelog.d/700.added.md delete mode 100644 doc/changelog.d/701.bugfix.md delete mode 100644 doc/changelog.d/702.feature.md delete mode 100644 doc/changelog.d/800.fixed.md delete mode 100644 doc/changelog.d/801.added.md delete mode 100644 doc/changelog.d/802.changed.md delete mode 100644 doc/changelog.d/803.feature.md delete mode 100644 doc/changelog.d/804.feature.md delete mode 100644 doc/changelog.d/805.fixed.md delete mode 100644 doc/changelog.d/806.added.md delete mode 100644 doc/changelog.d/807.breaking.md diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ae070fc3c..5d5a88eb7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -59,13 +59,13 @@ repos: hooks: - id: check-github-workflows -# Temporarily disabled due to Windows symlink permissions -# - repo: https://github.com/ansys/pre-commit-hooks -# rev: v0.5.2 -# hooks: -# - id: add-license-headers -# args: -# - --start_year=2021 +# Ansys pre-commit hooks for license headers and version management +- repo: https://github.com/ansys/pre-commit-hooks + rev: v0.5.2 + hooks: + - id: add-license-headers + args: + - --start_year=2021 # Automatic version increment on pre-push - repo: local diff --git a/doc/changelog.d/700.added.md b/doc/changelog.d/700.added.md deleted file mode 100644 index b2c83e734..000000000 --- a/doc/changelog.d/700.added.md +++ /dev/null @@ -1 +0,0 @@ -Added new test feature for version increment testing diff --git a/doc/changelog.d/701.bugfix.md b/doc/changelog.d/701.bugfix.md deleted file mode 100644 index 858705b12..000000000 --- a/doc/changelog.d/701.bugfix.md +++ /dev/null @@ -1 +0,0 @@ -Fixed a minor issue in version increment testing diff --git a/doc/changelog.d/702.feature.md b/doc/changelog.d/702.feature.md deleted file mode 100644 index a6d68920c..000000000 --- a/doc/changelog.d/702.feature.md +++ /dev/null @@ -1 +0,0 @@ -Added new feature for testing minor version increment diff --git a/doc/changelog.d/800.fixed.md b/doc/changelog.d/800.fixed.md deleted file mode 100644 index e69de29bb..000000000 diff --git a/doc/changelog.d/801.added.md b/doc/changelog.d/801.added.md deleted file mode 100644 index de06e642a..000000000 --- a/doc/changelog.d/801.added.md +++ /dev/null @@ -1 +0,0 @@ -Added new API for advanced data analysis diff --git a/doc/changelog.d/802.changed.md b/doc/changelog.d/802.changed.md deleted file mode 100644 index 9c77cbbc3..000000000 --- a/doc/changelog.d/802.changed.md +++ /dev/null @@ -1 +0,0 @@ -BREAKING CHANGE: Removed deprecated authentication methods. Users must migrate to the new authentication system. diff --git a/doc/changelog.d/803.feature.md b/doc/changelog.d/803.feature.md deleted file mode 100644 index 4b7c2981e..000000000 --- a/doc/changelog.d/803.feature.md +++ /dev/null @@ -1 +0,0 @@ -Added new feature for version increment testing in current branch diff --git a/doc/changelog.d/804.feature.md b/doc/changelog.d/804.feature.md deleted file mode 100644 index 4baf0bfd2..000000000 --- a/doc/changelog.d/804.feature.md +++ /dev/null @@ -1 +0,0 @@ -Added another feature to test version increment diff --git a/doc/changelog.d/805.fixed.md b/doc/changelog.d/805.fixed.md deleted file mode 100644 index 8ae75bada..000000000 --- a/doc/changelog.d/805.fixed.md +++ /dev/null @@ -1 +0,0 @@ -Fixed a minor bug in error handling diff --git a/doc/changelog.d/806.added.md b/doc/changelog.d/806.added.md deleted file mode 100644 index b3b4f83b9..000000000 --- a/doc/changelog.d/806.added.md +++ /dev/null @@ -1 +0,0 @@ -Added new testing feature for version increment diff --git a/doc/changelog.d/807.breaking.md b/doc/changelog.d/807.breaking.md deleted file mode 100644 index 70e90d1e3..000000000 --- a/doc/changelog.d/807.breaking.md +++ /dev/null @@ -1 +0,0 @@ -Breaking change: Removed deprecated API methods diff --git a/pyproject.toml b/pyproject.toml index 0b0d14e9d..a74bf772c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "flit_core.buildapi" [project] name = "ansys-sherlock-core" -version = "6.0.0" +version = "0.12.dev0" description = "A python wrapper for Ansys Sherlock" readme = "README.rst" requires-python = ">=3.10,<4" From d43074a0a7185c883adf773c033b289cd2c2ae03 Mon Sep 17 00:00:00 2001 From: skola Date: Mon, 6 Oct 2025 16:43:45 -0400 Subject: [PATCH 27/30] chore: bump version from 0.12.dev0 to 1.0.0 (major) --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index a74bf772c..3c190efce 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "flit_core.buildapi" [project] name = "ansys-sherlock-core" -version = "0.12.dev0" +version = "1.0.0" description = "A python wrapper for Ansys Sherlock" readme = "README.rst" requires-python = ">=3.10,<4" From 025c215287bb372603e08add7ee9dc52f52bff0b Mon Sep 17 00:00:00 2001 From: skola-ansys Date: Mon, 6 Oct 2025 16:48:12 -0400 Subject: [PATCH 28/30] Update pyproject.toml --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 3c190efce..a74bf772c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "flit_core.buildapi" [project] name = "ansys-sherlock-core" -version = "1.0.0" +version = "0.12.dev0" description = "A python wrapper for Ansys Sherlock" readme = "README.rst" requires-python = ">=3.10,<4" From 1ada568ac511f0e5128ddb769639e45bee0ce0b2 Mon Sep 17 00:00:00 2001 From: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com> Date: Tue, 7 Oct 2025 17:36:17 +0000 Subject: [PATCH 29/30] chore: adding changelog file 658.miscellaneous.md [dependabot-skip] --- doc/changelog.d/658.miscellaneous.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/changelog.d/658.miscellaneous.md diff --git a/doc/changelog.d/658.miscellaneous.md b/doc/changelog.d/658.miscellaneous.md new file mode 100644 index 000000000..17e6a6f31 --- /dev/null +++ b/doc/changelog.d/658.miscellaneous.md @@ -0,0 +1 @@ +Optimization/version check From 241cf75f47f71809f8341ef213e3082984315c7c Mon Sep 17 00:00:00 2001 From: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com> Date: Tue, 14 Oct 2025 18:51:31 +0000 Subject: [PATCH 30/30] chore: adding changelog file 658.miscellaneous.md [dependabot-skip] --- doc/changelog.d/658.miscellaneous.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/changelog.d/658.miscellaneous.md b/doc/changelog.d/658.miscellaneous.md index 17e6a6f31..e37967bb0 100644 --- a/doc/changelog.d/658.miscellaneous.md +++ b/doc/changelog.d/658.miscellaneous.md @@ -1 +1 @@ -Optimization/version check +Feat: Optimization version check