-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add PR dogfooding script + automatic comment #33043
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
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9d7a20e
Add scripts to easily retrieve MAUI PR artifacts
jfversluis 2081b97
Add GitHub Action for commenting
jfversluis 66d620f
Remove comment from PR template
jfversluis 1f6dfb3
Update README.md
jfversluis bda77e3
Address comments
jfversluis 696fae3
Don't trigger Azure Pipelines on GitHub changes
jfversluis e68a60a
Update get-maui-pr.sh
jfversluis 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
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,85 @@ | ||
| name: Add Dogfooding Comment | ||
|
|
||
| on: | ||
| # Use pull_request_target to run in the context of the base branch | ||
| # This allows commenting on PRs from forks | ||
| pull_request_target: | ||
| types: [opened, reopened, synchronize] | ||
| branches: | ||
| - 'main' | ||
| - 'net*' | ||
| - 'release/**' | ||
|
|
||
| # Allow manual triggering | ||
| workflow_dispatch: | ||
| inputs: | ||
| pr_number: | ||
| description: 'PR number to add dogfooding comment to' | ||
| required: true | ||
| type: number | ||
|
|
||
| jobs: | ||
| add-dogfood-comment: | ||
| # Only run on the dotnet org to avoid running on forks | ||
| if: ${{ github.repository_owner == 'dotnet' }} | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| pull-requests: write | ||
|
|
||
| steps: | ||
| - name: Add dogfooding comment | ||
| uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 | ||
| with: | ||
| script: | | ||
| // Get PR number from either the PR event or manual input | ||
| const prNumber = context.payload.number || context.payload.inputs?.pr_number; | ||
|
|
||
| const bashScript = 'https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh'; | ||
| const psScript = 'https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1'; | ||
|
|
||
| // Unique marker to identify dogfooding comments | ||
| const dogfoodMarker = '<!-- dogfood-pr -->'; | ||
|
|
||
| const comment = `${dogfoodMarker} | ||
| 🚀 **Dogfood this PR with:** | ||
|
|
||
| > **⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.** | ||
|
|
||
| \`\`\`bash | ||
| curl -fsSL ${bashScript} | bash -s -- ${prNumber} | ||
| \`\`\` | ||
|
|
||
| Or | ||
|
|
||
| - Run remotely in PowerShell: | ||
|
|
||
| \`\`\`powershell | ||
| iex "& { $(irm ${psScript}) } ${prNumber}" | ||
| \`\`\``; | ||
|
|
||
| // Check for existing dogfooding comment | ||
| const comments = await github.rest.issues.listComments({ | ||
| issue_number: prNumber, | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| }); | ||
|
|
||
| const existingComment = comments.data.find(comment => comment.body.includes(dogfoodMarker)); | ||
|
|
||
| if (existingComment) { | ||
| // Update existing comment | ||
| await github.rest.issues.updateComment({ | ||
| comment_id: existingComment.id, | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| body: comment | ||
| }); | ||
| } else { | ||
| // Create new comment | ||
| await github.rest.issues.createComment({ | ||
| issue_number: prNumber, | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| body: comment | ||
| }); | ||
| } | ||
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
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
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
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,128 @@ | ||
| # .NET MAUI PR Artifact Scripts | ||
|
|
||
| Scripts to test .NET MAUI pull request builds in your own projects before they're merged. | ||
|
|
||
| ## Scripts | ||
|
|
||
| - `get-maui-pr.sh` - Bash script for Unix-like systems (Linux, macOS) | ||
| - `get-maui-pr.ps1` - PowerShell script for cross-platform use (Windows, Linux, macOS) | ||
|
|
||
| ## Quick Start | ||
|
|
||
| > **⚠️ WARNING:** Always review the PR code before running these scripts. Only test PRs you trust. | ||
|
|
||
| **Bash:** | ||
|
|
||
| ```bash | ||
| curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- <PR_NUMBER> | ||
| ``` | ||
|
|
||
| **PowerShell:** | ||
|
|
||
| ```powershell | ||
| iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } <PR_NUMBER>" | ||
| ``` | ||
|
|
||
| ## NuGet Hive Path | ||
|
|
||
| Downloaded packages are stored in a hive directory: | ||
|
|
||
| - **Unix (Linux/macOS)**: `~/.maui/hives/pr-<PR_NUMBER>/packages` | ||
| - **Windows**: `%USERPROFILE%\.maui\hives\pr-<PR_NUMBER>\packages` | ||
|
|
||
| ## Requirements | ||
|
|
||
| - .NET SDK installed | ||
| - A .NET MAUI project (`.csproj` with `<UseMaui>true</UseMaui>`) | ||
| - Internet connection | ||
| - **Bash only**: `curl`, `jq`, and `unzip` | ||
|
|
||
| ## Parameters | ||
|
|
||
| ### Bash Script (`get-maui-pr.sh`) | ||
|
|
||
| | Argument | Description | Required | | ||
| |----------|-------------|----------| | ||
| | 1st | PR number to test | Yes | | ||
| | 2nd | Path to .csproj file | No (auto-detects) | | ||
|
|
||
| ### PowerShell Script (`get-maui-pr.ps1`) | ||
|
|
||
| | Parameter | Description | Default | | ||
| |-----------|-------------|---------| | ||
| | `-PrNumber` | PR number to test | Required | | ||
| | `-ProjectPath` | Path to .csproj file | Auto-detect | | ||
|
|
||
| ## Usage Examples | ||
|
|
||
| ### Bash Script Examples | ||
|
|
||
| ```bash | ||
| # Test PR in current directory | ||
| ./get-maui-pr.sh 33002 | ||
|
|
||
| # Test PR with specific project | ||
| ./get-maui-pr.sh 33002 ./MyApp/MyApp.csproj | ||
| ``` | ||
|
|
||
| ### PowerShell Script Examples | ||
|
|
||
| ```powershell | ||
| # Test PR in current directory | ||
| .\get-maui-pr.ps1 33002 | ||
|
|
||
| # Test PR with specific project | ||
| .\get-maui-pr.ps1 -PrNumber 33002 -ProjectPath ./MyApp/MyApp.csproj | ||
| ``` | ||
|
|
||
| ## Repository Override | ||
|
|
||
| You can point the scripts at a fork by setting the `MAUI_REPO` environment variable to `owner/name` before invoking the script (defaults to `dotnet/maui`). | ||
|
|
||
| ```bash | ||
| export MAUI_REPO=myfork/maui | ||
| ./get-maui-pr.sh 1234 | ||
| ``` | ||
|
|
||
| ```powershell | ||
| $env:MAUI_REPO = 'myfork/maui' | ||
| ./get-maui-pr.ps1 1234 | ||
| ``` | ||
|
|
||
| ## Reverting Changes | ||
|
|
||
| **TIP:** Use a separate Git branch for testing! | ||
|
|
||
| ```bash | ||
| git checkout -b test-pr-33002 | ||
| # ... test the PR ... | ||
| git checkout main # Easy revert! | ||
| ``` | ||
|
|
||
| Or manually revert: | ||
|
|
||
| 1. Edit your `.csproj` - change package version back to stable (see [NuGet](https://www.nuget.org/packages/Microsoft.Maui.Controls)) | ||
| 2. Remove the `maui-pr-build` source from `NuGet.config` | ||
| 3. Run `dotnet restore --force` | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| ### Common Issues | ||
|
|
||
| 1. **"No build found for PR"**: The PR may not have a completed build yet. Check the PR on GitHub for build status. | ||
| 2. **"No .NET MAUI project found"**: Ensure you're in a directory with a `.csproj` file that has `<UseMaui>true</UseMaui>`. | ||
| 3. **"Failed to download artifacts"**: Check your internet connection. Artifacts may have expired for older PRs. | ||
|
|
||
| ### Getting Help | ||
|
|
||
| Run the PowerShell script with the help flag to see detailed usage information: | ||
|
|
||
| ```powershell | ||
| Get-Help .\get-maui-pr.ps1 -Detailed | ||
| ``` | ||
|
|
||
| ## More Information | ||
|
|
||
| - [Testing PR Builds Wiki](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) | ||
| - [.NET MAUI Nightly Builds](https://github.com/dotnet/maui/wiki/Nightly-Builds) | ||
| - [Contributing Guide](https://github.com/dotnet/maui/blob/main/CONTRIBUTING.md) |
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.