-
Notifications
You must be signed in to change notification settings - Fork 0
Resolve merge conflicts in PRs #2, #3, and #4 #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
dc2af23
Initial plan
Copilot 80ab621
Add complete conflict resolution materials for PRs #2, #3, #4
Copilot 45bd6ca
Add comprehensive summary and improved resolution scripts
Copilot 9818bd4
Improve resolution scripts with better error handling
Copilot 235e131
Add scripts README and finalize documentation
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 <branch-name>` | ||
|
|
||
| ## 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 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The composite action example includes a checkout step at line 105, but the workflow examples (lines 128-161) don't include an initial checkout step before calling the composite action. This creates a chicken-and-egg problem where the workflow cannot access the composite action without first checking out the repository.
Either remove the checkout from the composite action definition, or add
- uses: actions/checkout@v4as the first step in each workflow example before calling the composite action.