-
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 all 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
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,73 @@ | ||
| # This workflow generates breaking change documentation for merged pull requests. | ||
| # It runs automatically when a PR with the 'needs-breaking-change-doc-created' label is merged, | ||
| # or when that label is added to an already merged PR. | ||
| # It can be manually triggered to generate documentation for any specific PR. | ||
| # | ||
| # The workflow uses GitHub Models AI to analyze the PR changes and create appropriate | ||
| # breaking change documentation that gets posted as a PR comment as a clickable link | ||
| # to open an issue in the dotnet/docs repository. | ||
| name: Breaking Change Documentation | ||
|
|
||
| on: | ||
| pull_request_target: | ||
| types: [closed, labeled] | ||
| workflow_dispatch: | ||
| inputs: | ||
| pr_number: | ||
| description: "Pull Request Number" | ||
| required: true | ||
| type: number | ||
|
|
||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
| models: read | ||
|
|
||
| jobs: | ||
| generate-breaking-change-doc: | ||
| if: | | ||
| github.repository_owner == 'dotnet' && ( | ||
| (github.event_name == 'pull_request_target' && github.event.action == 'closed' && github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'needs-breaking-change-doc-created')) || | ||
| (github.event_name == 'pull_request_target' && github.event.action == 'labeled' && github.event.pull_request.merged == true && github.event.label.name == 'needs-breaking-change-doc-created') || | ||
| github.event_name == 'workflow_dispatch' | ||
| ) | ||
| 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 ${{ inputs.pr_number || 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-${{ inputs.pr_number || 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,172 @@ | ||
| # 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 analysis-only default | ||
| - **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 -Help | ||
| ``` | ||
|
|
||
| 4. **Choose your workflow:** | ||
| ```powershell | ||
| # Default: Analysis only (generates drafts without making GitHub changes) | ||
| .\breaking-change-doc.ps1 -PrNumber 123456 | ||
|
|
||
| # Add comments with create issue links | ||
| .\breaking-change-doc.ps1 -PrNumber 123456 -Comment | ||
|
|
||
| # Create issues directly | ||
| .\breaking-change-doc.ps1 -PrNumber 123456 -CreateIssues | ||
|
|
||
| # Just collect data | ||
| .\breaking-change-doc.ps1 -PrNumber 123456 -CollectOnly | ||
| ``` | ||
|
|
||
| ## Commands | ||
|
|
||
| ```powershell | ||
| # Help (shows all parameters and examples) | ||
| .\breaking-change-doc.ps1 -Help | ||
|
|
||
| # Default workflow (analysis only - generates drafts) | ||
| .\breaking-change-doc.ps1 -PrNumber 123456 | ||
|
|
||
| # Add comments with issue creation links | ||
| .\breaking-change-doc.ps1 -PrNumber 123456 -Comment | ||
|
|
||
| # Create issues directly | ||
| .\breaking-change-doc.ps1 -PrNumber 123456 -CreateIssues | ||
|
|
||
| # Data collection only | ||
| .\breaking-change-doc.ps1 -PrNumber 123456 -CollectOnly | ||
|
|
||
| # Query multiple PRs | ||
| .\breaking-change-doc.ps1 -Query "repo:dotnet/runtime state:closed label:needs-breaking-change-doc-created is:merged" | ||
|
|
||
| # Clean previous data | ||
| .\breaking-change-doc.ps1 -Clean | ||
|
|
||
| # Clean and process | ||
| .\breaking-change-doc.ps1 -Clean -PrNumber 123456 | ||
| ``` | ||
|
|
||
| ## 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 when using -CreateIssues | ||
| - **GitHub Comments**: Added to PRs when using -Comment | ||
|
|
||
| ## 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 | ||
| 3. **AI Analysis** - Generates high-quality breaking change documentation using AI | ||
| 4. **Output Generation** - Creates issue drafts and comment drafts for review | ||
| 5. **Optional Actions** - Adds comments with issue creation links (-Comment) or creates issues directly (-CreateIssues) | ||
|
|
||
| ## 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 -Clean | ||
| ``` | ||
|
|
||
| ## Parameters | ||
|
|
||
| | Parameter | Description | Example | | ||
| |-----------|-------------|---------| | ||
| | `-Help` | Show help and parameter information | `.\breaking-change-doc.ps1 -Help` | | ||
| | `-PrNumber` | Process a specific PR number | `.\breaking-change-doc.ps1 -PrNumber 123456` | | ||
| | `-Query` | GitHub search query for multiple PRs | `.\breaking-change-doc.ps1 -Query "repo:dotnet/runtime state:closed label:needs-breaking-change-doc-created is:merged"` | | ||
| | `-CollectOnly` | Only collect PR data, don't generate documentation | `.\breaking-change-doc.ps1 -PrNumber 123456 -CollectOnly` | | ||
| | `-Comment` | Add comments to PRs with issue creation links | `.\breaking-change-doc.ps1 -PrNumber 123456 -Comment` | | ||
| | `-CreateIssues` | Create GitHub issues directly | `.\breaking-change-doc.ps1 -PrNumber 123456 -CreateIssues` | | ||
| | `-Clean` | Clean previous data before starting | `.\breaking-change-doc.ps1 -Clean` | | ||
|
|
||
| **Note**: Either `-PrNumber` or `-Query` must be specified (unless using `-Clean` or `-Help` alone). | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| **GitHub CLI**: `gh auth status` and `gh auth login` | ||
| **API Keys**: Verify environment variables are set for non-GitHub Models providers | ||
| **Rate Limits**: Script includes delays between API calls | ||
| **Git Operations**: Ensure git is in PATH and repository is up to date (`git fetch --tags`) | ||
| **Parameter Issues**: Use `-Help` to see current parameter list and examples |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice usage of
github.event.pull_request.labels.*.name💯