-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Breaking change doc tool #120987
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
ericstj
wants to merge
28
commits into
main
Choose a base branch
from
breakingChangeDocTool
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.
+1,508
−0
Open
Breaking change doc tool #120987
Changes from 18 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
73ad965
Initial check-in of breaking-change doc script
ericstj b72e312
Adjust breaking change script for runtime repo
ericstj af539cf
Remove label checking
ericstj cdde40f
Add a workflow triggered on breaking change docs needed.
ericstj 1100977
Remove issue write permission
ericstj 8af1bca
Simplify breaking change doc step
ericstj 2afb344
Use pull_request_target
ericstj f20e2cc
Only run workflow on dotnet repo.
ericstj 85affad
Use GitHub REST API for fetching from dotnet/docs
ericstj 465fa5b
Fix log messages
ericstj 6b37cfd
Try models: read permission
ericstj 448102f
Add support for Copilot CLI
ericstj 1498523
Address feedback
ericstj 3d50c46
Fix yml indenting
ericstj d57ace3
Allow external API key for Github Models and Copilot CLI
ericstj 61c3e30
Use optional token when invoking gh models / copilot
ericstj 730d99a
Use GH_TOKEN instead of GITHUB_TOKEN
ericstj 916bd2d
Merge branch 'main' into breakingChangeDocTool
ericstj 37aea61
Address feedback
ericstj d946c03
Only run the breaking change doc workflow on merged PRs
ericstj 076970f
Add workflow dispatch to breaking change workflow
ericstj 34ac620
Add docs to breaking change workflow.
ericstj 62ebd7f
Fix workflow condition
ericstj c797328
Fix calling gh CLI and use prompt file
ericstj 5ae118e
Use powershell-yaml
ericstj 10d1e6f
Fix Clean to work correctly
ericstj 9179883
Update readme
ericstj d27e210
Fetch PR commits, and remove some redundant CLI calls.
ericstj 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| name: Breaking Change Documentation | ||
|
|
||
| on: | ||
| pull_request_target: | ||
| types: [labeled] | ||
|
|
||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
| models: read | ||
|
|
||
| jobs: | ||
| generate-breaking-change-doc: | ||
| if: contains(github.event.label.name, 'needs-breaking-change-doc-created') && github.repository_owner == 'dotnet' | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 # Need full history for version detection | ||
|
|
||
| - name: Verify PowerShell | ||
| run: | | ||
| pwsh --version | ||
|
|
||
| - name: Verify GitHub CLI | ||
| run: | | ||
| gh --version | ||
|
|
||
| - name: Install GitHub Models extension | ||
| run: | | ||
| gh extension install github/gh-models --force | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
|
|
||
| - name: Fetch latest tags | ||
| run: | | ||
| git fetch --tags --force | ||
|
|
||
| - name: Run breaking change documentation script | ||
| shell: pwsh | ||
| working-directory: eng/breakingChanges | ||
| run: ./breaking-change-doc.ps1 -PrNumber ${{ github.event.pull_request.number }} -Comment | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| GITHUB_MODELS_API_KEY: ${{ secrets.MODELS_TOKEN }} | ||
|
|
||
| - name: Upload artifacts | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: breaking-change-doc-artifacts-${{ github.event.pull_request.number }} | ||
| path: artifacts/docs/breakingChanges/ | ||
| retention-days: 7 | ||
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,149 @@ | ||
| # Breaking Change Documentation Automation | ||
|
|
||
| This script automates the creation of high-quality breaking change documentation for .NET runtime PRs using AI-powered analysis. | ||
|
|
||
| ## Key Features | ||
|
|
||
| - **GitHub Models Integration**: Uses GitHub's AI models (no API keys required) with fallback to other providers | ||
| - **Dynamic Template Fetching**: Automatically fetches the latest breaking change issue template from dotnet/docs | ||
| - **Example-Based Learning**: Analyzes recent breaking change issues to improve content quality | ||
| - **Version Detection**: Analyzes GitHub tags to determine accurate .NET version information for proper milestone assignment | ||
| - **Flexible Workflow**: Multiple execution modes (CollectOnly, Comment, CreateIssues) with DryRun overlay | ||
| - **Comprehensive Data Collection**: Gathers PR details, related issues, merge commits, review comments, and closing issues | ||
| - **Area Label Detection**: Automatically detects feature areas from GitHub labels (area-*) with file path fallback | ||
| - **Individual File Output**: Creates separate JSON files per PR for easy examination | ||
|
|
||
| ## Quick Setup | ||
|
|
||
| 1. **Install Prerequisites:** | ||
| - GitHub CLI: `gh auth login` | ||
| - Choose LLM provider: | ||
| - **GitHub Models** (recommended): `gh extension install github/gh-models` | ||
| - **OpenAI**: Set `$env:OPENAI_API_KEY = "your-key"` | ||
| - **Others**: See configuration section below | ||
|
|
||
| 2. **Configure:** | ||
| ```powershell | ||
| # Edit config.ps1 to set: | ||
| # - LlmProvider = "github-models" (or other provider) | ||
| ``` | ||
|
|
||
| 3. **Run the workflow:** | ||
| ```powershell | ||
| .\breaking-change-doc.ps1 -DryRun | ||
| ``` | ||
|
|
||
| 4. **Choose your workflow:** | ||
| ```powershell | ||
| # Default: Add comments with create issue links (recommended) | ||
| .\breaking-change-doc.ps1 | ||
|
|
||
| # Create issues directly | ||
| .\breaking-change-doc.ps1 -CreateIssues | ||
|
|
||
| # Just collect data | ||
| .\breaking-change-doc.ps1 -CollectOnly | ||
| ``` | ||
|
|
||
| ## Commands | ||
|
|
||
| ```powershell | ||
| # Dry run (inspect commands) | ||
| .\breaking-change-doc.ps1 -DryRun | ||
|
|
||
| # Default workflow (add comments with links) | ||
| .\breaking-change-doc.ps1 | ||
|
|
||
| # Create issues directly | ||
| .\breaking-change-doc.ps1 -CreateIssues | ||
|
|
||
| # Data collection only | ||
| .\breaking-change-doc.ps1 -CollectOnly | ||
|
|
||
| # Single PR mode | ||
| .\breaking-change-doc.ps1 -PRNumber 123456 | ||
|
|
||
| # Clean start | ||
| .\breaking-change-doc.ps1 -CleanStart | ||
|
|
||
| # Help | ||
| .\breaking-change-doc.ps1 -Help | ||
| ``` | ||
|
|
||
| ## Configuration | ||
|
|
||
| Edit `config.ps1` to customize: | ||
| - **LLM provider**: GitHub Models, OpenAI, Anthropic, Azure OpenAI | ||
| - **Search parameters**: Date ranges, labels, excluded milestones | ||
| - **Output settings**: Labels, assignees, notification emails | ||
|
|
||
| ## LLM Providers | ||
|
|
||
| **GitHub Models** (recommended - no API key needed): | ||
| ```powershell | ||
| gh extension install github/gh-models | ||
| # Set provider in config.ps1: LlmProvider = "github-models" | ||
| ``` | ||
|
|
||
| **OpenAI**: | ||
| ```powershell | ||
| $env:OPENAI_API_KEY = "your-key" | ||
| # Set provider in config.ps1: LlmProvider = "openai" | ||
| ``` | ||
|
|
||
| **Anthropic Claude**: | ||
| ```powershell | ||
| $env:ANTHROPIC_API_KEY = "your-key" | ||
| # Set provider in config.ps1: LlmProvider = "anthropic" | ||
| ``` | ||
|
|
||
| **Azure OpenAI**: | ||
| ```powershell | ||
| $env:AZURE_OPENAI_API_KEY = "your-key" | ||
| # Configure endpoint in config.ps1: LlmProvider = "azure-openai" | ||
| ``` | ||
|
|
||
| ## Output | ||
|
|
||
| - **Data Collection**: `(repoRoot)\artifacts\docs\breakingChanges\data\summary_report.md`, `(repoRoot)\artifacts\docs\breakingChanges\data\pr_*.json` | ||
| - **Issue Drafts**: `(repoRoot)\artifacts\docs\breakingChanges\issue-drafts\*.md` | ||
| - **Comment Drafts**: `(repoRoot)\artifacts\docs\breakingChanges\comment-drafts\*.md` | ||
| - **GitHub Issues**: Created automatically (unless -DryRun) | ||
|
|
||
| ## Workflow Steps | ||
|
|
||
| 1. **Fetch PRs** - Downloads PR data from dotnet/runtime with comprehensive details | ||
| 2. **Version Detection** - Analyzes GitHub tags to determine accurate .NET version information | ||
| 3. **Template & Examples** - Fetches latest issue template and analyzes recent breaking change issues | ||
| 4. **AI Analysis** - Generates high-quality breaking change documentation using AI | ||
| 5. **Create Issues/Comments** - Adds comments with issue creation links or creates issues directly | ||
|
|
||
| ## Version Detection | ||
|
|
||
| The script automatically determines accurate .NET version information using the local git repository: | ||
| - **Fast and reliable**: Uses `git describe` commands on the repository | ||
| - **No API rate limits**: Avoids GitHub API calls for version detection | ||
| - **Accurate timing**: Analyzes actual commit ancestry and tag relationships | ||
| - **Merge commit analysis**: For merged PRs, finds the exact merge commit and determines version context | ||
| - **Branch-aware**: For unmerged PRs, uses target branch information | ||
|
|
||
| ## Manual Review | ||
|
|
||
| AI generates 90%+ ready documentation, but review for: | ||
| - Technical accuracy | ||
| - API completeness | ||
| - Edge cases | ||
|
|
||
| ## Cleanup | ||
|
|
||
| Between runs: | ||
| ```powershell | ||
| .\breaking-change-doc.ps1 -CleanStart | ||
| ``` | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| **GitHub CLI**: `gh auth status` and `gh auth login` | ||
| **API Keys**: Verify environment variables are set for non-GitHub Models providers | ||
| **Rate Limits**: Use -DryRun for testing, script includes delays | ||
| **Git Operations**: Ensure git is in PATH and repository is up to date (`git fetch --tags`) |
Oops, something went wrong.
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.