-
Notifications
You must be signed in to change notification settings - Fork 1k
Automation for tracking breaking changes #14785
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+304
−9
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
ce668b4
Add breaking changes automation
jaydeluca 3b5bba2
Merge branch 'main' of github.com:jaydeluca/opentelemetry-java-instru…
jaydeluca 0232046
fix newlines
jaydeluca c571848
simplify release notes
jaydeluca ae4e4d3
fix bash
jaydeluca f3cb98a
fix shellcheck
jaydeluca 866c6c5
add deprecation flow
jaydeluca 2c9eae8
remove extra file
jaydeluca eee165a
fix link
jaydeluca 9c5ac34
PR feedback updates
jaydeluca 74e95ec
update verbiage to remove option to add notes to comments
jaydeluca 3714857
Provide a way for users to add/remove labels
jaydeluca 044cb83
try and fix trigger
jaydeluca 445040d
Merge branch 'main' into breaking-automation
jaydeluca 1d8b83d
remove unnessary script, remove workflows for removing labels
jaydeluca 133437b
Merge branch 'main' into breaking-automation
jaydeluca 3933874
Merge remote-tracking branch 'upstream/main' into mid
trask df2bc60
updates
trask File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#!/bin/bash -e | ||
|
||
# This script extracts PRs with "breaking change" and "deprecation" labels for the given version range | ||
# Usage: extract-labeled-prs.sh [git-range] | ||
# If no range is provided, it uses HEAD | ||
|
||
range="${1:-HEAD}" | ||
|
||
# Get the date range for filtering | ||
if [[ "$range" == "HEAD" ]]; then | ||
# Get all commits from HEAD | ||
oldest_commit=$(git log --reverse --pretty=format:"%H" HEAD | head -1) | ||
since_date=$(git show -s --format=%ci "$oldest_commit" | cut -d' ' -f1) | ||
else | ||
# Get commits in the specified range | ||
if [[ $range =~ ^(.+)\.\.(.+)$ ]]; then | ||
from_ref="${BASH_REMATCH[1]}" | ||
oldest_commit=$(git rev-parse "$from_ref") | ||
since_date=$(git show -s --format=%ci "$oldest_commit" | cut -d' ' -f1) | ||
else | ||
echo "[ERROR] Invalid range format: $range" >&2 | ||
exit 1 | ||
fi | ||
fi | ||
|
||
# Initialize tracking variables | ||
breaking_changes="" | ||
deprecations="" | ||
breaking_changes_found=false | ||
deprecations_found=false | ||
|
||
# Get PRs with "breaking change" label using GitHub search | ||
breaking_prs=$(gh pr list \ | ||
--repo open-telemetry/opentelemetry-java-instrumentation \ | ||
--label "breaking change" \ | ||
--state merged \ | ||
--search "merged:>=$since_date" \ | ||
--json number,title \ | ||
--jq '.[] | "\(.number)|\(.title)"' 2>/dev/null || echo "") | ||
|
||
if [[ -n "$breaking_prs" ]]; then | ||
breaking_changes_found=true | ||
while IFS='|' read -r pr_number pr_title; do | ||
breaking_changes+="- $pr_title"$'\n'" ([#$pr_number](https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/$pr_number))"$'\n' | ||
done <<< "$breaking_prs" | ||
fi | ||
|
||
# Get PRs with "deprecation" label using GitHub search | ||
deprecation_prs=$(gh pr list \ | ||
--repo open-telemetry/opentelemetry-java-instrumentation \ | ||
--label "deprecation" \ | ||
--state merged \ | ||
--search "merged:>=$since_date" \ | ||
--json number,title \ | ||
--jq '.[] | "\(.number)|\(.title)"' 2>/dev/null || echo "") | ||
|
||
if [[ -n "$deprecation_prs" ]]; then | ||
deprecations_found=true | ||
while IFS='|' read -r pr_number pr_title; do | ||
deprecations+="- $pr_title"$'\n'" ([#$pr_number](https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/$pr_number))"$'\n' | ||
done <<< "$deprecation_prs" | ||
fi | ||
|
||
# Output breaking changes section | ||
if [[ "$breaking_changes_found" == "true" ]]; then | ||
echo "### ⚠️ Breaking Changes" | ||
echo | ||
echo -n "$breaking_changes" | ||
echo | ||
fi | ||
|
||
# Output deprecations section | ||
if [[ "$deprecations_found" == "true" ]]; then | ||
echo "### 🚫 Deprecations" | ||
echo | ||
echo -n "$deprecations" | ||
echo | ||
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
name: PR Automation Comments | ||
on: | ||
pull_request: | ||
types: [labeled] | ||
|
||
permissions: | ||
pull-requests: write | ||
|
||
jobs: | ||
comment-on-breaking-change: | ||
if: contains(github.event.label.name, 'breaking change') | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Comment on PR | ||
uses: actions/github-script@v7 | ||
with: | ||
script: | | ||
const { data: comments } = await github.rest.issues.listComments({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: context.issue.number, | ||
}); | ||
|
||
// Check if we've already commented about breaking changes | ||
const botComment = comments.find(comment => | ||
comment.user.login === 'github-actions[bot]' && | ||
comment.body.includes('⚠️ Breaking Change Documentation Required') | ||
); | ||
|
||
if (!botComment) { | ||
const commentBody = [ | ||
"## ⚠️ Breaking Change Documentation Required", | ||
"", | ||
"This PR has been labeled as a **breaking change**. Please ensure you provide the following information:", | ||
"", | ||
"### Migration Notes Required", | ||
"Please add detailed migration notes to help users understand:", | ||
"- What is changing and why", | ||
"- How to update their code/configuration", | ||
"- Any alternative approaches if applicable", | ||
"- Code examples showing before/after usage", | ||
"", | ||
"### Checklist", | ||
"- [ ] Migration notes added to the PR description", | ||
"- [ ] Breaking change is documented in the changelog entry for the next release", | ||
"- [ ] Consider if this change requires a major version bump", | ||
"", | ||
"Your migration notes will be included in the release notes to help users upgrade smoothly. The more detailed and helpful they are, the better the user experience will be.", | ||
"", | ||
"---", | ||
"*This comment was automatically generated because the `breaking change` label was applied to this PR.*" | ||
].join("\n"); | ||
|
||
await github.rest.issues.createComment({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: context.issue.number, | ||
body: commentBody | ||
}); | ||
} | ||
|
||
comment-on-deprecation: | ||
if: contains(github.event.label.name, 'deprecation') | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Comment on PR | ||
uses: actions/github-script@v7 | ||
with: | ||
script: | | ||
const { data: comments } = await github.rest.issues.listComments({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: context.issue.number, | ||
}); | ||
|
||
// Check if we've already commented about deprecation | ||
const botComment = comments.find(comment => | ||
comment.user.login === 'github-actions[bot]' && | ||
comment.body.includes('📋 Deprecation Notice') | ||
); | ||
|
||
if (!botComment) { | ||
const commentBody = [ | ||
"## 📋 Deprecation Notice", | ||
"", | ||
"This PR has been labeled as a **deprecation**. Please ensure you provide the following information:", | ||
"", | ||
"### 📝 Deprecation Details Required", | ||
"Please add details to help users understand:", | ||
"- What is being deprecated and why", | ||
"- What should be used instead (if applicable)", | ||
"- Timeline for removal (if known)", | ||
"- Any migration guidance", | ||
"", | ||
"### 📋 Checklist", | ||
"- [ ] Deprecation details added to the PR description", | ||
"- [ ] Deprecation is documented in the changelog entry for the next release", | ||
"- [ ] Consider adding deprecation warnings in code/documentation", | ||
"", | ||
"Your deprecation notes will be included in the release notes to help users prepare for future changes.", | ||
"", | ||
"---", | ||
"*This comment was automatically generated because the `deprecation` label was applied to this PR.*" | ||
].join("\n"); | ||
|
||
await github.rest.issues.createComment({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: context.issue.number, | ||
body: commentBody | ||
}); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
name: PR Label Automation | ||
on: | ||
issue_comment: | ||
types: [created] | ||
|
||
permissions: | ||
contents: read | ||
issues: write | ||
pull-requests: write | ||
|
||
jobs: | ||
auto-label: | ||
# Only run on pull request comments | ||
if: github.event.issue.pull_request != null | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Add breaking change label | ||
if: github.event.comment.body == '/breaking-change' | ||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 | ||
with: | ||
script: | | ||
// Add the breaking change label | ||
await github.rest.issues.addLabels({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: context.issue.number, | ||
labels: ['breaking change'] | ||
}); | ||
|
||
// React to the comment to show it was processed | ||
await github.rest.reactions.createForIssueComment({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
comment_id: context.payload.comment.id, | ||
content: '+1' | ||
}); | ||
|
||
// Add a reply comment to confirm the action | ||
await github.rest.issues.createComment({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: context.issue.number, | ||
body: '✅ Added `breaking change` label to this PR.' | ||
}); | ||
|
||
- name: Add deprecation label | ||
if: github.event.comment.body == '/deprecation' | ||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 | ||
with: | ||
script: | | ||
// Add the deprecation label | ||
await github.rest.issues.addLabels({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: context.issue.number, | ||
labels: ['deprecation'] | ||
}); | ||
|
||
// React to the comment to show it was processed | ||
await github.rest.reactions.createForIssueComment({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
comment_id: context.payload.comment.id, | ||
content: '+1' | ||
}); | ||
|
||
// Add a reply comment to confirm the action | ||
await github.rest.issues.createComment({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: context.issue.number, | ||
body: '✅ Added `deprecation` label to this PR.' | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.