-
Notifications
You must be signed in to change notification settings - Fork 8.3k
[release/v7.5] Create github copilot setup workflow #26807
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| name: "Copilot Setup Steps" | ||
|
|
||
| # Allow testing of the setup steps from your repository's "Actions" tab. | ||
| on: | ||
| workflow_dispatch: | ||
|
|
||
| pull_request: | ||
| branches: | ||
| - master | ||
| paths: | ||
| - ".github/workflows/copilot-setup-steps.yml" | ||
|
|
||
| jobs: | ||
| # The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot. | ||
| # See https://docs.github.com/en/copilot/customizing-copilot/customizing-the-development-environment-for-copilot-coding-agent | ||
| copilot-setup-steps: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| # You can define any steps you want, and they will run before the agent starts. | ||
| # If you do not check out your code, Copilot will do this for you. | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
| with: | ||
| fetch-depth: 1000 | ||
|
|
||
| - name: Bootstrap | ||
| if: success() | ||
| run: |- | ||
| $title = 'Import Build.psm1' | ||
| Write-Host "::group::$title" | ||
| Import-Module ./build.psm1 -Verbose -ErrorAction Stop | ||
| Write-LogGroupEnd -Title $title | ||
|
|
||
| $title = 'Switch to public feed' | ||
| Write-LogGroupStart -Title $title | ||
| Switch-PSNugetConfig -Source Public | ||
| Write-LogGroupEnd -Title $title | ||
|
|
||
| $title = 'Bootstrap' | ||
| Write-LogGroupStart -Title $title | ||
| Start-PSBootstrap -Scenario DotNet | ||
| Write-LogGroupEnd -Title $title | ||
|
|
||
| $title = 'Install .NET Tools' | ||
| Write-LogGroupStart -Title $title | ||
| Start-PSBootstrap -Scenario Tools | ||
| Write-LogGroupEnd -Title $title | ||
|
|
||
| $title = 'Sync Tags' | ||
| Write-LogGroupStart -Title $title | ||
| Sync-PSTags -AddRemoteIfMissing | ||
| Write-LogGroupEnd -Title $title | ||
|
|
||
| $title = 'Setup .NET environment variables' | ||
| Write-LogGroupStart -Title $title | ||
| Find-DotNet -SetDotnetRoot | ||
| Write-LogGroupEnd -Title $title | ||
| shell: pwsh | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2282,7 +2282,12 @@ function Start-PSBootstrap { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [switch]$BuildLinuxArm, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [switch]$Force, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [Parameter(Mandatory = $true)] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [ValidateSet("Package", "DotNet", "Both")] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Package: Install dependencies for packaging tools (fpm, rpmbuild, WiX) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # DotNet: Install the .NET SDK | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Both: Package and DotNet scenarios | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Tools: Install .NET global tools (e.g., dotnet-format) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # All: Install all dependencies (packaging, .NET SDK, and tools) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [ValidateSet("Package", "DotNet", "Both", "Tools", "All")] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+2289
to
+2290
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # All: Install all dependencies (packaging, .NET SDK, and tools) | |
| [ValidateSet("Package", "DotNet", "Both", "Tools", "All")] | |
| [ValidateSet("Package", "DotNet", "Both", "Tools")] |
Copilot
AI
Feb 13, 2026
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.
The .NET global tools install uses dotnet tool install --global dotnet-format, which is not idempotent (it fails if the tool is already installed). Consider switching to dotnet tool update --global or checking dotnet tool list --global first so Start-PSBootstrap can be safely re-run.
| # Install dotnet-format | |
| Write-Verbose -Verbose "Installing dotnet-format global tool" | |
| Start-NativeExecution { | |
| dotnet tool install --global dotnet-format | |
| } | |
| # Ensure dotnet-format is installed as a global tool (idempotent) | |
| Write-Verbose -Verbose "Ensuring dotnet-format global tool is installed" | |
| $dotnetToolListOutput = Start-NativeExecution -IgnoreExitcode { | |
| dotnet tool list --global | |
| } | |
| $dotnetFormatInstalled = $false | |
| if ($LASTEXITCODE -eq 0 -and $dotnetToolListOutput -match '^\s*dotnet-format\b') { | |
| $dotnetFormatInstalled = $true | |
| } | |
| if ($dotnetFormatInstalled) { | |
| Write-Verbose -Verbose "dotnet-format is already installed. Updating global tool." | |
| Start-NativeExecution { | |
| dotnet tool update --global dotnet-format | |
| } | |
| } | |
| else { | |
| Write-Verbose -Verbose "dotnet-format is not installed. Installing global tool." | |
| Start-NativeExecution { | |
| dotnet tool install --global dotnet-format | |
| } | |
| } |
Copilot
AI
Feb 13, 2026
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.
Find-Dotnet now persists PATH/DOTNET_ROOT to GitHub Actions via Add-PSEnvironmentPath/Set-PSEnvironmentVariable before the final precheck succeeds. If precheck fails, the code restores only $env:PATH, but any prior writes to $GITHUB_PATH/$GITHUB_ENV (and DOTNET_ROOT in-process) remain, leaving the job environment inconsistent. Persist only after the final precheck passes, or stage changes locally and write to GitHub env files conditionally on success.
Copilot
AI
Feb 13, 2026
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.
The global tools PATH being added uses Join-Path $dotnetPath "tools". On Windows, dotnet tool install --global typically installs to $env:USERPROFILE\.dotnet\tools, not under $env:LocalAppData\Microsoft\dotnet\tools, so this may not put global tools on PATH. Consider computing the tools path per-platform (or from DOTNET_CLI_HOME/USERPROFILE) to ensure dotnet-format is discoverable.
| # Add .NET global tools to PATH when setting up the environment | |
| $dotnetToolsPath = Join-Path $dotnetPath "tools" | |
| # Compute .NET global tools path based on DOTNET_CLI_HOME/USERPROFILE/HOME | |
| $dotnetCliHome = if (-not [string]::IsNullOrWhiteSpace($env:DOTNET_CLI_HOME)) { | |
| $env:DOTNET_CLI_HOME | |
| } | |
| elseif ($environment.IsWindows) { | |
| $env:USERPROFILE | |
| } | |
| else { | |
| $env:HOME | |
| } | |
| $dotnetToolsRoot = Join-Path $dotnetCliHome ".dotnet" | |
| $dotnetToolsPath = Join-Path $dotnetToolsRoot "tools" |
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.
This workflow’s
pull_requesttrigger is restricted tomaster. Since this file is being backported torelease/v7.5, PRs targetingrelease/**(including this branch) won’t run the workflow to validate changes. Consider addingrelease/**(matching other CI workflows here) or removing the branch filter so edits are validated on release branches too.