Skip to content

Commit 76022d7

Browse files
authored
Merge pull request #5 from Abstract-Data/copilot/resolve-pr-conflicts
Resolve merge conflicts in PRs #2, #3, and #4
2 parents 7fc0b43 + 235e131 commit 76022d7

10 files changed

Lines changed: 1062 additions & 0 deletions

File tree

PR_CONFLICT_RESOLUTION.md

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
# Pull Request Conflict Resolution Guide
2+
3+
This document provides step-by-step instructions to resolve merge conflicts in PRs #2, #3, and #4.
4+
5+
## Root Cause
6+
7+
The base branch `ci/add-github-workflows` split the single `ci.yml` workflow into three separate workflow files:
8+
- `.github/workflows/lint.yml` (Ruff linting)
9+
- `.github/workflows/typecheck.yml` (Mypy type checking)
10+
- `.github/workflows/tests.yml` (Pytest tests)
11+
12+
PRs #2, #3, and #4 all modify the original `ci.yml` file, which no longer exists in the base branch, causing merge conflicts.
13+
14+
## PR #2: Improve CI workflow with dependency caching and Python version matrix
15+
16+
**Changes to Apply:**
17+
- Add `permissions: contents: read` to all three workflow files
18+
- Add `enable-cache: true` to uv setup in all three workflows
19+
- Add Python version matrix (`["3.12", "3.13"]`) to tests.yml
20+
- Update test job name to include Python version: `Pytest - Python ${{ matrix.python-version }}`
21+
- Update Python installation in tests.yml to use matrix variable: `uv python install ${{ matrix.python-version }}`
22+
23+
### Resolution Steps:
24+
25+
1. Checkout the branch:
26+
```bash
27+
git checkout copilot/sub-pr-1
28+
git merge ci/add-github-workflows
29+
```
30+
31+
2. Remove the conflicted ci.yml:
32+
```bash
33+
git rm .github/workflows/ci.yml
34+
```
35+
36+
3. Apply the improvements to each new workflow file:
37+
38+
**lint.yml:**
39+
- Add `permissions: contents: read` after the `on:` section
40+
- Add `enable-cache: true` to the uv setup step
41+
42+
**typecheck.yml:**
43+
- Add `permissions: contents: read` after the `on:` section
44+
- Add `enable-cache: true` to the uv setup step
45+
46+
**tests.yml:**
47+
- Add `permissions: contents: read` after the `on:` section
48+
- Add `enable-cache: true` to the uv setup step
49+
- Add matrix strategy with Python 3.12 and 3.13
50+
- Update job name to include version
51+
- Use matrix Python version in setup step
52+
53+
4. Commit and push:
54+
```bash
55+
git add .
56+
git commit -m "Resolve merge conflict: Apply PR #2 improvements to split workflow files"
57+
git push origin copilot/sub-pr-1
58+
```
59+
60+
## PR #3: Remove trailing blank line from CI workflow
61+
62+
**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.
63+
64+
**Resolution:** Close this PR as the formatting issue has been resolved in the split workflow files.
65+
66+
### Resolution Steps:
67+
68+
1. Close PR #3 with a comment explaining that the formatting issue was resolved during the workflow split.
69+
70+
## PR #4: Extract duplicated CI setup steps into composite action
71+
72+
**Changes to Apply:**
73+
- Create `.github/actions/setup-python-uv/action.yml` composite action
74+
- Update all three workflow files to use the composite action
75+
- Add `install-extras` parameter to the composite action (default: false)
76+
- Test workflow should pass `install-extras: 'true'`
77+
78+
### Resolution Steps:
79+
80+
1. Checkout the branch:
81+
```bash
82+
git checkout copilot/sub-pr-1-another-one
83+
git merge ci/add-github-workflows
84+
```
85+
86+
2. Remove the conflicted ci.yml:
87+
```bash
88+
git rm .github/workflows/ci.yml
89+
```
90+
91+
3. Create the composite action `.github/actions/setup-python-uv/action.yml`:
92+
```yaml
93+
name: Setup Python with uv
94+
description: Set up Python environment using uv package manager
95+
96+
inputs:
97+
install-extras:
98+
description: 'Whether to install all extras with dependencies'
99+
required: false
100+
default: 'false'
101+
102+
runs:
103+
using: composite
104+
steps:
105+
- uses: actions/checkout@v4
106+
107+
- name: Install uv
108+
uses: astral-sh/setup-uv@v4
109+
with:
110+
version: "latest"
111+
112+
- name: Set up Python
113+
shell: bash
114+
run: uv python install 3.12
115+
116+
- name: Install dependencies
117+
shell: bash
118+
run: |
119+
if [ "${{ inputs.install-extras }}" = "true" ]; then
120+
uv sync --group dev --all-extras
121+
else
122+
uv sync --group dev
123+
fi
124+
```
125+
126+
4. Update each workflow file to use the composite action:
127+
128+
**lint.yml:**
129+
```yaml
130+
steps:
131+
- name: Setup Python with uv
132+
uses: ./.github/actions/setup-python-uv
133+
134+
- name: Run Ruff check
135+
run: uv run ruff check src/ tests/
136+
137+
- name: Run Ruff format check
138+
run: uv run ruff format --check src/ tests/
139+
```
140+
141+
**typecheck.yml:**
142+
```yaml
143+
steps:
144+
- name: Setup Python with uv
145+
uses: ./.github/actions/setup-python-uv
146+
147+
- name: Run Mypy
148+
run: uv run mypy src/
149+
```
150+
151+
**tests.yml:**
152+
```yaml
153+
steps:
154+
- name: Setup Python with uv
155+
uses: ./.github/actions/setup-python-uv
156+
with:
157+
install-extras: 'true'
158+
159+
- name: Run tests
160+
run: uv run pytest tests/ -v --tb=short
161+
```
162+
163+
5. Commit and push:
164+
```bash
165+
git add .
166+
git commit -m "Resolve merge conflict: Apply composite action to split workflow files"
167+
git push origin copilot/sub-pr-1-another-one
168+
```
169+
170+
## Recommended Merge Order
171+
172+
To avoid future conflicts, merge PRs in this order:
173+
174+
1. **PR #1** - Base CI workflows (already mergeable, no conflicts)
175+
2. **PR #2** - Add caching and Python matrix (after resolving conflicts per above)
176+
3. **Close PR #3** - No longer needed after split
177+
4. **PR #4** - Add composite action (after resolving conflicts per above, can be merged after PR #2)
178+
179+
## Alternative: Combined Resolution
180+
181+
Instead of resolving each PR separately, consider combining the best features of all PRs into a single update to PR #1:
182+
183+
1. Start with the split workflows from PR #1
184+
2. Add caching and permissions from PR #2
185+
3. Add Python version matrix from PR #2
186+
4. Add composite action from PR #4
187+
5. Close PRs #2, #3, #4 as superseded
188+
189+
This would result in clean, optimized workflows with all improvements applied without conflicts.

