Skip to content

Commit 4573a38

Browse files
feat(ci): Update PR checks (#8056)
* Fix missing ready_for_review event * Add issue liking keyword detection * Replace the checklist by a simple list as the workflow does most of the checks automatically * Remove the squash your commits entry from the checklist as it is now enforced in GitHub repository settings
1 parent 11a429c commit 4573a38

10 files changed

+44
-14
lines changed

.github/pull_request_template.md

+4-5
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@
66

77
# Contributor Checklist
88

9-
- [ ] Format the title [according the contribution guidelines](https://github.com/DataDog/dd-trace-java/blob/master/CONTRIBUTING.md#title-format)
10-
- [ ] Assign the `type:` and (`comp:` or `inst:`) labels in addition to [any usefull labels](https://github.com/DataDog/dd-trace-java/blob/master/CONTRIBUTING.md#labels)
11-
- [ ] Squash your commits prior merging or merge using GitHub's [Squash and merge](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/incorporating-changes-from-a-pull-request/about-pull-request-merges#squash-and-merge-your-commits)
12-
- [ ] Don't use `close`, `fix` or any [linking keywords](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword) when referencing an issue.
9+
- Format the title [according the contribution guidelines](https://github.com/DataDog/dd-trace-java/blob/master/CONTRIBUTING.md#title-format)
10+
- Assign the `type:` and (`comp:` or `inst:`) labels in addition to [any usefull labels](https://github.com/DataDog/dd-trace-java/blob/master/CONTRIBUTING.md#labels)
11+
- Don't use `close`, `fix` or any [linking keywords](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword) when referencing an issue.
1312
Use `solves` instead, and assign the PR [milestone](https://github.com/DataDog/dd-trace-java/milestones) to the issue
14-
- [ ] Update the [public documentation](https://docs.datadoghq.com/tracing/trace_collection/library_config/java/) in case of new configuration flag or behavior
13+
- Update the [public documentation](https://docs.datadoghq.com/tracing/trace_collection/library_config/java/) in case of new configuration flag or behavior
1514

1615
Jira ticket: [PROJ-IDENT]
1716

.github/workflows/check-pull-requests.yaml

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Check pull requests
22
on:
33
pull_request:
4-
types: [opened, edited, labeled, unlabeled]
4+
types: [opened, edited, ready_for_review, labeled, unlabeled]
55
branches:
66
- master
77
- release/v*
@@ -38,14 +38,22 @@ jobs:
3838
if (titleCheckFailed) {
3939
core.setFailed('Please remove the tag from the pull request title.')
4040
}
41+
// Check body does
42+
const linkingKeywords = ['closes', 'closed', 'fix', 'fixes', 'fixed', 'resolve', 'resolves', 'resolved']
43+
const body = context.payload.pull_request.body
44+
const bodyCheckFailed = linkingKeywords.some(keyword => body.search(new RegExp(`${keyword}\\s\\d+`, "im")) !== -1)
45+
if (bodyCheckFailed) {
46+
core.setFailed('Please remove the issue linking keyword from the pull request body.')
47+
}
4148
// Add comment to the pull request
42-
if (labelsCheckFailed || titleCheckFailed) {
49+
if (labelsCheckFailed || titleCheckFailed || bodyCheckFailed) {
4350
// Define comment body
4451
const commentMarker = '<!-- dd-trace-java-check-pull-requests-workflow -->'
4552
const commentBody = 'Hi! 👋 Thanks for your pull request! 🎉\n\n' +
4653
'To help us review it, please make sure to:\n\n' +
4754
(labelsCheckFailed ? '* Add at least one type, and one component or instrumentation label to the pull request\n' : '') +
4855
(titleCheckFailed ? '* Remove the tag from the pull request title\n' : '') +
56+
(bodyCheckFailed ? '* Remove the issue linking keyword\n' : '') +
4957
'\nIf you need help, please check our [contributing guidelines](https://github.com/DataDog/dd-trace-java/blob/master/CONTRIBUTING.md).' +
5058
'\n\n' + commentMarker
5159
// Look for previous comment

.github/workflows/tests/check-pull-requests/payload-pull-request-draft.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"number": 7884,
44
"draft": true,
55
"labels": [],
6-
"title": "Adding some new features"
6+
"title": "Adding some new features",
7+
"body": "# What Does This Do\n\nThis PR introduces a workflow that checks PRs contributing guidelines."
78
}
89
}

.github/workflows/tests/check-pull-requests/payload-pull-request-instrumentation.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"name": "type: bug"
1111
}
1212
],
13-
"title": "Adding some new features"
13+
"title": "Adding some new features",
14+
"body": "# What Does This Do\n\nThis PR introduces a workflow that checks PRs contributing guidelines."
1415
}
1516
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"pull_request": {
3+
"number": 7884,
4+
"draft": false,
5+
"labels": [
6+
{
7+
"name": "comp: api"
8+
},
9+
{
10+
"name": "type: enhancement"
11+
}
12+
],
13+
"title": "Adding some new features",
14+
"body": "# What Does This Do\n\nThis PR introduces a workflow to check that PRs labels and title match the contributing guidelines.\nIt fixes #1234 amoung other issues."
15+
}
16+
}

.github/workflows/tests/check-pull-requests/payload-pull-request-missing-label.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"name": "comp: api"
88
}
99
],
10-
"title": "Adding some new features"
10+
"title": "Adding some new features",
11+
"body": "# What Does This Do\n\nThis PR introduces a workflow that checks PRs contributing guidelines."
1112
}
1213
}

.github/workflows/tests/check-pull-requests/payload-pull-request-no-release-notes.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"name": "tag: no release notes"
88
}
99
],
10-
"title": "Adding some new features"
10+
"title": "Adding some new features",
11+
"body": "# What Does This Do\n\nThis PR introduces a workflow that checks PRs contributing guidelines."
1112
}
1213
}

.github/workflows/tests/check-pull-requests/payload-pull-request-title-tag.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"name": "type: enhancement"
1111
}
1212
],
13-
"title": "[API] Adding some new features"
13+
"title": "[API] Adding some new features",
14+
"body": "# What Does This Do\n\nThis PR introduces a workflow that checks PRs contributing guidelines."
1415
}
1516
}

.github/workflows/tests/check-pull-requests/payload-pull-request.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"name": "type: enhancement"
1111
}
1212
],
13-
"title": "Adding some new features"
13+
"title": "Adding some new features",
14+
"body": "# What Does This Do\n\nThis PR introduces a workflow that checks PRs contributing guidelines."
1415
}
1516
}

.github/workflows/tests/check-pull-requests/test-pull-request.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ testworkflow pull_request instrumentation && \
55
testworkflow pull_request draft && \
66
testworkflow pull_request no-release-notes && \
77
! testworkflow pull_request missing-label && \
8-
! testworkflow pull_request title-tag
8+
! testworkflow pull_request title-tag && \
9+
! testworkflow pull_request linking-issue

0 commit comments

Comments
 (0)