-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
191 lines (159 loc) · 6.75 KB
/
issue-labeler.yml
File metadata and controls
191 lines (159 loc) · 6.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
name: Issue Form Labeler
on:
issues:
types: [ opened ]
permissions:
contents: read
jobs:
label-issues:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- uses: actions/checkout@v6
- name: Parse bug report form
id: bug-parser
uses: stefanbuck/github-issue-parser@v3
with:
template-path: .github/ISSUE_TEMPLATE/bug-report.yml
continue-on-error: true
- name: Parse feature proposal form
id: feature-parser
uses: stefanbuck/github-issue-parser@v3
with:
template-path: .github/ISSUE_TEMPLATE/feature_proposal.yml
continue-on-error: true
- name: Apply labels from bug report
uses: redhat-plumbers-in-action/advanced-issue-labeler@v3
with:
issue-form: ${{ steps.bug-parser.outputs.jsonString }}
token: ${{ secrets.GITHUB_TOKEN }}
config-path: .github/issue-labeler-config.yml
continue-on-error: true
- name: Apply labels from feature proposal
uses: redhat-plumbers-in-action/advanced-issue-labeler@v3
with:
issue-form: ${{ steps.feature-parser.outputs.jsonString }}
token: ${{ secrets.GITHUB_TOKEN }}
config-path: .github/issue-labeler-config.yml
continue-on-error: true
- name: Clean up labeled sections
uses: actions/github-script@v9
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const issueNumber = context.issue.number;
const originalBody = context.payload.issue.body;
const owner = context.repo.owner;
const repo = context.repo.repo;
const headingsToRemove = [
'### What version of Selenium are you currently using?',
'### The following statements are true',
'### Did this work for you before?',
'### If yes, what version of Selenium did it work with?',
'### Operating System',
'### Selenium Language Binding',
'### Which browsers are you experiencing the issue with?',
'### Are you using Selenium Grid?',
'### Does this apply to specific language bindings?',
'### What part(s) of Selenium does this relate to?'
];
const form = JSON.parse(process.env.FORM_JSON || '{}');
const lastGood = form?.["last-good"]?.trim();
// Conditionally remove Debugging Logs
const logs = form?.logs?.trim();
const isLogsEmpty = !logs || logs === '```logs\n\n```' || logs === '```logs```';
if (isLogsEmpty) {
headingsToRemove.push('### Debugging Logs');
}
const lines = originalBody.split(/\r?\n/);
const cleanedLines = [];
let skip = false;
for (let i = 0; i < lines.length; i++) {
const line = lines[i];
const trimmed = line.trim();
if (headingsToRemove.includes(trimmed)) {
skip = true;
continue;
}
if (skip) {
if (trimmed.startsWith('###')) {
skip = false;
i--; // Reprocess this heading
}
continue;
}
cleanedLines.push(line);
}
let finalBody = cleanedLines.join('\n').trim();
if (lastGood) {
finalBody += `\n\n---\nℹ️ **Last known working version:** \`${lastGood}\``;
}
await github.rest.issues.update({
owner,
repo,
issue_number: issueNumber,
body: finalBody
});
env:
FORM_JSON: ${{ steps.bug-parser.outputs.jsonString }}
- name: Get latest Selenium version
id: get-version
uses: actions/github-script@v9
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { data: latestRelease } = await github.rest.repos.getLatestRelease({
owner: 'SeleniumHQ',
repo: 'selenium'
});
const latestTag = latestRelease.tag_name;
const versionMatch = latestTag.match(/[vV]?(?:selenium-)?(\d+\.\d+(?:\.\d+)?)/);
if (!versionMatch) {
core.setFailed(`Couldn't parse version from tag: ${latestTag}`);
return;
}
const fullVersion = versionMatch[1];
const [major, minor] = fullVersion.split('.');
const latestVersion = `${major}.${minor}`;
console.log(`Latest version: ${latestVersion}`);
core.setOutput('version', latestVersion);
- name: Compare user version
id: version-check
uses: actions/github-script@v9
with:
script: |
const form = JSON.parse(process.env.FORM_JSON || '{}');
const userVersion = form?.["selenium-version"]?.trim() || "";
const latest = process.env.LATEST_VERSION;
const [umaj, umin] = userVersion.split('.').map(n => parseInt(n, 10));
const [lmaj, lmin] = latest.split('.').map(n => parseInt(n, 10));
const isOutdated = umaj < lmaj || (umaj === lmaj && umin < lmin);
core.setOutput("user-version", userVersion);
core.setOutput("latest-version", latest);
core.setOutput("is-outdated", isOutdated);
env:
FORM_JSON: ${{ steps.bug-parser.outputs.jsonString }}
LATEST_VERSION: ${{ steps.get-version.outputs.version }}
- name: Comment if version is outdated
id: comment-version
if: steps.version-check.outputs.is-outdated == 'true'
uses: peter-evans/create-or-update-comment@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.issue.number }}
body: |
⚠️ You reported using Selenium version `${{ steps.version-check.outputs.user-version }}`, but the latest release is `${{ steps.version-check.outputs.latest-version }}`.
Please verify that this issue still occurs with the latest version. If it no longer applies, you can close this issue or update your comment.
*This issue will be marked "awaiting answer" and may be closed automatically if no response is received.*
- name: Add label
if: steps.version-check.outputs.is-outdated == 'true'
uses: actions-ecosystem/action-add-labels@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
labels: J-awaiting answer
- name: Remove label
if: steps.version-check.outputs.is-outdated == 'true'
uses: actions-ecosystem/action-remove-labels@v1
with:
labels: A-needs-triaging