Skip to content

Commit 4bd5bc1

Browse files
committed
feature parity workflow
1 parent 93c16e3 commit 4bd5bc1

File tree

1 file changed

+132
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)