Skip to content

Commit 77a23ab

Browse files
authored
Simplify pull_request_template.md (#6985)
1 parent c325e5c commit 77a23ab

File tree

4 files changed

+64
-34
lines changed

4 files changed

+64
-34
lines changed

.github/pull_request_template.md

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
## What this PR solves / how to test
1+
Fixes #[insert GH or internal issue link(s)].
22

3-
Fixes #[insert GH or internal issue number(s)].
3+
_Describe your change..._
44

5-
## Author has addressed the following
5+
---
66

77
- Tests
88
- [ ] TODO (before merge)
@@ -12,10 +12,6 @@ Fixes #[insert GH or internal issue number(s)].
1212
- [ ] I don't know
1313
- [ ] Required
1414
- [ ] Not required because:
15-
- Changeset ([Changeset guidelines](https://github.com/cloudflare/workers-sdk/blob/main/CONTRIBUTING.md#changesets))
16-
- [ ] TODO (before merge)
17-
- [ ] Changeset included
18-
- [ ] Changeset not necessary because:
1915
- Public documentation
2016
- [ ] TODO (before merge)
2117
- [ ] Cloudflare docs PR(s): <!--e.g. <https://github.com/cloudflare/cloudflare-docs/pull/>...-->
@@ -25,9 +21,3 @@ Fixes #[insert GH or internal issue number(s)].
2521
Have you read our [Contributing guide](https://github.com/cloudflare/workers-sdk/blob/main/CONTRIBUTING.md)?
2622
In particular, for non-trivial changes, please always engage on the issue or create a discussion or feature request issue first before writing your code.
2723
-->
28-
29-
<!--
30-
**Note for PR author:**
31-
We want to celebrate and highlight awesome PR review!
32-
If you think this PR received a particularly high-caliber review, please assign it the label `highlight pr review` so future reviewers can take inspiration and learn from it.
33-
-->

.github/workflows/validate-pr-description.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ jobs:
2626
everything_but_markdown:
2727
- '!**/*.md'
2828
29+
- uses: jitterbit/get-changed-files@v1
30+
id: files
31+
with:
32+
format: "json"
33+
2934
- name: Install Dependencies
3035
if: steps.changes.outputs.everything_but_markdown == 'true'
3136
uses: ./.github/actions/install-dependencies
@@ -41,3 +46,4 @@ jobs:
4146
TITLE: ${{ github.event.pull_request.title }}
4247
BODY: ${{ github.event.pull_request.body }}
4348
LABELS: ${{ toJson(github.event.pull_request.labels.*.name) }}
49+
FILES: ${{ steps.files.outputs.all }}

tools/deployments/__tests__/validate-pr-description.test.ts

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { validateDescription } from "../validate-pr-description";
44
describe("validateDescription()", () => {
55
it("should skip validation with the `skip-pr-description-validation` label", () => {
66
expect(
7-
validateDescription("", "", '["skip-pr-description-validation"]')
7+
validateDescription("", "", '["skip-pr-description-validation"]', "[]")
88
).toHaveLength(0);
99
});
1010

@@ -26,28 +26,54 @@ Fixes #[insert GH or internal issue number(s)].
2626
- [ ] I don't know
2727
- [ ] Required
2828
- [ ] Not required because:
29-
- Changeset ([Changeset guidelines](https://github.com/cloudflare/workers-sdk/blob/main/CONTRIBUTING.md#changesets))
30-
- [ ] TODO (before merge)
31-
- [ ] Changeset included
32-
- [ ] Changeset not necessary because:
3329
- Public documentation
3430
- [x] TODO (before merge)
3531
- [ ] Cloudflare docs PR(s): <!--e.g. <https://github.com/cloudflare/cloudflare-docs/pull/>...-->
3632
- [ ] Documentation not necessary because:
3733
`,
34+
"[]",
3835
"[]"
3936
)
4037
).toMatchInlineSnapshot(`
4138
[
4239
"All TODO checkboxes in your PR description must be unchecked before merging",
4340
"Your PR must include tests, or provide justification for why no tests are required",
4441
"Your PR must run E2E tests, or provide justification for why running them is not required",
45-
"Your PR must include a changeset, or provide justification for why no changesets are required",
42+
"Your PR doesn't include a changeset. Either include one (following the instructions in CONTRIBUTING.md) or add the 'no-changeset-required' label to bypass this check. Most PRs should have a changeset, so only bypass this check if you're sure that your change doesn't need one: see https://github.com/cloudflare/workers-sdk/blob/main/CONTRIBUTING.md#changesets for more details.",
4643
"Your PR must include documentation (in the form of a link to a Cloudflare Docs issue or PR), or provide justification for why no documentation is required",
4744
]
4845
`);
4946
});
5047

48+
it("should bypass changesets check with label", () => {
49+
expect(
50+
validateDescription(
51+
"",
52+
`## What this PR solves / how to test
53+
54+
Fixes #[insert GH or internal issue number(s)].
55+
56+
## Author has addressed the following
57+
58+
- Tests
59+
- [ ] TODO (before merge)
60+
- [x] Tests included
61+
- [ ] Tests not necessary because:
62+
- E2E Tests CI Job required? (Use "e2e" label or ask maintainer to run separately)
63+
- [ ] I don't know
64+
- [ ] Required
65+
- [x] Not required because: test
66+
- Public documentation
67+
- [ ] TODO (before merge)
68+
- [ ] Cloudflare docs PR(s): <!--e.g. <https://github.com/cloudflare/cloudflare-docs/pull/>...-->
69+
- [x] Documentation not necessary because: test
70+
`,
71+
'["no-changeset-required"]',
72+
"[]"
73+
)
74+
).toHaveLength(0);
75+
});
76+
5177
it("should accept everything included", () => {
5278
expect(
5379
validateDescription(
@@ -75,7 +101,8 @@ Fixes [AA-000](https://jira.cfdata.org/browse/AA-000).
75101
- [x] Cloudflare docs PR(s): https://github.com/cloudflare/cloudflare-docs/pull/123
76102
- [ ] Documentation not necessary because:
77103
`,
78-
"[]"
104+
"[]",
105+
'[".changeset/hello-world.md"]'
79106
)
80107
).toHaveLength(0);
81108
});
@@ -107,7 +134,8 @@ Fixes [AA-000](https://jira.cfdata.org/browse/AA-000).
107134
- [x] Cloudflare docs PR(s): https://github.com/cloudflare/cloudflare-docs/pull/123
108135
- [ ] Documentation not necessary because:
109136
`,
110-
"[]"
137+
"[]",
138+
'[".changeset/hello-world.md"]'
111139
)
112140
).toMatchInlineSnapshot(`
113141
[
@@ -144,7 +172,8 @@ Fixes [AA-000](https://jira.cfdata.org/browse/AA-000).
144172
- [x] Cloudflare docs PR(s): https://github.com/cloudflare/cloudflare-docs/pull/123
145173
- [ ] Documentation not necessary because:
146174
`,
147-
"[]"
175+
"[]",
176+
'[".changeset/hello-world.md"]'
148177
)
149178
).toMatchInlineSnapshot(`
150179
[
@@ -180,7 +209,8 @@ Fixes [AA-000](https://jira.cfdata.org/browse/AA-000).
180209
- [x] Cloudflare docs PR(s): https://github.com/cloudflare/cloudflare-docs/pull/123
181210
- [ ] Documentation not necessary because:
182211
`,
183-
'["e2e"]'
212+
'["e2e"]',
213+
'[".changeset/hello-world.md"]'
184214
)
185215
).toHaveLength(0);
186216
});
@@ -212,7 +242,8 @@ Fixes [AA-000](https://jira.cfdata.org/browse/AA-000).
212242
- [X] Cloudflare docs PR(s): https://github.com/cloudflare/cloudflare-docs/pull/123
213243
- [ ] Documentation not necessary because:
214244
`,
215-
'["e2e"]'
245+
'["e2e"]',
246+
'[".changeset/hello-world.md"]'
216247
)
217248
).toHaveLength(0);
218249
});

tools/deployments/validate-pr-description.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ if (require.main === module) {
33
const errors = validateDescription(
44
process.env.TITLE as string,
55
process.env.BODY as string,
6-
process.env.LABELS as string
6+
process.env.LABELS as string,
7+
process.env.FILES as string
78
);
89
if (errors.length > 0) {
910
console.error("Validation errors in PR description:");
@@ -17,12 +18,14 @@ if (require.main === module) {
1718
export function validateDescription(
1819
title: string,
1920
body: string,
20-
labels: string
21+
labels: string,
22+
changedFilesJson: string
2123
) {
2224
const errors: string[] = [];
2325

2426
console.log("PR:", title);
25-
const parsedLabels = JSON.parse(labels);
27+
28+
const parsedLabels = JSON.parse(labels) as string[];
2629

2730
if (parsedLabels.includes("skip-pr-description-validation")) {
2831
console.log(
@@ -71,14 +74,14 @@ export function validateDescription(
7174
);
7275
}
7376

74-
if (
75-
!(
76-
/- \[x\] Changeset included/i.test(body) ||
77-
/- \[x\] Changeset not necessary because: .+/i.test(body)
78-
)
79-
) {
77+
const changedFiles = JSON.parse(changedFilesJson) as string[];
78+
const changesetIncluded = changedFiles.some((f) =>
79+
f.startsWith(".changeset/")
80+
);
81+
82+
if (!changesetIncluded && !parsedLabels.includes("no-changeset-required")) {
8083
errors.push(
81-
"Your PR must include a changeset, or provide justification for why no changesets are required"
84+
"Your PR doesn't include a changeset. Either include one (following the instructions in CONTRIBUTING.md) or add the 'no-changeset-required' label to bypass this check. Most PRs should have a changeset, so only bypass this check if you're sure that your change doesn't need one: see https://github.com/cloudflare/workers-sdk/blob/main/CONTRIBUTING.md#changesets for more details."
8285
);
8386
}
8487

0 commit comments

Comments
 (0)