Skip to content

Commit 252a68b

Browse files
committed
feature parity workflow
1 parent de936ed commit 252a68b

File tree

1 file changed

+135
-0
lines changed

1 file changed

+135
-0
lines changed

.github/workflows/feature-parity.yml

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
name: Feature Parity
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- synchronize
8+
- labeled
9+
- unlabeled
10+
paths-ignore:
11+
- "docs/**"
12+
13+
jobs:
14+
check-parity-label:
15+
runs-on: ubuntu-latest
16+
if: github.event.action == 'labeled' && github.event.label.name == 'parity'
17+
steps:
18+
- name: Check out repository code
19+
uses: actions/checkout@v4
20+
21+
- name: Check user permissions
22+
uses: actions/github-script@v7
23+
with:
24+
github-token: ${{ secrets.GITHUB_TOKEN }}
25+
script: |
26+
const { data: permission } = await github.rest.repos.getCollaboratorPermissionLevel({
27+
owner: context.repo.owner,
28+
repo: context.repo.repo,
29+
username: context.actor
30+
});
31+
32+
const hasWriteAccess = ['admin', 'write'].includes(permission.permission);
33+
34+
if (!hasWriteAccess) {
35+
// Remove the parity label if user doesn't have write access
36+
await github.rest.issues.removeLabel({
37+
owner: context.repo.owner,
38+
repo: context.repo.repo,
39+
issue_number: context.issue.number,
40+
name: 'parity'
41+
});
42+
43+
// Add a comment explaining why the label was removed
44+
await github.rest.issues.createComment({
45+
owner: context.repo.owner,
46+
repo: context.repo.repo,
47+
issue_number: context.issue.number,
48+
body: `❌ **Parity Label Removed**\n\n@${context.actor}, you do not have sufficient permissions to add the 'parity' label. Only users with write access can trigger feature parity issues.\n\nIf you believe this feature should be implemented in the Python SDK, please ask a maintainer to add the label.`
49+
});
50+
51+
throw new Error(`User ${context.actor} does not have write access to add parity label`);
52+
}
53+
54+
console.log(`User ${context.actor} has ${permission.permission} access - proceeding with parity workflow`);
55+
56+
- name: Create issue in Python SDK repository
57+
uses: actions/github-script@v7
58+
with:
59+
github-token: ${{ secrets.PYTHON_REPO_TOKEN }}
60+
script: |
61+
const { data: pullRequest } = await github.rest.pulls.get({
62+
owner: context.repo.owner,
63+
repo: context.repo.repo,
64+
pull_number: context.issue.number,
65+
});
66+
67+
// Get PR comments for additional context
68+
const { data: comments } = await github.rest.issues.listComments({
69+
owner: context.repo.owner,
70+
repo: context.repo.repo,
71+
issue_number: context.issue.number,
72+
});
73+
74+
// Format comments for the issue description
75+
let commentsSection = '';
76+
if (comments.length > 0) {
77+
commentsSection = '\n\n## Recent Comments\n\n';
78+
comments.slice(-3).forEach(comment => {
79+
commentsSection += `**@${comment.user.login}** commented:\n`;
80+
commentsSection += `${comment.body.substring(0, 500)}${comment.body.length > 500 ? '...' : ''}\n\n`;
81+
});
82+
}
83+
84+
// Get list of changed files for context
85+
const { data: files } = await github.rest.pulls.listFiles({
86+
owner: context.repo.owner,
87+
repo: context.repo.repo,
88+
pull_number: context.issue.number,
89+
});
90+
91+
const changedFiles = files.map(file => `- \`${file.filename}\``).join('\n');
92+
93+
const issueTitle = `[Feature Parity] ${pullRequest.title}`;
94+
const issueBody = `## Feature Parity Request
95+
96+
This issue was automatically created from a pull request in the TypeScript Stagehand repository that was labeled with 'parity'.
97+
98+
### Original PR Details
99+
- **PR**: #${context.issue.number} - ${pullRequest.title}
100+
- **Author**: @${pullRequest.user.login}
101+
- **Link**: ${pullRequest.html_url}
102+
103+
### Description
104+
${pullRequest.body || 'No description provided.'}
105+
106+
### Changed Files
107+
${changedFiles}
108+
109+
${commentsSection}
110+
111+
### Action Required
112+
Please review the changes in the original PR and implement equivalent functionality in the Python SDK if applicable.
113+
114+
---
115+
*This issue was automatically generated by the Feature Parity workflow.*`;
116+
117+
// Create the issue in the Python repository
118+
const { data: issue } = await github.rest.issues.create({
119+
owner: 'browserbase',
120+
repo: 'stagehand-python',
121+
title: issueTitle,
122+
body: issueBody,
123+
labels: ['feature-parity']
124+
});
125+
126+
console.log(`Created issue: ${issue.html_url}`);
127+
128+
// Add a comment to the original PR confirming the issue was created
129+
await github.rest.issues.createComment({
130+
owner: context.repo.owner,
131+
repo: context.repo.repo,
132+
issue_number: context.issue.number,
133+
body: `🔄 **Feature Parity Issue Created**\n\nAn issue has been automatically created in the Python SDK repository to track parity implementation:\n${issue.html_url}`
134+
});
135+

0 commit comments

Comments
 (0)