SCRIPTS-README.md

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# Conflict Resolution Scripts
2+
3+
This directory contains automated scripts to resolve merge conflicts in pull requests.
4+
5+
## Quick Start
6+
7+
```bash
8+
# Resolve PR #2
9+
./resolve-pr2.sh
10+
11+
# Resolve PR #4
12+
./resolve-pr4.sh
13+
```
14+
15+
## What These Scripts Do
16+
17+
### `resolve-pr2.sh`
18+
Resolves conflicts in **PR #2: Improve CI workflow with dependency caching and Python version matrix**
19+
20+
**Actions:**
21+
1. Checks out branch `copilot/sub-pr-1`
22+
2. Merges `ci/add-github-workflows` (creates expected conflicts)
23+
3. Removes old `ci.yml` file
24+
4. Creates new split workflow files with these improvements:
25+
- `enable-cache: true` for faster CI runs
26+
- `permissions: contents: read` for security
27+
- Python version matrix (3.12, 3.13) in tests
28+
5. Commits and pushes the resolution
29+
30+
### `resolve-pr4.sh`
31+
Resolves conflicts in **PR #4: Extract duplicated CI setup steps into composite action**
32+
33+
**Actions:**
34+
1. Checks out branch `copilot/sub-pr-1-another-one`
35+
2. Merges `ci/add-github-workflows` (creates expected conflicts)
36+
3. Removes old `ci.yml` file
37+
4. Creates composite action `.github/actions/setup-python-uv/`
38+
5. Creates new split workflow files using the composite action
39+
6. Includes all improvements from PR #2
40+
7. Commits and pushes the resolution
41+
42+
## Prerequisites
43+
44+
- Git repository cloned locally
45+
- Write access to push to `copilot/sub-pr-1` and `copilot/sub-pr-1-another-one` branches
46+
- All remote branches fetched (`git fetch --all`)
47+
48+
## Error Handling
49+
50+
Both scripts include robust error handling:
51+
- ✅ Verbose logging of each step
52+
- ✅ Verification that expected conflicts exist
53+
- ✅ Graceful handling of missing files
54+
- ✅ Automatic rollback on unexpected conditions
55+
- ✅ Clear error messages for debugging
56+
57+
## Troubleshooting
58+
59+
### "Could not reset to origin"
60+
This warning is informational. The script will use the current HEAD instead. This happens if you haven't fetched the remote branch.
61+
62+
**Solution:**
63+
```bash
64+
git fetch --all
65+
```
66+
67+
### "Error: Expected conflicts but none found"
68+
This means the branches have already been merged or the conflict was already resolved.
69+
70+
**Solution:** Check the PR status on GitHub. If it's already mergeable, you don't need to run the script.
71+
72+
### "Error: Merge completed without conflicts"
73+
This is unexpected and suggests the branches are already compatible.
74+
75+
**Solution:** Check if the PR was already resolved manually.
76+
77+
### "Authentication failed"
78+
The scripts require push permissions to the repository.
79+
80+
**Solution:** Ensure you have write access and your Git credentials are configured.
81+
82+
## Manual Alternative
83+
84+
If you prefer not to use the scripts, see:
85+
- `PR_CONFLICT_RESOLUTION.md` for step-by-step manual instructions
86+
- `resolved-workflows/` for pre-resolved workflow files you can copy
87+
88+
## Testing the Scripts
89+
90+
To test the scripts without pushing:
91+
92+
1. Comment out the `git push` line in the script
93+
2. Run the script
94+
3. Review the changes with `git diff --cached`
95+
4. If satisfied, manually push with `git push origin <branch-name>`
96+
97+
## What Happens After Running
98+
99+
After running the scripts:
100+
1. Check the PR on GitHub - conflicts should be resolved
101+
2. The PR should show as "mergeable"
102+
3. Review the changes in the PR
103+
4. Merge when ready
104+
105+
## Script Output Example
106+
107+
```
108+
Resolving conflicts in PR #2 (copilot/sub-pr-1)...
109+
Resetting branch to clean state...
110+
Reset to origin/copilot/sub-pr-1
111+
Merging ci/add-github-workflows...
112+
Merge conflicts detected (expected). Proceeding with resolution...
113+
Conflicted files: .github/workflows/ci.yml
114+
Removing conflicted ci.yml...
115+
Creating resolved workflow files...
116+
Staging changes...
117+
Committing resolution...
118+
Pushing to origin...
119+
PR #2 conflicts resolved and pushed successfully!
120+
```
121+
122+
## Support
123+
124+
If you encounter issues:
125+
1. Check the error message for specific guidance
126+
2. Review `SUMMARY.md` for overall context
127+
3. See `PR_CONFLICT_RESOLUTION.md` for manual steps
128+
4. Open an issue in the repository

0 commit comments

Comments
 (0)