From cf7a167ec8ca2fcb6698f6f78f42cb469dd3fecf Mon Sep 17 00:00:00 2001 From: frazz <59382025+Sudo-Whodo@users.noreply.github.com> Date: Sun, 2 Feb 2025 23:12:30 -0800 Subject: [PATCH 1/6] fix: tesing --- docs/release-workflow.md | 177 +++++++++++++++++++++++++++------------ 1 file changed, 123 insertions(+), 54 deletions(-) diff --git a/docs/release-workflow.md b/docs/release-workflow.md index 7c21340..618e3fd 100644 --- a/docs/release-workflow.md +++ b/docs/release-workflow.md @@ -2,7 +2,55 @@ This document outlines the process for releasing new versions of PR Genius. -## Pre-release Testing +## Automated Release Process + +PR Genius uses python-semantic-release and GitHub Actions to automate the release process. The workflow is configured to: + +1. Monitor commits for version-worthy changes using conventional commit messages +2. Create release PRs automatically when changes warrant a new version +3. Generate changelogs and update version numbers +4. Create GitHub releases and Docker images + +### Release Types + +The system supports three types of releases: + +1. **Regular Releases** (from main branch) + + - Created when changes are pushed to main + - Version format: v1.2.3 + - Full production releases + +2. **Alpha Releases** (from feature branches) + + - Created when changes are pushed to feature/\* branches + - Version format: v1.2.3-alpha.1 + - Used for testing new features + - Created automatically from feature branches + +3. **Beta Releases** (from fix branches) + - Created when changes are pushed to fix/\* branches + - Version format: v1.2.3-beta.1 + - Used for testing bug fixes + - Created automatically from fix branches + +### Commit Message Format + +The release process relies on conventional commit messages to determine version bumps: + +- `feat:` - New feature (minor version bump) +- `fix:` or `perf:` - Bug fix or performance improvement (patch version bump) +- `BREAKING CHANGE:` - Breaking API change (major version bump) + +Example commit messages: + +``` +feat: add new analysis feature +fix: resolve memory leak in processor +feat!: redesign API (includes BREAKING CHANGE) +``` + +## Manual Testing 1. Run the test suite: @@ -39,102 +87,123 @@ export PR_REVIEW_SYSTEM_CONTENT="Focus on security" ## Release Process -1. Update version in pyproject.toml: +### Automated Release Flow -```toml -[tool.poetry] -name = "pr-genius" -version = "1.2.3" # New version here -``` +1. **Triggering a Release** -2. Update CHANGELOG.md with the new version and changes: + - Push changes to main, feature/_, or fix/_ branches + - Or manually trigger the Release workflow in GitHub Actions -```markdown -## [1.2.3] - YYYY-MM-DD +2. **Version Check** -### Added + - The system analyzes commit messages since the last release + - Determines if a version bump is needed and what type + - Creates a release PR if changes warrant a new version -- New feature X -- New feature Y +3. **Release PR** -### Changed + - Contains version updates and changelog + - For main branch: targets main + - For feature branches: targets the feature branch with alpha version + - For fix branches: targets the fix branch with beta version -- Improvement to Z -- Update to A +4. **After PR Merge** + - Creates GitHub release + - Pushes Docker images + - Regular releases go to main + - Prereleases stay on their respective branches -### Fixed +### Manual Release (if needed) -- Bug fix for B -- Issue with C -``` +You can still create releases manually if needed: -3. Create a new release branch: +1. Create a release branch: ```bash git checkout -b release/v1.2.3 ``` -4. Commit changes: +2. Update version and changelog: ```bash -git add pyproject.toml CHANGELOG.md +semantic-release version --no-commit +git add . git commit -m "chore(release): prepare v1.2.3" ``` -5. Create a pull request and wait for CI checks +3. Create and merge a PR to main -6. After merging, tag the release: +4. The workflow will handle the rest automatically -```bash -git tag -a v1.2.3 -m "Release v1.2.3" -git push origin v1.2.3 -``` +## Post-release -7. Create a GitHub release: +1. Verify the release: -- Go to Releases > Draft a new release -- Choose the tag -- Copy changelog entries -- Publish release + - Check GitHub releases page + - Verify Docker images are published + - Test the new version in a clean environment -## Post-release +2. Update documentation if needed: + + - README.md + - docs/usage-guide.md + - Example workflows -1. Verify the GitHub Action works with the new release: +3. Verify the GitHub Action works with the new release: ```yaml - uses: sudo-whodo/pr-genius@v1.2.3 ``` -2. Update documentation if needed: - -- README.md -- docs/usage-guide.md -- Example workflows - ## Hotfix Process For urgent fixes to a released version: -1. Create a hotfix branch from the tag: +1. Create a fix branch: ```bash -git checkout -b hotfix/v1.2.4 v1.2.3 +git checkout -b fix/urgent-issue main ``` -2. Make the fix and update version/changelog +2. Make your changes and commit with appropriate message: -3. Follow steps 4-7 from the release process +```bash +git commit -m "fix: resolve critical issue" +``` + +3. Push the branch: + +```bash +git push origin fix/urgent-issue +``` + +4. The workflow will automatically: + - Create a beta release for testing + - Create a release PR when ready ## Version Numbering -We follow semantic versioning: +We follow semantic versioning with prerelease support: + +### Regular Releases (main branch) + +- Format: MAJOR.MINOR.PATCH +- Example: 1.2.3 + - MAJOR: Incompatible API changes + - MINOR: New features (backwards compatible) + - PATCH: Bug fixes (backwards compatible) + +### Prerelease Versions + +- Alpha (feature branches) -- MAJOR version for incompatible API changes -- MINOR version for new features in a backwards compatible manner -- PATCH version for backwards compatible bug fixes + - Format: MAJOR.MINOR.PATCH-alpha.N + - Example: 1.2.3-alpha.1 + - Used for new feature testing -Example: 1.2.3 +- Beta (fix branches) + - Format: MAJOR.MINOR.PATCH-beta.N + - Example: 1.2.3-beta.1 + - Used for bug fix testing -- 1 = Major version -- 2 = Minor version -- 3 = Patch version +Version bumps are determined automatically from commit messages using conventional commit format. From b1883a1982c1af96664adefc718cac1d97afde1a Mon Sep 17 00:00:00 2001 From: frazz <59382025+Sudo-Whodo@users.noreply.github.com> Date: Sun, 2 Feb 2025 23:20:16 -0800 Subject: [PATCH 2/6] chore: move files --- {pr-diff-bot => pr_diff_bot}/__init__.py | 0 {pr-diff-bot => pr_diff_bot}/llm_clients.py | 0 {pr-diff-bot => pr_diff_bot}/pr_diff_analyzer.py | 0 {pr-diff-bot => pr_diff_bot}/requirements.txt | 0 {pr-diff-bot => pr_diff_bot}/test_llm_client.py | 0 pyproject.toml | 2 +- 6 files changed, 1 insertion(+), 1 deletion(-) rename {pr-diff-bot => pr_diff_bot}/__init__.py (100%) rename {pr-diff-bot => pr_diff_bot}/llm_clients.py (100%) rename {pr-diff-bot => pr_diff_bot}/pr_diff_analyzer.py (100%) rename {pr-diff-bot => pr_diff_bot}/requirements.txt (100%) rename {pr-diff-bot => pr_diff_bot}/test_llm_client.py (100%) diff --git a/pr-diff-bot/__init__.py b/pr_diff_bot/__init__.py similarity index 100% rename from pr-diff-bot/__init__.py rename to pr_diff_bot/__init__.py diff --git a/pr-diff-bot/llm_clients.py b/pr_diff_bot/llm_clients.py similarity index 100% rename from pr-diff-bot/llm_clients.py rename to pr_diff_bot/llm_clients.py diff --git a/pr-diff-bot/pr_diff_analyzer.py b/pr_diff_bot/pr_diff_analyzer.py similarity index 100% rename from pr-diff-bot/pr_diff_analyzer.py rename to pr_diff_bot/pr_diff_analyzer.py diff --git a/pr-diff-bot/requirements.txt b/pr_diff_bot/requirements.txt similarity index 100% rename from pr-diff-bot/requirements.txt rename to pr_diff_bot/requirements.txt diff --git a/pr-diff-bot/test_llm_client.py b/pr_diff_bot/test_llm_client.py similarity index 100% rename from pr-diff-bot/test_llm_client.py rename to pr_diff_bot/test_llm_client.py diff --git a/pyproject.toml b/pyproject.toml index ad4d457..932c68e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [tool.semantic_release] -version_variable = ["pr-diff-bot/__init__.py:__version__"] +version_variable = "pr_diff_bot/__init__.py:__version__" branch = "main" upload_to_pypi = false upload_to_release = true From a97ae11091eab065760b12080b893182e4c218fa Mon Sep 17 00:00:00 2001 From: frazz <59382025+Sudo-Whodo@users.noreply.github.com> Date: Sun, 2 Feb 2025 23:23:21 -0800 Subject: [PATCH 3/6] ci: test --- .github/workflows/release.yml | 12 +----------- pyproject.toml | 3 ++- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b174df6..e8e62d1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -40,17 +40,7 @@ jobs: - name: Check if release is needed id: check run: | - if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then - # Check if there are changes that warrant a new version - NEW_VERSION=$(semantic-release version --noop) - if [ -z "$NEW_VERSION" ]; then - echo "No version bump needed" - echo "should_release=false" >> $GITHUB_OUTPUT - else - echo "Version bump needed: $NEW_VERSION" - echo "should_release=true" >> $GITHUB_OUTPUT - fi - elif [[ "${{ github.event_name }}" == "push" ]]; then + if [[ "${{ github.event_name }}" == "workflow_dispatch" || "${{ github.event_name }}" == "push" ]]; then # Check if there are changes that warrant a new version NEW_VERSION=$(semantic-release version --noop) if [ -z "$NEW_VERSION" ]; then diff --git a/pyproject.toml b/pyproject.toml index 932c68e..27c6b9a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,6 @@ [tool.semantic_release] -version_variable = "pr_diff_bot/__init__.py:__version__" +version_variable = ["pr_diff_bot/__init__.py:__version__"] +version_pattern = "__version__ = '{version}'" branch = "main" upload_to_pypi = false upload_to_release = true From b43e256451933ba8257657e0cd12532dcb24e0e2 Mon Sep 17 00:00:00 2001 From: frazz <59382025+Sudo-Whodo@users.noreply.github.com> Date: Sun, 2 Feb 2025 23:27:00 -0800 Subject: [PATCH 4/6] chore: updating path --- Dockerfile | 4 ++-- test-local.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 23e136a..b3c8329 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,7 +10,7 @@ RUN apt-get update && \ WORKDIR /app # Copy requirements first for better caching -COPY pr-diff-bot/requirements.txt . +COPY pr_diff_bot/requirements.txt . RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir -r requirements.txt @@ -18,7 +18,7 @@ RUN pip install --no-cache-dir --upgrade pip && \ RUN mkdir -p /app/examples # Copy application code -COPY pr-diff-bot/ . +COPY pr_diff_bot/ . COPY entrypoint.sh . # Make entrypoint executable diff --git a/test-local.sh b/test-local.sh index b0d38cd..405d42a 100755 --- a/test-local.sh +++ b/test-local.sh @@ -34,12 +34,12 @@ echo "- OpenRouter Key: ${OPENROUTER_API_KEY:0:4}...${OPENROUTER_API_KEY: -4}" # Build the container echo -e "\nBuilding container..." -docker build -t pr-diff-analyzer:local . +docker build -t pr_diff_bot:local . # Run the container echo -e "\nRunning analysis..." docker run \ -e GITHUB_TOKEN=$GITHUB_TOKEN \ -e OPENROUTER_API_KEY=$OPENROUTER_API_KEY \ - pr-diff-analyzer:local \ + pr_diff_bot:local \ "$REPO" "$PR_NUMBER" "--model" "$MODEL" \ No newline at end of file From 9c5976ec5b0f126c46f7d75f7c3c8f1a5dd69d75 Mon Sep 17 00:00:00 2001 From: frazz <59382025+Sudo-Whodo@users.noreply.github.com> Date: Sun, 2 Feb 2025 23:40:56 -0800 Subject: [PATCH 5/6] chore: update path and version --- .github/workflows/release.yml | 6 +++--- pr_diff_bot/pr_diff_analyzer.py | 4 +--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e8e62d1..8496c6d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -35,7 +35,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install python-semantic-release==7.34.6 + pip install python-semantic-release==8.7.0 - name: Check if release is needed id: check @@ -73,7 +73,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install python-semantic-release==7.34.6 + pip install python-semantic-release==8.7.0 - name: Configure Git run: | @@ -159,7 +159,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install python-semantic-release==7.34.6 + pip install python-semantic-release==8.7.0 - name: Configure Git run: | diff --git a/pr_diff_bot/pr_diff_analyzer.py b/pr_diff_bot/pr_diff_analyzer.py index 54ea8e8..f86e484 100644 --- a/pr_diff_bot/pr_diff_analyzer.py +++ b/pr_diff_bot/pr_diff_analyzer.py @@ -13,9 +13,7 @@ import git import sys import os -# Add the root directory to Python path -sys.path.append(os.path.dirname(os.path.abspath(__file__))) -from llm_clients import get_llm_client +from pr_diff_bot.llm_clients import get_llm_client # Configure logging logging.basicConfig( From 11794a121cb2e59a03d6d74696494899fbafcece Mon Sep 17 00:00:00 2001 From: frazz <59382025+Sudo-Whodo@users.noreply.github.com> Date: Sun, 2 Feb 2025 23:46:57 -0800 Subject: [PATCH 6/6] chore: path --- Dockerfile | 15 ++++++--------- entrypoint.sh | 4 ++-- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index b3c8329..f91cdd3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,16 +9,13 @@ RUN apt-get update && \ # Set working directory WORKDIR /app -# Copy requirements first for better caching -COPY pr_diff_bot/requirements.txt . -RUN pip install --no-cache-dir --upgrade pip && \ - pip install --no-cache-dir -r requirements.txt - -# Create directories -RUN mkdir -p /app/examples +# Copy source code +COPY . /app/ -# Copy application code -COPY pr_diff_bot/ . +# Install package and dependencies +RUN pip install --no-cache-dir --upgrade pip && \ + pip install --no-cache-dir -r pr_diff_bot/requirements.txt && \ + pip install -e . COPY entrypoint.sh . # Make entrypoint executable diff --git a/entrypoint.sh b/entrypoint.sh index efe208f..fcc86db 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -62,7 +62,7 @@ esac # Run the PR diff analyzer echo "Running analysis for repository: $REPO, PR: $PR, Provider: $PROVIDER${MODEL:+, Model: $MODEL}" if [ -n "$MODEL" ]; then - python /app/pr_diff_analyzer.py --repo "$REPO" --pr "$PR" --provider "$PROVIDER" --model "$MODEL" + python /app/pr_diff_bot/pr_diff_analyzer.py --repo "$REPO" --pr "$PR" --provider "$PROVIDER" --model "$MODEL" else - python /app/pr_diff_analyzer.py --repo "$REPO" --pr "$PR" --provider "$PROVIDER" + python /app/pr_diff_bot/pr_diff_analyzer.py --repo "$REPO" --pr "$PR" --provider "$PROVIDER" fi