Skip to content

Commit a025d9f

Browse files
Mossakaclaude
andauthored
fix: ensure labels exist before creating regression issues (#1763)
The `needs-investigation` label doesn't exist in this repo, causing the GitHub API to return 422 when the performance monitor tries to create regression issues. Add a step to ensure both labels exist before issue creation, and add error handling around the issue creation step itself. Fixes #1759 Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 853b1d8 commit a025d9f

1 file changed

Lines changed: 34 additions & 7 deletions

File tree

.github/workflows/performance-monitor.yml

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,28 @@ jobs:
8888
"| \($r.metric) | \($r.mean)\($r.unit) | \($r.median)\($r.unit) | \($r.p95)\($r.unit) | \($r.p99)\($r.unit) | \($t.target // "N/A")\(if $t then $r.unit else "" end) | \($t.critical // "N/A")\(if $t then $r.unit else "" end) |"' \
8989
benchmark-results.json >> "$GITHUB_STEP_SUMMARY"
9090
91+
- name: Ensure labels exist
92+
if: steps.check.outputs.regression_count != '0'
93+
uses: actions/github-script@v7
94+
with:
95+
script: |
96+
const labels = [
97+
{ name: 'needs-investigation', color: 'e4e669', description: 'Requires further investigation' },
98+
{ name: 'performance', color: 'd4c5f9', description: 'Performance related' },
99+
];
100+
for (const label of labels) {
101+
try {
102+
await github.rest.issues.createLabel({ owner: context.repo.owner, repo: context.repo.repo, ...label });
103+
core.info(`Created label: ${label.name}`);
104+
} catch (e) {
105+
if (e.status === 422) {
106+
core.info(`Label already exists: ${label.name}`);
107+
} else {
108+
throw e;
109+
}
110+
}
111+
}
112+
91113
- name: Create regression issue
92114
if: steps.check.outputs.regression_count != '0'
93115
uses: actions/github-script@v7
@@ -123,10 +145,15 @@ jobs:
123145
`</details>`,
124146
].join('\n');
125147
126-
await github.rest.issues.create({
127-
owner: context.repo.owner,
128-
repo: context.repo.repo,
129-
title: `Performance regression detected (${new Date().toISOString().split('T')[0]})`,
130-
body,
131-
labels: ['performance', 'needs-investigation'],
132-
});
148+
try {
149+
const issue = await github.rest.issues.create({
150+
owner: context.repo.owner,
151+
repo: context.repo.repo,
152+
title: `Performance regression detected (${new Date().toISOString().split('T')[0]})`,
153+
body,
154+
labels: ['performance', 'needs-investigation'],
155+
});
156+
core.info(`Created regression issue: ${issue.data.html_url}`);
157+
} catch (error) {
158+
core.setFailed(`Failed to create regression issue: ${error.message}`);
159+
}

0 commit comments

Comments
 (0)