-
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
Open
jaydeluca
wants to merge
16
commits into
open-telemetry:main
Choose a base branch
from
jaydeluca:breaking-automation
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+307
−0
Open
Changes from all commits
Commits
Show all changes
16 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 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}" | ||
|
||
if [[ "$range" == "HEAD" ]]; then | ||
# Get all commits from HEAD | ||
commits=$(git log --reverse --pretty=format:"%H %s" HEAD) | ||
else | ||
# Get commits in the specified range | ||
commits=$(git log --reverse --pretty=format:"%H %s" "$range") | ||
fi | ||
|
||
# Initialize tracking variables | ||
breaking_changes="" | ||
deprecations="" | ||
breaking_changes_found=false | ||
deprecations_found=false | ||
|
||
# Process each commit to find PRs with specified labels | ||
while IFS= read -r line; do | ||
if [[ -z "$line" ]]; then | ||
continue | ||
fi | ||
|
||
# Extract PR number from commit message | ||
if [[ $line =~ \(#([0-9]+)\)$ ]]; then | ||
pr_number="${BASH_REMATCH[1]}" | ||
commit_subject=$(echo "$line" | cut -d' ' -f2- | sed 's/ (#[0-9]*)$//') | ||
|
||
# Get PR labels using GitHub CLI | ||
if pr_labels=$(gh pr view "$pr_number" --json labels --jq '.labels[].name' 2>/dev/null); then | ||
# Check for breaking change label | ||
if echo "$pr_labels" | grep -q "^breaking change$"; then | ||
breaking_changes_found=true | ||
breaking_changes+="- $commit_subject"$'\n'" ([#$pr_number](https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/$pr_number))"$'\n'$'\n' | ||
fi | ||
|
||
# Check for deprecation label | ||
if echo "$pr_labels" | grep -q "^deprecation$"; then | ||
deprecations_found=true | ||
deprecations+="- $commit_subject"$'\n'" ([#$pr_number](https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/$pr_number))"$'\n'$'\n' | ||
fi | ||
fi | ||
fi | ||
done <<< "$commits" | ||
|
||
# Output breaking changes section | ||
if [[ "$breaking_changes_found" == "true" ]]; then | ||
echo "## ⚠️ Breaking Changes" | ||
echo | ||
echo -n "$breaking_changes" | ||
fi | ||
|
||
# Output deprecations section | ||
if [[ "$deprecations_found" == "true" ]]; then | ||
echo "## 🚫 Deprecations" | ||
echo | ||
echo -n "$deprecations" | ||
fi | ||
|
||
# Output "no changes" messages if needed | ||
if [[ "$breaking_changes_found" == "false" ]]; then | ||
echo "## ⚠️ Breaking Changes" | ||
echo | ||
echo "*No breaking changes in this release.*" | ||
echo | ||
fi | ||
|
||
if [[ "$deprecations_found" == "false" ]]; then | ||
echo "## 🚫 Deprecations" | ||
echo | ||
echo "*No deprecations in this release.*" | ||
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.