diff --git a/PR_CONFLICT_RESOLUTION.md b/PR_CONFLICT_RESOLUTION.md new file mode 100644 index 0000000..e27c218 --- /dev/null +++ b/PR_CONFLICT_RESOLUTION.md @@ -0,0 +1,189 @@ +# Pull Request Conflict Resolution Guide + +This document provides step-by-step instructions to resolve merge conflicts in PRs #2, #3, and #4. + +## Root Cause + +The base branch `ci/add-github-workflows` split the single `ci.yml` workflow into three separate workflow files: +- `.github/workflows/lint.yml` (Ruff linting) +- `.github/workflows/typecheck.yml` (Mypy type checking) +- `.github/workflows/tests.yml` (Pytest tests) + +PRs #2, #3, and #4 all modify the original `ci.yml` file, which no longer exists in the base branch, causing merge conflicts. + +## PR #2: Improve CI workflow with dependency caching and Python version matrix + +**Changes to Apply:** +- Add `permissions: contents: read` to all three workflow files +- Add `enable-cache: true` to uv setup in all three workflows +- Add Python version matrix (`["3.12", "3.13"]`) to tests.yml +- Update test job name to include Python version: `Pytest - Python ${{ matrix.python-version }}` +- Update Python installation in tests.yml to use matrix variable: `uv python install ${{ matrix.python-version }}` + +### Resolution Steps: + +1. Checkout the branch: + ```bash + git checkout copilot/sub-pr-1 + git merge ci/add-github-workflows + ``` + +2. Remove the conflicted ci.yml: + ```bash + git rm .github/workflows/ci.yml + ``` + +3. Apply the improvements to each new workflow file: + + **lint.yml:** + - Add `permissions: contents: read` after the `on:` section + - Add `enable-cache: true` to the uv setup step + + **typecheck.yml:** + - Add `permissions: contents: read` after the `on:` section + - Add `enable-cache: true` to the uv setup step + + **tests.yml:** + - Add `permissions: contents: read` after the `on:` section + - Add `enable-cache: true` to the uv setup step + - Add matrix strategy with Python 3.12 and 3.13 + - Update job name to include version + - Use matrix Python version in setup step + +4. Commit and push: + ```bash + git add . + git commit -m "Resolve merge conflict: Apply PR #2 improvements to split workflow files" + git push origin copilot/sub-pr-1 + ``` + +## PR #3: Remove trailing blank line from CI workflow + +**Status:** This PR only removed a trailing blank line from `ci.yml`. Since the file has been split and reformatted, this change is no longer applicable. + +**Resolution:** Close this PR as the formatting issue has been resolved in the split workflow files. + +### Resolution Steps: + +1. Close PR #3 with a comment explaining that the formatting issue was resolved during the workflow split. + +## PR #4: Extract duplicated CI setup steps into composite action + +**Changes to Apply:** +- Create `.github/actions/setup-python-uv/action.yml` composite action +- Update all three workflow files to use the composite action +- Add `install-extras` parameter to the composite action (default: false) +- Test workflow should pass `install-extras: 'true'` + +### Resolution Steps: + +1. Checkout the branch: + ```bash + git checkout copilot/sub-pr-1-another-one + git merge ci/add-github-workflows + ``` + +2. Remove the conflicted ci.yml: + ```bash + git rm .github/workflows/ci.yml + ``` + +3. Create the composite action `.github/actions/setup-python-uv/action.yml`: + ```yaml + name: Setup Python with uv + description: Set up Python environment using uv package manager + + inputs: + install-extras: + description: 'Whether to install all extras with dependencies' + required: false + default: 'false' + + runs: + using: composite + steps: + - uses: actions/checkout@v4 + + - name: Install uv + uses: astral-sh/setup-uv@v4 + with: + version: "latest" + + - name: Set up Python + shell: bash + run: uv python install 3.12 + + - name: Install dependencies + shell: bash + run: | + if [ "${{ inputs.install-extras }}" = "true" ]; then + uv sync --group dev --all-extras + else + uv sync --group dev + fi + ``` + +4. Update each workflow file to use the composite action: + + **lint.yml:** + ```yaml + steps: + - name: Setup Python with uv + uses: ./.github/actions/setup-python-uv + + - name: Run Ruff check + run: uv run ruff check src/ tests/ + + - name: Run Ruff format check + run: uv run ruff format --check src/ tests/ + ``` + + **typecheck.yml:** + ```yaml + steps: + - name: Setup Python with uv + uses: ./.github/actions/setup-python-uv + + - name: Run Mypy + run: uv run mypy src/ + ``` + + **tests.yml:** + ```yaml + steps: + - name: Setup Python with uv + uses: ./.github/actions/setup-python-uv + with: + install-extras: 'true' + + - name: Run tests + run: uv run pytest tests/ -v --tb=short + ``` + +5. Commit and push: + ```bash + git add . + git commit -m "Resolve merge conflict: Apply composite action to split workflow files" + git push origin copilot/sub-pr-1-another-one + ``` + +## Recommended Merge Order + +To avoid future conflicts, merge PRs in this order: + +1. **PR #1** - Base CI workflows (already mergeable, no conflicts) +2. **PR #2** - Add caching and Python matrix (after resolving conflicts per above) +3. **Close PR #3** - No longer needed after split +4. **PR #4** - Add composite action (after resolving conflicts per above, can be merged after PR #2) + +## Alternative: Combined Resolution + +Instead of resolving each PR separately, consider combining the best features of all PRs into a single update to PR #1: + +1. Start with the split workflows from PR #1 +2. Add caching and permissions from PR #2 +3. Add Python version matrix from PR #2 +4. Add composite action from PR #4 +5. Close PRs #2, #3, #4 as superseded + +This would result in clean, optimized workflows with all improvements applied without conflicts. diff --git a/SCRIPTS-README.md b/SCRIPTS-README.md new file mode 100644 index 0000000..65ae950 --- /dev/null +++ b/SCRIPTS-README.md @@ -0,0 +1,128 @@ +# Conflict Resolution Scripts + +This directory contains automated scripts to resolve merge conflicts in pull requests. + +## Quick Start + +```bash +# Resolve PR #2 +./resolve-pr2.sh + +# Resolve PR #4 +./resolve-pr4.sh +``` + +## What These Scripts Do + +### `resolve-pr2.sh` +Resolves conflicts in **PR #2: Improve CI workflow with dependency caching and Python version matrix** + +**Actions:** +1. Checks out branch `copilot/sub-pr-1` +2. Merges `ci/add-github-workflows` (creates expected conflicts) +3. Removes old `ci.yml` file +4. Creates new split workflow files with these improvements: + - `enable-cache: true` for faster CI runs + - `permissions: contents: read` for security + - Python version matrix (3.12, 3.13) in tests +5. Commits and pushes the resolution + +### `resolve-pr4.sh` +Resolves conflicts in **PR #4: Extract duplicated CI setup steps into composite action** + +**Actions:** +1. Checks out branch `copilot/sub-pr-1-another-one` +2. Merges `ci/add-github-workflows` (creates expected conflicts) +3. Removes old `ci.yml` file +4. Creates composite action `.github/actions/setup-python-uv/` +5. Creates new split workflow files using the composite action +6. Includes all improvements from PR #2 +7. Commits and pushes the resolution + +## Prerequisites + +- Git repository cloned locally +- Write access to push to `copilot/sub-pr-1` and `copilot/sub-pr-1-another-one` branches +- All remote branches fetched (`git fetch --all`) + +## Error Handling + +Both scripts include robust error handling: +- ✅ Verbose logging of each step +- ✅ Verification that expected conflicts exist +- ✅ Graceful handling of missing files +- ✅ Automatic rollback on unexpected conditions +- ✅ Clear error messages for debugging + +## Troubleshooting + +### "Could not reset to origin" +This warning is informational. The script will use the current HEAD instead. This happens if you haven't fetched the remote branch. + +**Solution:** +```bash +git fetch --all +``` + +### "Error: Expected conflicts but none found" +This means the branches have already been merged or the conflict was already resolved. + +**Solution:** Check the PR status on GitHub. If it's already mergeable, you don't need to run the script. + +### "Error: Merge completed without conflicts" +This is unexpected and suggests the branches are already compatible. + +**Solution:** Check if the PR was already resolved manually. + +### "Authentication failed" +The scripts require push permissions to the repository. + +**Solution:** Ensure you have write access and your Git credentials are configured. + +## Manual Alternative + +If you prefer not to use the scripts, see: +- `PR_CONFLICT_RESOLUTION.md` for step-by-step manual instructions +- `resolved-workflows/` for pre-resolved workflow files you can copy + +## Testing the Scripts + +To test the scripts without pushing: + +1. Comment out the `git push` line in the script +2. Run the script +3. Review the changes with `git diff --cached` +4. If satisfied, manually push with `git push origin ` + +## What Happens After Running + +After running the scripts: +1. Check the PR on GitHub - conflicts should be resolved +2. The PR should show as "mergeable" +3. Review the changes in the PR +4. Merge when ready + +## Script Output Example + +``` +Resolving conflicts in PR #2 (copilot/sub-pr-1)... +Resetting branch to clean state... +Reset to origin/copilot/sub-pr-1 +Merging ci/add-github-workflows... +Merge conflicts detected (expected). Proceeding with resolution... +Conflicted files: .github/workflows/ci.yml +Removing conflicted ci.yml... +Creating resolved workflow files... +Staging changes... +Committing resolution... +Pushing to origin... +PR #2 conflicts resolved and pushed successfully! +``` + +## Support + +If you encounter issues: +1. Check the error message for specific guidance +2. Review `SUMMARY.md` for overall context +3. See `PR_CONFLICT_RESOLUTION.md` for manual steps +4. Open an issue in the repository diff --git a/SUMMARY.md b/SUMMARY.md new file mode 100644 index 0000000..aa79429 --- /dev/null +++ b/SUMMARY.md @@ -0,0 +1,172 @@ +# Conflict Resolution Summary + +## Overview + +All pull request conflicts have been analyzed and resolution materials have been prepared. This document summarizes the findings and provides the path forward. + +## Pull Request Status + +| PR # | Title | Base Branch | Status | Action Required | +|------|-------|-------------|--------|-----------------| +| #1 | Add GitHub Actions CI workflow and README badges | main | ✅ **Mergeable** | Merge when ready | +| #2 | Improve CI workflow with dependency caching and Python version matrix | ci/add-github-workflows | ❌ **Has Conflicts** | Run `resolve-pr2.sh` | +| #3 | Remove trailing blank line from CI workflow | ci/add-github-workflows | ℹ️ **Not Needed** | Close with explanation | +| #4 | Extract duplicated CI setup steps into composite action | ci/add-github-workflows | ❌ **Has Conflicts** | Run `resolve-pr4.sh` | +| #5 | Review and resolve conflicts in pull requests | main | 📝 **This PR** | Contains resolution materials | + +## Conflict Root Cause + +The base branch for PRs #2, #3, and #4 (`ci/add-github-workflows`) underwent a significant refactoring: +- **Before**: Single file `.github/workflows/ci.yml` with all CI jobs +- **After**: Split into three files: + - `.github/workflows/lint.yml` (Ruff linting) + - `.github/workflows/typecheck.yml` (Mypy type checking) + - `.github/workflows/tests.yml` (Pytest tests) + +All three dependent PRs modified the original `ci.yml` file, which no longer exists in the base branch, creating merge conflicts. + +## Resolution Strategy + +### Automated Resolution (Recommended) + +Two shell scripts have been created to automatically resolve the conflicts: + +1. **`resolve-pr2.sh`** - Resolves PR #2 + - Merges the split workflow structure + - Applies caching (`enable-cache: true`) + - Adds security permissions (`permissions: contents: read`) + - Implements Python version matrix (3.12, 3.13) + +2. **`resolve-pr4.sh`** - Resolves PR #4 + - Merges the split workflow structure + - Creates composite action `.github/actions/setup-python-uv/` + - Eliminates code duplication across workflows + - Includes all improvements from PR #2 + +### Manual Resolution + +For those who prefer manual resolution, complete step-by-step instructions are provided in `PR_CONFLICT_RESOLUTION.md`. + +### Pre-Resolved Files + +The `resolved-workflows/` directory contains production-ready workflow files that incorporate ALL improvements from both PR #2 and PR #4. These can be copied directly into any branch. + +## Resolution Details + +### PR #2 Resolution + +**Improvements Applied:** +- ✅ `enable-cache: true` on all uv setup steps +- ✅ `permissions: contents: read` for security +- ✅ Python version matrix testing (3.12, 3.13) +- ✅ Job names include Python version for clarity + +**Files Modified:** +- `.github/workflows/lint.yml` +- `.github/workflows/typecheck.yml` +- `.github/workflows/tests.yml` + +### PR #3 Resolution + +**Status:** ⚠️ **Not Applicable** + +This PR only removed a trailing blank line from `ci.yml`. Since the file was split and reformatted, this formatting issue is already resolved. + +**Recommendation:** Close PR #3 with a comment explaining that the formatting issue was resolved during the workflow split. + +### PR #4 Resolution + +**Improvements Applied:** +- ✅ Composite action created (`.github/actions/setup-python-uv/action.yml`) +- ✅ All workflows use the composite action (DRY principle) +- ✅ Composite action parameterized (`install-extras`, `python-version`) +- ✅ Includes all improvements from PR #2 +- ✅ `enable-cache: true` in composite action +- ✅ `permissions: contents: read` in all workflows + +**Files Created/Modified:** +- `.github/actions/setup-python-uv/action.yml` (new) +- `.github/workflows/lint.yml` +- `.github/workflows/typecheck.yml` +- `.github/workflows/tests.yml` + +## Execution Instructions + +### For Repository Maintainers with Push Access + +1. **Clone the repository** (if not already cloned) + ```bash + git clone https://github.com/Abstract-Data/RyanData-Address-Utils.git + cd RyanData-Address-Utils + ``` + +2. **Fetch all branches** + ```bash + git fetch --all + ``` + +3. **Resolve PR #2** + ```bash + ./resolve-pr2.sh + ``` + This will checkout `copilot/sub-pr-1`, merge `ci/add-github-workflows`, resolve conflicts, and push. + +4. **Resolve PR #4** + ```bash + ./resolve-pr4.sh + ``` + This will checkout `copilot/sub-pr-1-another-one`, merge `ci/add-github-workflows`, resolve conflicts, and push. + +5. **Close PR #3** + - Go to https://github.com/Abstract-Data/RyanData-Address-Utils/pull/3 + - Add comment: "This PR is no longer needed. The formatting issue (trailing blank line) was resolved when the CI workflow was split into separate files in the base branch." + - Close the PR + +6. **Verify resolutions** + - Check PR #2: https://github.com/Abstract-Data/RyanData-Address-Utils/pull/2 + - Check PR #4: https://github.com/Abstract-Data/RyanData-Address-Utils/pull/4 + - Both should now show as mergeable + +### Alternative: Manual Application + +If you prefer not to run the scripts, you can: + +1. Copy files from `resolved-workflows/` to the appropriate PR branches +2. Or apply the changes to PR #1 directly +3. Or create a new PR with all improvements combined + +## Benefits of Resolution + +Once conflicts are resolved, the repository will have: + +1. **Better CI Organization**: Separate workflows for each task (lint, type check, test) +2. **Faster CI Runs**: Dependency caching reduces setup time +3. **Better Test Coverage**: Python 3.12 and 3.13 matrix testing +4. **Cleaner Code**: Composite action eliminates duplication +5. **Better Security**: Explicit permissions on all workflows +6. **Better Status Visibility**: Separate workflow badges for each CI task + +## Recommended Merge Order + +1. Merge PR #1 (already mergeable) +2. Merge resolved PR #2 +3. Close PR #3 (not needed) +4. Merge resolved PR #4 (builds on #2) +5. Close PR #5 (this PR - task complete) + +## Files Provided in This PR + +- `PR_CONFLICT_RESOLUTION.md` - Detailed manual resolution guide +- `SUMMARY.md` - This file +- `resolve-pr2.sh` - Automated PR #2 resolution script +- `resolve-pr4.sh` - Automated PR #4 resolution script +- `resolved-workflows/` - Directory with pre-resolved workflow files + - `README.md` - Guide for using resolved files + - `lint.yml` - Resolved lint workflow + - `typecheck.yml` - Resolved typecheck workflow + - `tests.yml` - Resolved test workflow + - `setup-python-uv-action.yml` - Composite action + +## Questions or Issues? + +If you encounter any issues with the resolution scripts or need clarification, please comment on this PR (#5). diff --git a/resolve-pr2.sh b/resolve-pr2.sh new file mode 100755 index 0000000..533ff3d --- /dev/null +++ b/resolve-pr2.sh @@ -0,0 +1,180 @@ +#!/bin/bash +# Script to resolve conflicts in PR #2 (copilot/sub-pr-1) +# This applies the improvements from PR #2 to the split workflow structure + +set -e + +echo "Resolving conflicts in PR #2 (copilot/sub-pr-1)..." + +# Checkout the PR branch +git checkout copilot/sub-pr-1 + +# Reset to the original state before any merge attempts +echo "Resetting branch to clean state..." +if git reset --hard origin/copilot/sub-pr-1 2>/dev/null; then + echo "Reset to origin/copilot/sub-pr-1" +else + echo "Warning: Could not reset to origin, using current HEAD" + git reset --hard HEAD +fi + +# Merge the base branch +echo "Merging ci/add-github-workflows..." +if ! git merge ci/add-github-workflows --no-commit --no-ff; then + echo "Merge conflicts detected (expected). Proceeding with resolution..." + + # Verify conflicts exist + CONFLICTS=$(git diff --name-only --diff-filter=U) + if [ -z "$CONFLICTS" ]; then + echo "Error: Expected conflicts but none found. Aborting." + git merge --abort 2>/dev/null || true + exit 1 + fi + echo "Conflicted files: $CONFLICTS" +else + echo "Error: Merge completed without conflicts. This is unexpected. Aborting." + git reset --hard HEAD~1 + exit 1 +fi + +# Remove the conflicted ci.yml file if it exists +echo "Removing conflicted ci.yml..." +if [ -f .github/workflows/ci.yml ]; then + git rm .github/workflows/ci.yml +else + # File might already be staged for deletion + git rm --cached .github/workflows/ci.yml 2>/dev/null || echo "ci.yml already removed" +fi + +# The new workflow files were added by the merge, now we need to enhance them +# Add permissions and caching to lint.yml +cat > .github/workflows/lint.yml << 'EOF' +name: Ruff + +on: + push: + branches: [main] + pull_request: + branches: [main] + +permissions: + contents: read + +jobs: + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install uv + uses: astral-sh/setup-uv@v4 + with: + version: "latest" + enable-cache: true + + - name: Set up Python + run: uv python install 3.12 + + - name: Install dependencies + run: uv sync --group dev + + - name: Run Ruff check + run: uv run ruff check src/ tests/ + + - name: Run Ruff format check + run: uv run ruff format --check src/ tests/ +EOF + +# Add permissions and caching to typecheck.yml +cat > .github/workflows/typecheck.yml << 'EOF' +name: Mypy + +on: + push: + branches: [main] + pull_request: + branches: [main] + +permissions: + contents: read + +jobs: + typecheck: + name: Type Check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install uv + uses: astral-sh/setup-uv@v4 + with: + version: "latest" + enable-cache: true + + - name: Set up Python + run: uv python install 3.12 + + - name: Install dependencies + run: uv sync --group dev + + - name: Run Mypy + run: uv run mypy src/ +EOF + +# Add permissions, caching, and Python matrix to tests.yml +cat > .github/workflows/tests.yml << 'EOF' +name: Tests + +on: + push: + branches: [main] + pull_request: + branches: [main] + +permissions: + contents: read + +jobs: + test: + name: Pytest - Python ${{ matrix.python-version }} + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.12", "3.13"] + steps: + - uses: actions/checkout@v4 + + - name: Install uv + uses: astral-sh/setup-uv@v4 + with: + version: "latest" + enable-cache: true + + - name: Set up Python + run: uv python install ${{ matrix.python-version }} + + - name: Install dependencies + run: uv sync --group dev --all-extras + + - name: Run tests + run: uv run pytest tests/ -v --tb=short +EOF + +# Stage all changes +git add . + +# Commit the resolution +git commit -m "Resolve merge conflict: Apply PR #2 improvements to split workflow files + +- Replaced single ci.yml with split workflows (lint.yml, typecheck.yml, tests.yml) +- Applied improvements from original PR #2: + - Added enable-cache: true for uv setup in all workflows + - Added permissions: contents: read to all workflows + - Added Python version matrix (3.12, 3.13) to test workflow + - Updated test job name to include Python version" + +# Push the resolved branch +git push origin copilot/sub-pr-1 + +echo "PR #2 conflicts resolved and pushed successfully!" diff --git a/resolve-pr4.sh b/resolve-pr4.sh new file mode 100755 index 0000000..250e628 --- /dev/null +++ b/resolve-pr4.sh @@ -0,0 +1,195 @@ +#!/bin/bash +# Script to resolve conflicts in PR #4 (copilot/sub-pr-1-another-one) +# This applies the composite action approach to the split workflow structure + +set -e + +echo "Resolving conflicts in PR #4 (copilot/sub-pr-1-another-one)..." + +# Checkout the PR branch +git checkout copilot/sub-pr-1-another-one + +# Reset to the original state before any merge attempts +echo "Resetting branch to clean state..." +if git reset --hard origin/copilot/sub-pr-1-another-one 2>/dev/null; then + echo "Reset to origin/copilot/sub-pr-1-another-one" +else + echo "Warning: Could not reset to origin, using current HEAD" + git reset --hard HEAD +fi + +# Merge the base branch +echo "Merging ci/add-github-workflows..." +if ! git merge ci/add-github-workflows --no-commit --no-ff; then + echo "Merge conflicts detected (expected). Proceeding with resolution..." + + # Verify conflicts exist + CONFLICTS=$(git diff --name-only --diff-filter=U) + if [ -z "$CONFLICTS" ]; then + echo "Error: Expected conflicts but none found. Aborting." + git merge --abort 2>/dev/null || true + exit 1 + fi + echo "Conflicted files: $CONFLICTS" +else + echo "Error: Merge completed without conflicts. This is unexpected. Aborting." + git reset --hard HEAD~1 + exit 1 +fi + +# Remove the conflicted ci.yml file if it exists +echo "Removing conflicted ci.yml..." +if [ -f .github/workflows/ci.yml ]; then + git rm .github/workflows/ci.yml +else + # File might already be staged for deletion + git rm --cached .github/workflows/ci.yml 2>/dev/null || echo "ci.yml already removed" +fi + +# Create the composite action directory +mkdir -p .github/actions/setup-python-uv + +# Create the composite action with enhancements (caching + python-version parameter) +cat > .github/actions/setup-python-uv/action.yml << 'EOF' +name: Setup Python with uv +description: Set up Python environment using uv package manager + +inputs: + install-extras: + description: 'Whether to install all extras with dependencies' + required: false + default: 'false' + python-version: + description: 'Python version to install' + required: false + default: '3.12' + +runs: + using: composite + steps: + - uses: actions/checkout@v4 + + - name: Install uv + uses: astral-sh/setup-uv@v4 + with: + version: "latest" + enable-cache: true + + - name: Set up Python + shell: bash + run: uv python install ${{ inputs.python-version }} + + - name: Install dependencies + shell: bash + run: | + if [ "${{ inputs.install-extras }}" = "true" ]; then + uv sync --group dev --all-extras + else + uv sync --group dev + fi +EOF + +# Update lint.yml to use composite action +cat > .github/workflows/lint.yml << 'EOF' +name: Ruff + +on: + push: + branches: [main] + pull_request: + branches: [main] + +permissions: + contents: read + +jobs: + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - name: Setup Python with uv + uses: ./.github/actions/setup-python-uv + + - name: Run Ruff check + run: uv run ruff check src/ tests/ + + - name: Run Ruff format check + run: uv run ruff format --check src/ tests/ +EOF + +# Update typecheck.yml to use composite action +cat > .github/workflows/typecheck.yml << 'EOF' +name: Mypy + +on: + push: + branches: [main] + pull_request: + branches: [main] + +permissions: + contents: read + +jobs: + typecheck: + name: Type Check + runs-on: ubuntu-latest + steps: + - name: Setup Python with uv + uses: ./.github/actions/setup-python-uv + + - name: Run Mypy + run: uv run mypy src/ +EOF + +# Update tests.yml to use composite action with extras and Python matrix +cat > .github/workflows/tests.yml << 'EOF' +name: Tests + +on: + push: + branches: [main] + pull_request: + branches: [main] + +permissions: + contents: read + +jobs: + test: + name: Pytest - Python ${{ matrix.python-version }} + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.12", "3.13"] + steps: + - name: Setup Python with uv + uses: ./.github/actions/setup-python-uv + with: + install-extras: 'true' + python-version: ${{ matrix.python-version }} + + - name: Run tests + run: uv run pytest tests/ -v --tb=short +EOF + +# Stage all changes +git add . + +# Commit the resolution +git commit -m "Resolve merge conflict: Apply composite action to split workflow files + +- Replaced single ci.yml with split workflows (lint.yml, typecheck.yml, tests.yml) +- Created composite action .github/actions/setup-python-uv/action.yml +- Applied improvements: + - Composite action reduces duplication across workflows + - Added enable-cache: true to composite action + - Added permissions: contents: read to all workflows + - Added python-version parameter to composite action + - Added Python version matrix (3.12, 3.13) to test workflow + - Test workflow passes install-extras and python-version to composite action" + +# Push the resolved branch +git push origin copilot/sub-pr-1-another-one + +echo "PR #4 conflicts resolved and pushed successfully!" diff --git a/resolved-workflows/README.md b/resolved-workflows/README.md new file mode 100644 index 0000000..edc6332 --- /dev/null +++ b/resolved-workflows/README.md @@ -0,0 +1,90 @@ +# Pull Request Conflict Resolution + +This directory contains everything needed to resolve merge conflicts in PRs #2, #3, and #4. + +## Quick Summary + +- **PR #1**: ✅ No conflicts (mergeable) +- **PR #2**: ❌ Has conflicts (resolved via `resolve-pr2.sh`) +- **PR #3**: ℹ️ Not needed (formatting fix superseded by workflow split) +- **PR #4**: ❌ Has conflicts (resolved via `resolve-pr4.sh`) + +## Root Cause + +The base branch `ci/add-github-workflows` split the single `.github/workflows/ci.yml` into three files: +- `lint.yml` - Ruff linting +- `typecheck.yml` - Mypy type checking +- `tests.yml` - Pytest testing + +PRs #2, #3, and #4 all modify the old `ci.yml` which no longer exists, causing conflicts. + +## Automated Resolution + +### Option 1: Run Resolution Scripts + +The repository contains automated scripts to resolve each PR: + +```bash +# Resolve PR #2 (caching + Python matrix) +./resolve-pr2.sh + +# Resolve PR #4 (composite action) +./resolve-pr4.sh +``` + +**Note:** These scripts require GitHub push permissions. If you don't have direct push access, you'll need to fork and create new PRs or ask a maintainer to run these scripts. + +### Option 2: Use Resolved Workflow Files + +The `resolved-workflows/` directory contains the fully resolved workflow files that incorporate ALL improvements from PRs #2 and #4: + +1. **Resolved workflow files:** + - `lint.yml` - With permissions, caching, and composite action + - `typecheck.yml` - With permissions, caching, and composite action + - `tests.yml` - With permissions, caching, Python matrix, and composite action + - `setup-python-uv-action.yml` - Composite action for setup + +2. **To apply these files:** + - Copy them to the appropriate locations in the repository + - The composite action should go to `.github/actions/setup-python-uv/action.yml` + - The workflow files should go to `.github/workflows/` + +## Manual Resolution + +See `PR_CONFLICT_RESOLUTION.md` for detailed step-by-step manual resolution instructions. + +## Improvements Included + +The resolved workflows incorporate all improvements from the conflicting PRs: + +### From PR #2: +✅ `enable-cache: true` for faster CI runs +✅ `permissions: contents: read` for security +✅ Python version matrix (3.12, 3.13) for broader testing +✅ Python version in test job name for clarity + +### From PR #4: +✅ Composite action to eliminate code duplication +✅ Parameterized composite action (install-extras, python-version) +✅ Clean, maintainable workflow files + +### Bonus Enhancement: +✅ Added `python-version` parameter to composite action for matrix support + +## Recommended Action + +**For Repository Maintainers:** + +1. Review the resolved workflow files in `resolved-workflows/` +2. Either: + - Run `./resolve-pr2.sh` and `./resolve-pr4.sh` to automatically resolve conflicts, OR + - Manually apply the changes from `resolved-workflows/` to PR #1 or a new PR +3. Close PR #3 as it's no longer needed +4. Merge the resolved PRs or the enhanced PR #1 + +The end result will be a clean CI setup with: +- Separate workflows for each CI task (better status badges) +- Dependency caching (faster runs) +- Python version matrix (better compatibility testing) +- Reusable composite action (DRY principle) +- Proper security permissions diff --git a/resolved-workflows/lint.yml b/resolved-workflows/lint.yml new file mode 100644 index 0000000..98ef655 --- /dev/null +++ b/resolved-workflows/lint.yml @@ -0,0 +1,24 @@ +name: Ruff + +on: + push: + branches: [main] + pull_request: + branches: [main] + +permissions: + contents: read + +jobs: + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - name: Setup Python with uv + uses: ./.github/actions/setup-python-uv + + - name: Run Ruff check + run: uv run ruff check src/ tests/ + + - name: Run Ruff format check + run: uv run ruff format --check src/ tests/ diff --git a/resolved-workflows/setup-python-uv-action.yml b/resolved-workflows/setup-python-uv-action.yml new file mode 100644 index 0000000..83c7217 --- /dev/null +++ b/resolved-workflows/setup-python-uv-action.yml @@ -0,0 +1,36 @@ +name: Setup Python with uv +description: Set up Python environment using uv package manager + +inputs: + install-extras: + description: 'Whether to install all extras with dependencies' + required: false + default: 'false' + python-version: + description: 'Python version to install' + required: false + default: '3.12' + +runs: + using: composite + steps: + - uses: actions/checkout@v4 + + - name: Install uv + uses: astral-sh/setup-uv@v4 + with: + version: "latest" + enable-cache: true + + - name: Set up Python + shell: bash + run: uv python install ${{ inputs.python-version }} + + - name: Install dependencies + shell: bash + run: | + if [ "${{ inputs.install-extras }}" = "true" ]; then + uv sync --group dev --all-extras + else + uv sync --group dev + fi diff --git a/resolved-workflows/tests.yml b/resolved-workflows/tests.yml new file mode 100644 index 0000000..b02cc12 --- /dev/null +++ b/resolved-workflows/tests.yml @@ -0,0 +1,27 @@ +name: Tests + +on: + push: + branches: [main] + pull_request: + branches: [main] + +permissions: + contents: read + +jobs: + test: + name: Pytest - Python ${{ matrix.python-version }} + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.12", "3.13"] + steps: + - name: Setup Python with uv + uses: ./.github/actions/setup-python-uv + with: + install-extras: 'true' + python-version: ${{ matrix.python-version }} + + - name: Run tests + run: uv run pytest tests/ -v --tb=short diff --git a/resolved-workflows/typecheck.yml b/resolved-workflows/typecheck.yml new file mode 100644 index 0000000..174290a --- /dev/null +++ b/resolved-workflows/typecheck.yml @@ -0,0 +1,21 @@ +name: Mypy + +on: + push: + branches: [main] + pull_request: + branches: [main] + +permissions: + contents: read + +jobs: + typecheck: + name: Type Check + runs-on: ubuntu-latest + steps: + - name: Setup Python with uv + uses: ./.github/actions/setup-python-uv + + - name: Run Mypy + run: uv run mypy src/