Flaky-test bot: reopen existing issues (#12727)

If a test becomes flaky again, reopen the old issue.
This commit is contained in:
Richard van der Hoff 2024-07-04 11:24:15 +01:00 committed by GitHub
parent e48110d7c6
commit de12d69e6b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -53,7 +53,10 @@ class FlakyReporter implements Reporter {
const headers = { Authorization: `Bearer ${GITHUB_TOKEN}` };
// Fetch all existing issues with the flaky-test label.
const issuesRequest = await fetch(`${GITHUB_API_URL}/repos/${REPO}/issues?labels=${LABEL}`, { headers });
const issuesRequest = await fetch(
`${GITHUB_API_URL}/repos/${REPO}/issues?labels=${LABEL}&state=all&per_page=100&sort=created`,
{ headers },
);
const issues = await issuesRequest.json();
for (const flake of this.flakes) {
const title = ISSUE_TITLE_PREFIX + "`" + flake + "`";
@ -61,6 +64,12 @@ class FlakyReporter implements Reporter {
if (existingIssue) {
console.log(`Found issue ${existingIssue.number} for ${flake}, adding comment...`);
// Ensure that the test is open
await fetch(existingIssue.url, {
method: "PATCH",
headers,
body: JSON.stringify({ state: "open" }),
});
await fetch(`${existingIssue.url}/comments`, {
method: "POST",
headers,