Skip to content

Commit f90c4b0

Browse files
authored
Merge pull request #11 from duckduckgo/loremattei/check-dod
Asana Task: https://app.asana.com/0/1204165176092271/1209189118557663/f Adds a check to verify that the "Conform to Definition of Done" checkbox has been checked. Makes PR checks fail otherwise.
2 parents 8dd79f4 + ec0bc94 commit f90c4b0

File tree

2 files changed

+72
-1
lines changed

2 files changed

+72
-1
lines changed

org/allPRs.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,13 @@ export const embeddedFilesURLMismatch = async() => {
189189
await privacyConfigMismatch(repo, modifiedFiles)
190190
}
191191

192+
export const dodChecked = async () => {
193+
// Warn when DOD checkbox is not checked
194+
if (!danger.github.pr.body.toLowerCase().includes("* [x] does this pr satisfy our [definition of done]")) {
195+
fail("Please, make sure this PR satisfies our [Definition of Done](https://app.asana.com/0/1202500774821704/1207634633537039/f) and the relevant checkbox is checked.");
196+
}
197+
}
198+
192199
// Default run
193200
export default async () => {
194201
await prSize()
@@ -198,4 +205,5 @@ export default async () => {
198205
await licensedFonts()
199206
await newColors()
200207
await embeddedFilesURLMismatch()
201-
}
208+
await dodChecked()
209+
}

tests/checkDod.allPRs.test.ts

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
jest.mock("danger", () => jest.fn())
2+
import danger from 'danger'
3+
const dm = danger as any;
4+
5+
import { dodChecked } from '../org/allPRs'
6+
7+
beforeEach(() => {
8+
dm.warn = jest.fn().mockReturnValue(true);
9+
dm.fail = jest.fn().mockReturnValue(true);
10+
11+
dm.danger = {
12+
github: {
13+
pr: {
14+
body: "",
15+
}
16+
},
17+
}
18+
})
19+
20+
describe("Definition of Done checked", () => {
21+
it("does fail when Definition of Done checkbox is not in the body", async () => {
22+
var prBody = "**Steps to test this PR**:\n1.\n2.\n"
23+
prBody += "**Orientation Testing**:\n* [ ] Portrait\n* [ ] Landscape"
24+
dm.danger.github.pr.body = prBody
25+
26+
await dodChecked()
27+
28+
expect(dm.fail).toHaveBeenCalledWith("Please, make sure this PR satisfies our [Definition of Done](https://app.asana.com/0/1202500774821704/1207634633537039/f) and the relevant checkbox is checked.")
29+
})
30+
31+
it("does fail when Definition of Done checkbox is not checked", async () => {
32+
var prBody = "**Steps to test this PR**:\n1.\n2.\n"
33+
prBody += "**Definition of Done (Internal Only)**:\n* [ ] Does this PR satisfy our [Definition of Done](https://app.asana.com/0/1202500774821704/1207634633537039/f)?\n"
34+
prBody += "**Orientation Testing**:\n* [ ] Portrait\n* [ ] Landscape"
35+
dm.danger.github.pr.body = prBody
36+
37+
await dodChecked()
38+
39+
expect(dm.fail).toHaveBeenCalledWith("Please, make sure this PR satisfies our [Definition of Done](https://app.asana.com/0/1202500774821704/1207634633537039/f) and the relevant checkbox is checked.")
40+
})
41+
42+
it("does not fail when Definition of Done checkbox is checked (Lower Case)", async () => {
43+
var prBody = "**Steps to test this PR**:\n1.\n2.\n"
44+
prBody += "**Definition of Done (Internal Only)**:\n* [x] Does this PR satisfy our [Definition of Done](https://app.asana.com/0/1202500774821704/1207634633537039/f)?\n"
45+
prBody += "**Orientation Testing**:\n* [ ] Portrait\n* [ ] Landscape"
46+
dm.danger.github.pr.body = prBody
47+
48+
await dodChecked()
49+
50+
expect(dm.fail).not.toHaveBeenCalled()
51+
})
52+
53+
it("does not fail when Definition of Done checkbox is checked (Upper Case)", async () => {
54+
var prBody = "**Steps to test this PR**:\n1.\n2.\n"
55+
prBody += "**Definition of Done (Internal Only)**:\n* [X] Does this PR satisfy our [Definition of Done](https://app.asana.com/0/1202500774821704/1207634633537039/f)?\n"
56+
prBody += "**Orientation Testing**:\n* [ ] Portrait\n* [ ] Landscape"
57+
dm.danger.github.pr.body = prBody
58+
59+
await dodChecked()
60+
61+
expect(dm.fail).not.toHaveBeenCalled()
62+
})
63+
})

0 commit comments

Comments
 (0)