Skip to content

Commit

Permalink
Revert "Auto route issues (#799)" (#801)
Browse files Browse the repository at this point in the history
This reverts commit 04f8a2a.
  • Loading branch information
hubertdeng123 authored Jun 18, 2024
1 parent 04f8a2a commit abbc641
Show file tree
Hide file tree
Showing 17 changed files with 25 additions and 398 deletions.
90 changes: 0 additions & 90 deletions .pnp.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed .yarn/cache/uuid-npm-9.0.1-39a8442bc6-39931f6da7.zip
Binary file not shown.
15 changes: 0 additions & 15 deletions migrations/20240613121434_add-auto-routed-comments.ts

This file was deleted.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
"@types/tar": "^6.1.4",
"fastify": "^3.29.4",
"fastify-formbody": "^5.2.0",
"google-auth-library": "^9.11.0",
"js-yaml": "^4.1.0",
"knex": "^2.4.2",
"middie": "^5.3.0",
Expand Down
1 change: 0 additions & 1 deletion src/api/github/__mocks__/octokitWithRetries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ OctokitWithRetries.issues = {
createComment: jest.fn(async function (payload) {
this._comments.push(payload.body);
}),
get: jest.fn(),
update: jest.fn(),
};

Expand Down
87 changes: 3 additions & 84 deletions src/brain/issueLabelHandler/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ import { MockOctokitError } from '@api/github/__mocks__/mockError';
import * as businessHourFunctions from '@utils/businessHours';
import { db } from '@utils/db';

jest.mock('google-auth-library');

import { GoogleAuth } from 'google-auth-library';

import { issueLabelHandler } from '.';

describe('issueLabelHandler', function () {
Expand Down Expand Up @@ -134,19 +130,14 @@ describe('issueLabelHandler', function () {
);
}

async function addLabel(
label: string,
repo?: string,
state?: string,
sender?: string
) {
async function addLabel(label: string, repo?: string, state?: string) {
await createGitHubEvent(
fastify,
'issues.labeled',
makePayload({
repo,
label,
sender,
sender: undefined,
state,
author_association: undefined,
})
Expand Down Expand Up @@ -353,27 +344,6 @@ describe('issueLabelHandler', function () {
.spyOn(org, 'modifyProjectIssueField')
.mockImplementation(jest.fn());
});

beforeEach(function () {
GoogleAuth.mockImplementation(() => {
const mockResponse = {
data: {
input_text: 'input text',
predicted_label: 'Product Area: Test',
probability: 0.6,
},
};
const mockRequest = jest.fn().mockResolvedValue(mockResponse);
const mockIdTokenClient = jest
.fn()
.mockResolvedValue({ request: mockRequest });

return {
getIdTokenClient: mockIdTokenClient,
};
});
});

afterEach(function () {
jest.clearAllMocks();
});
Expand All @@ -390,41 +360,6 @@ describe('issueLabelHandler', function () {
expect(addIssueToGlobalIssuesProjectSpy).toHaveBeenCalled();
});

it('auto routes new issues that with label if probability > 0.7', async function () {
GoogleAuth.mockImplementation(() => {
const mockResponse = {
data: {
input_text: 'input text',
predicted_label: 'Product Area: Test',
probability: 0.9,
},
};
const mockRequest = jest.fn().mockResolvedValue(mockResponse);
const mockIdTokenClient = jest
.fn()
.mockResolvedValue({ request: mockRequest });

return {
getIdTokenClient: mockIdTokenClient,
};
});
await createIssue('routing-repo');
expectNotWaitingForSupport();
expectWaitingforProductOwner();
expect(org.api.issues._labels).toContain('Product Area: Test');
// Simulate GitHub adding Waiting for Product Owner Label to send webhook
await addLabel(WAITING_FOR_PRODUCT_OWNER_LABEL);
await addLabel(
'Product Area: Test',
'routing-repo',
'sentry-test-fixture-nonmember'
);
expect(org.api.issues._comments).toEqual([
'Auto-routing to @getsentry/product-owners-test for [triage](https://develop.sentry.dev/processing-tickets/#3-triage) ⏲️',
]);
expect(addIssueToGlobalIssuesProjectSpy).toHaveBeenCalled();
});

it('adds `Status: Unrouted` and `Waiting for: Support` for GTM users', async function () {
await createIssue('routing-repo', 'Troi');
expectWaitingForSupport();
Expand Down Expand Up @@ -502,22 +437,6 @@ describe('issueLabelHandler', function () {
expect(modifyProjectIssueFieldSpy).toHaveBeenCalled();
});

it.only('does not include routing comment if bot adds product area label', async function () {
await createIssue('routing-repo');
await addLabel(
'Product Area: Test',
'routing-repo',
'open',
'sentry-test-fixture-nonmember'
);
expectWaitingforProductOwner();
expect(org.api.issues._labels).toContain('Product Area: Test');
expect(org.api.issues._comments).toEqual([
'Assigning to @getsentry/support for [routing](https://open.sentry.io/triage/#2-route) ⏲️',
]);
expect(modifyProjectIssueFieldSpy).toHaveBeenCalled();
});

it('removes previous Product Area labels when re[routing](https://open.sentry.io/triage/#2-route)', async function () {
await createIssue('routing-repo');
await addLabel('Product Area: Test', 'routing-repo');
Expand Down Expand Up @@ -878,7 +797,7 @@ describe('issueLabelHandler', function () {
}
);

it.each([
it.only.each([
WAITING_FOR_PRODUCT_OWNER_LABEL,
WAITING_FOR_SUPPORT_LABEL,
WAITING_FOR_COMMUNITY_LABEL,
Expand Down
6 changes: 3 additions & 3 deletions src/brain/issueLabelHandler/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
ensureOneWaitingForLabel,
updateFollowupsOnComment,
} from './followups';
import { handleNewIssues, markNotWaitingForSupport } from './route';
import { markNotWaitingForSupport, markWaitingForSupport } from './route';
import {
markNotWaitingForProductOwner,
markWaitingForProductOwner,
Expand All @@ -19,8 +19,8 @@ export async function issueLabelHandler() {
githubEvents.on('issues.opened', markWaitingForProductOwner);
githubEvents.removeListener('issues.labeled', markNotWaitingForProductOwner);
githubEvents.on('issues.labeled', markNotWaitingForProductOwner);
githubEvents.removeListener('issues.opened', handleNewIssues);
githubEvents.on('issues.opened', handleNewIssues);
githubEvents.removeListener('issues.opened', markWaitingForSupport);
githubEvents.on('issues.opened', markWaitingForSupport);
githubEvents.removeListener('issues.labeled', markNotWaitingForSupport);
githubEvents.on('issues.labeled', markNotWaitingForSupport);
githubEvents.removeListener(
Expand Down
Loading

0 comments on commit abbc641

Please sign in to comment.