Skip to content

Commit a08d00e

Browse files
authored
Merge branch 'master' into dougqh/advice-annotation-checking
2 parents 1e6c3ca + 31bfaf7 commit a08d00e

File tree

140 files changed

+5300
-325
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+5300
-325
lines changed

.circleci/render_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
}
2929
# Version to use for all the base Docker images, see
3030
# https://github.com/DataDog/dd-trace-java-docker-build/pkgs/container/dd-trace-java-docker-build
31-
DOCKER_IMAGE_VERSION="v24.08"
31+
DOCKER_IMAGE_VERSION="v24.10"
3232

3333
# Get labels from pull requests to override some defaults for jobs to run.
3434
# `run-tests: all` will run all tests.

.github/workflows/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ _Action:_ Append the new release to the Cloud Foundry repository.
2020

2121
_Recovery:_ Manually edit and push the `index.yml` file from [the cloudfoundry branch](https://github.com/DataDog/dd-trace-java/tree/cloudfoundry).
2222

23+
### check-pull-requests [🔗](check-pull-requests.yaml)
24+
25+
_Trigger:_ When creating or updating a pull request.
26+
27+
_Action:_ Check the pull request complies with [the contribution guidelines](https://github.com/DataDog/dd-trace-java/blob/master/CONTRIBUTING.md).
28+
29+
_Recovery:_ Manually verify the guideline compliance.
30+
2331
### create-next-milestone [🔗](create-next-milestone.yaml)
2432

2533
_Trigger:_ When closing a milestone.

.github/workflows/analyze-changes.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ jobs:
140140
output: 'trivy-results.sarif'
141141
severity: 'CRITICAL,HIGH'
142142
limit-severities-for-sarif: true
143+
env:
144+
TRIVY_DB_REPOSITORY: ghcr.io/aquasecurity/trivy-db,public.ecr.aws/aquasecurity/trivy-db
145+
TRIVY_JAVA_DB_REPOSITORY: ghcr.io/aquasecurity/trivy-java-db,public.ecr.aws/aquasecurity/trivy-java-db
143146

144147
- name: Upload Trivy scan results to GitHub Security tab
145148
uses: github/codeql-action/upload-sarif@4dd16135b69a43b6c8efb853346f8437d92d3c93 # v3.26.6
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Check pull requests
2+
on:
3+
pull_request:
4+
types: [opened, edited, labeled, unlabeled]
5+
branches:
6+
- master
7+
- release/v*
8+
jobs:
9+
check_pull_requests:
10+
name: Check pull requests
11+
permissions:
12+
issues: write # Required to create a comment on the pull request
13+
pull-requests: write # Required to create a comment on the pull request
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Check pull requests
17+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # 7.0.1
18+
with:
19+
github-token: ${{secrets.GITHUB_TOKEN}}
20+
script: |
21+
// Skip draft pull requests
22+
if (context.payload.pull_request.draft) {
23+
return
24+
}
25+
// Check at least one type and (component or instrumentation) label is set
26+
const labels = context.payload.pull_request.labels.map(label => label.name)
27+
const ignoreReleaseNotes = labels.filter(label => label == 'tag: no release notes').length > 0
28+
const hasTypeLabel = labels.filter(label => label.startsWith('type:')).length > 0
29+
const hasComponentLabel = labels.filter(label => label.startsWith('comp:')).length > 0
30+
const hasInstrumentationLabel = labels.filter(label => label.startsWith('instr:')).length > 0
31+
const labelsCheckFailed = !ignoreReleaseNotes && (!hasTypeLabel || (!hasComponentLabel && !hasInstrumentationLabel));
32+
if (labelsCheckFailed) {
33+
core.setFailed('Please add at least one type, and one component or instrumentation label to the pull request.')
34+
}
35+
// Check title does not contain tag
36+
const title = context.payload.pull_request.title
37+
const titleCheckFailed = title.match(/\[.*\]/)
38+
if (titleCheckFailed) {
39+
core.setFailed('Please remove the tag from the pull request title.')
40+
}
41+
// Add comment to the pull request
42+
if (labelsCheckFailed || titleCheckFailed) {
43+
// Define comment body
44+
const commentMarker = '<!-- dd-trace-java-check-pull-requests-workflow -->'
45+
const commentBody = 'Hi! 👋 Thanks for your pull request! 🎉\n\n' +
46+
'To help us review it, please make sure to:\n\n' +
47+
(labelsCheckFailed ? '* Add at least one type, and one component or instrumentation label to the pull request\n' : '') +
48+
(titleCheckFailed ? '* Remove the tag from the pull request title\n' : '') +
49+
'\nIf you need help, please check our [contributing guidelines](https://github.com/DataDog/dd-trace-java/blob/master/CONTRIBUTING.md).' +
50+
'\n\n' + commentMarker
51+
// Look for previous comment
52+
const comments = await github.rest.issues.listComments({
53+
issue_number: context.payload.pull_request.number,
54+
owner: context.repo.owner,
55+
repo: context.repo.repo
56+
})
57+
const previousComment = comments.data.find(comment => comment.body.includes(commentMarker))
58+
if (previousComment) {
59+
// Update previous comment
60+
await github.rest.issues.updateComment({
61+
comment_id: previousComment.id,
62+
owner: context.repo.owner,
63+
repo: context.repo.repo,
64+
body: commentBody
65+
})
66+
} else {
67+
// Create new comment
68+
await github.rest.issues.createComment({
69+
issue_number: context.payload.pull_request.number,
70+
owner: context.repo.owner,
71+
repo: context.repo.repo,
72+
body: commentBody
73+
})
74+
}
75+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"pull_request": {
3+
"number": 7884,
4+
"draft": true,
5+
"labels": [],
6+
"title": "Adding some new features"
7+
}
8+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"pull_request": {
3+
"number": 7884,
4+
"draft": false,
5+
"labels": [
6+
{
7+
"name": "comp: api"
8+
}
9+
],
10+
"title": "Adding some new features"
11+
}
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"pull_request": {
3+
"number": 7884,
4+
"draft": false,
5+
"labels": [
6+
{
7+
"name": "tag: no release notes"
8+
}
9+
],
10+
"title": "Adding some new features"
11+
}
12+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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": "[API] Adding some new features"
14+
}
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
}
15+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
source "$(dirname "$0")/../env.sh"
3+
testworkflow pull_request && \
4+
testworkflow pull_request draft && \
5+
testworkflow pull_request no-release-notes && \
6+
! testworkflow pull_request missing-label && \
7+
! testworkflow pull_request title-tag

0 commit comments

Comments
 (0)