[rfc] Delete devtools_check_repro workflow
With GitHub issue templates this workflow is not truly necessary and can deny other workflows from running due to a limited amount of CI workers in the pool. I propose deleting this workflow and relying on issue templates instead. ghstack-source-id: a798621f3625fa8fffaade5a987e4024553aefa0 Pull Request resolved: https://github.com/facebook/react/pull/30518
Lauren Tan committed
Jul 30, 2024 at 10:46 UTC
927ba5799a506e5f10ee71b3df8f59296550d29f
1 file changed
-208
.github/workflows/devtools_check_repro.yml
deleted
-208
@@ -1,208 +0,0 @@
1
-name: (DevTools) Check for bug repro
2
-on:
3
- issues:
4
- types: [opened, edited]
5
- issue_comment:
6
- types: [created, edited]
7
-
8
-env:
9
- TZ: /usr/share/zoneinfo/America/Los_Angeles
10
-
11
-jobs:
12
- check-repro:
13
- runs-on: ubuntu-latest
14
- steps:
15
- - uses: actions/github-script@v3
16
- with:
17
- github-token: ${{ secrets.GITHUB_TOKEN }}
18
- script: |
19
- const URL_REGEXP = /### Website or app[\r\n]+([^#]+)###/m;
20
- const REPRO_STEPS_REGEXP = /### Repro steps[\r\n]+([^#]+)###/m;
21
- const LABEL_NEEDS_MORE_INFORMATION = "Resolution: Needs More Information";
22
- const LABEL_UNCONFIRMED = "Status: Unconfirmed";
23
-
24
- function debug(...args) {
25
- core.info(args.map(JSON.stringify).join(' '));
26
- }
27
-
28
- if (context.payload.comment) {
29
- debug('Ignoring comment update.');
30
- return;
31
- }
32
-
33
- const user = context.payload.sender.login;
34
- const issue = context.payload.issue;
35
- const body = issue.body;
36
-
37
- const urlMatch = body.match(URL_REGEXP);
38
- const reproStepsMatch = body.match(REPRO_STEPS_REGEXP);
39
-
40
- const url = urlMatch !== null ? urlMatch[1].trim() : null;
41
- const reproSteps = reproStepsMatch !== null ? reproStepsMatch[1].trim() : null;
42
-
43
- if (!url || !reproSteps) {
44
- debug('This issue is not a DevTools bug report.');
45
- return;
46
- }
47
-
48
- debug(`found URL "${url}"`);
49
- debug(`found repro steps "${reproSteps}"`);
50
-
51
- async function createComment(comment) {
52
- // Format
53
- comment = comment
54
- .split("\n")
55
- .map((line) => line.trim())
56
- .join("\n")
57
- .trim();
58
-
59
- await github.issues.createComment({
60
- issue_number: context.issue.number,
61
- owner: context.repo.owner,
62
- repo: context.repo.repo,
63
- body: comment,
64
- });
65
- }
66
-
67
- async function getGitHubActionComments() {
68
- debug(`Loading existing comments...`);
69
-
70
- const comments = await github.issues.listComments({
71
- issue_number: context.issue.number,
72
- owner: context.repo.owner,
73
- repo: context.repo.repo,
74
- });
75
-
76
- return comments.data.filter(comment => {
77
- debug(`comment by user: "${comment.user.login}"`);
78
- return comment.user.login === 'github-actions[bot]';
79
- });
80
- }
81
-
82
- async function getIssueLabels() {
83
- const issues = await github.issues.listLabelsOnIssue({
84
- issue_number: context.issue.number,
85
- owner: context.repo.owner,
86
- repo: context.repo.repo,
87
- });
88
-
89
- return issues.data;
90
- }
91
-
92
- async function updateIssue(state, assignees = []) {
93
- await github.issues.update({
94
- issue_number: context.issue.number,
95
- owner: context.repo.owner,
96
- repo: context.repo.repo,
97
- state,
98
- assignees,
99
- });
100
- }
101
-
102
- async function closeWithComment(comment) {
103
- if (issue.state !== 'open') {
104
- debug(`Issue is not open`);
105
- return;
106
- }
107
-
108
- const labels = await getIssueLabels();
109
- const label = labels.find(label => label.name === LABEL_UNCONFIRMED);
110
- if (!label) {
111
- debug(`Issue was not opened via DevTools bug report template`);
112
- return;
113
- }
114
-
115
- const comments = await getGitHubActionComments();
116
- if (comments.length > 0) {
117
- debug(`Already commented on issue; won't comment again`);
118
- return;
119
- }
120
-
121
- debug(`Missing required information`);
122
-
123
- await github.issues.addLabels({
124
- issue_number: context.issue.number,
125
- owner: context.repo.owner,
126
- repo: context.repo.repo,
127
- labels: [LABEL_NEEDS_MORE_INFORMATION],
128
- });
129
-
130
- await createComment(comment);
131
- await updateIssue('closed', [user]);
132
- }
133
-
134
- async function openWithComment(comment) {
135
- if (issue.state !== 'closed') {
136
- debug(`Issue is already open`);
137
- return;
138
- }
139
-
140
- const labels = await getIssueLabels();
141
- const label = labels.find(label => label.name === LABEL_NEEDS_MORE_INFORMATION);
142
- if (!label) {
143
- debug(`Issue was not tagged as needs information`);
144
- return;
145
- }
146
-
147
- const comments = await getGitHubActionComments();
148
- if (comments.length === 0) {
149
- debug(`Issue was closed by someone else; won't reopen`);
150
- return;
151
- }
152
-
153
- debug(`Re-opening closed issue`);
154
-
155
- await github.issues.removeLabel({
156
- issue_number: context.issue.number,
157
- owner: context.repo.owner,
158
- repo: context.repo.repo,
159
- name: LABEL_NEEDS_MORE_INFORMATION,
160
- });
161
-
162
- await createComment(comment);
163
- await updateIssue('open');
164
- }
165
-
166
- const PROBABLY_NOT_A_URL_REGEX = /(^Chrome$|^Firefox$| Website)/i;
167
-
168
- const COMMENT_HEADER = `
169
- @${user}: We're sorry you've seen this error. ❤️
170
- `.trim();
171
-
172
- const COMMENT_FOOTER = `
173
- Please help us by providing a link to a CodeSandbox (https://codesandbox.io/s/new), a repository on GitHub, or a minimal code example that reproduces the problem. (Screenshots or videos can also be helpful if they help provide context on how to repro the bug.)
174
-
175
- Here are some tips for providing a minimal example: https://stackoverflow.com/help/mcve
176
-
177
- Issues without repros are automatically closed but we will re-open if you update with repro info.
178
- `.trim();
179
-
180
- if (url.includes("localhost")) {
181
- closeWithComment(`
182
- ${COMMENT_HEADER}
183
-
184
- Unfortunately the URL you provided ("localhost") is not publicly accessible. (This means that we will not be able to reproduce the problem you're reporting.)
185
-
186
- ${COMMENT_FOOTER}
187
- `);
188
- } else if (url.length < 10 || url.match(PROBABLY_NOT_A_URL_REGEX)) {
189
- closeWithComment(`
190
- ${COMMENT_HEADER}
191
-
192
- It looks like you forgot to specify a valid URL. (This means that we will not be able to reproduce the problem you're reporting.)
193
-
194
- ${COMMENT_FOOTER}
195
- `);
196
- } else if (reproSteps.length < 25) {
197
- closeWithComment(`
198
- ${COMMENT_HEADER}
199
-
200
- Unfortunately, it doesn't look like this issue has enough info for one of us to reproduce and fix it though.
201
-
202
- ${COMMENT_FOOTER}
203
- `);
204
- } else {
205
- openWithComment(`
206
- Thank you for providing repro steps! Re-opening issue now for triage.
207
- `);
208
- }