Skip to content

Commit

Permalink
Update: Don't add auto-created issues to triage board (fixes #147) (#152
Browse files Browse the repository at this point in the history
)

* Update: Don't add auto-created issues to triage board (fixes #147)

* Fix test
  • Loading branch information
nzakas authored Sep 23, 2021
1 parent 8249e8d commit 679cafd
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/plugins/add-to-triage-project/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ async function triage(context) {

const issue = context.payload.issue;

// issues with "triage:no" label are exempt
if (issue.labels.some(label => label.name === "triage:no")) {
return;
}

await context.github.projects.createCard({
column_id: NEEDS_TRIAGE_COLUMN_ID,
content_id: issue.id,
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/recurring-issues/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ function createIssueHandler({ labelTrigger, newLabels, shouldCreateNewIssue, get
const RELEASE_ISSUE_TITLE_FORMAT = "[Scheduled release for ]MMMM Do, YYYY";
const releaseIssueHandler = createIssueHandler({
labelTrigger: "release",
newLabels: ["release", "tsc agenda"],
newLabels: ["release", "tsc agenda", "triage:no"],
async shouldCreateNewIssue({ title }) {
return moment.utc(title, RELEASE_ISSUE_TITLE_FORMAT, true).isValid();
},
Expand All @@ -235,7 +235,7 @@ const releaseIssueHandler = createIssueHandler({
const TSC_MEETING_TITLE_FORMAT = "[TSC meeting ]DD-MMMM-YYYY";
const tscMeetingIssueHandler = createIssueHandler({
labelTrigger: "tsc meeting",
newLabels: ["tsc meeting"],
newLabels: ["tsc meeting", "triage:no"],
async shouldCreateNewIssue({ title }) {
return moment.utc(title, TSC_MEETING_TITLE_FORMAT, true).isValid();
},
Expand Down
43 changes: 42 additions & 1 deletion tests/plugins/add-to-triage-project/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe("add-to-triage-project", () => {
});

describe("issue opened", () => {
test("Adds the issue to the projectt", async() => {
test("Adds the issue to the project", async() => {
const addIssueToTriageProject = nock("https://api.github.com")
.post(`/projects/columns/${NEEDS_TRIAGE_COLUMN_ID}/cards`, body => {
expect(body).toEqual({
Expand Down Expand Up @@ -60,5 +60,46 @@ describe("add-to-triage-project", () => {

expect(addIssueToTriageProject.isDone()).toBeTruthy();
});

test("doesn't add the issue to the project when 'triage:no' label is present", async() => {

const addIssueToTriageProject = nock("https://api.github.com")
.post(`/projects/columns/${NEEDS_TRIAGE_COLUMN_ID}/cards`, body => {
expect(body).toEqual({
content_id: 1234,
content_type: "Issue"
});
return true;
})
.reply(200);

await bot.receive({
name: "issues",
payload: {
action: "opened",
installation: {
id: 1
},
issue: {
labels: [
{
name: "triage:no"
}
],
number: 1,
id: 1234
},
repository: {
name: "repo-test",
owner: {
login: "test"
}
}
}
});

expect(addIssueToTriageProject.isDone()).toBeFalsy();

});
});
});

0 comments on commit 679cafd

Please sign in to comment.