-
Notifications
You must be signed in to change notification settings - Fork 93
Update msbench script and pipeline #1070
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 5 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
ccc6659
Update bench script and pipeline
hallipr 5cfef1c
Address PR feedback and improve docs
hallipr 64d47b2
Try using an authenticated feed url
hallipr eff083e
Only emit the `setsecret` lines in a pipeline run
hallipr b1a1278
Add LASTEXITCODE checks
hallipr d6e165b
Emit the encoded token as a secret as well
hallipr b842b99
Update pipelines/scripts/Invoke-CopilotBenchmarks.ps1
hallipr 140b277
Improve feed auth
hallipr 5d580f1
Try python 3.12
hallipr 3d345ca
Use internal feed
hallipr 84d80e9
Update pipelines/scripts/Invoke-CopilotBenchmarks.ps1
hallipr 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 |
|---|---|---|
| @@ -1,4 +1,6 @@ | ||
|
|
||
| venv/ | ||
| .venv/ | ||
| __integration_*__/ | ||
| __pycache__/ | ||
| __test_fixtures__/ | ||
|
|
||
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 |
|---|---|---|
| @@ -1,12 +1,136 @@ | ||
| param( | ||
| [string]$BuildId | ||
| ) | ||
| <# | ||
| .SYNOPSIS | ||
| Installs MSBench CLI and runs a Copilot Azure benchmark. | ||
|
|
||
| .DESCRIPTION | ||
| This script runs in Azure DevOps under an AzureCLI@2 task with federated authentication. | ||
| It acquires an Azure DevOps AAD token from the already-authenticated az CLI session, | ||
| constructs an authenticated pip index URL, installs MSBench CLI from the | ||
| MicrosoftSweBench Azure Artifacts feed, and invokes: | ||
| msbench-cli run --agent github-copilot-cli --benchmark <benchmark> --model <model> | ||
|
|
||
| MSBench CLI reference: | ||
| - https://github.com/devdiv-microsoft/MicrosoftSweBench/wiki | ||
|
|
||
| # Install MSBench CLI | ||
| Write-Host "Installing keyring" | ||
| pip install keyring artifacts-keyring | ||
| .PARAMETER Benchmark | ||
| Benchmark identifier. Default: azure | ||
|
|
||
| Write-Host "Listing key vaults in the resource group" | ||
| az keyvault list --resource-group rg-msbench-eval-kv-azure-mcp --query "[].name" -o tsv | ||
| .PARAMETER Model | ||
hallipr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Model identifier. Default: claude-sonnet-4.5-autodev-test | ||
|
|
||
| .PARAMETER NoWait | ||
| Whether to add --no-wait to the run command. | ||
|
|
||
hallipr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| .LINK | ||
| https://github.com/devdiv-microsoft/MicrosoftSweBench/wiki | ||
| #> | ||
|
|
||
| param( | ||
| [string]$Benchmark = "azure", | ||
| [string]$Model = "claude-sonnet-4.5-autodev-test", | ||
| [switch]$NoWait | ||
| ) | ||
|
|
||
| Set-StrictMode -Version Latest | ||
| $ErrorActionPreference = "Stop" | ||
|
|
||
| if (!$Benchmark) { | ||
| throw "Benchmark parameter is required." | ||
| } | ||
|
|
||
| if (!$Model) { | ||
| throw "Model parameter is required." | ||
| } | ||
|
|
||
| $vaultName = "kv-msbench-eval-azuremcp" | ||
| $secretName = "azure-eval-gh-pat" | ||
|
|
||
| Write-Host "Benchmark: $Benchmark" | ||
| Write-Host "Model: $Model" | ||
| Write-Host "NoWait: $NoWait" | ||
|
|
||
| $pipelineRun = $env:TF_BUILD -eq "True" | ||
|
|
||
| # --- Retrieve GitHub PAT from KeyVault --- | ||
| try { | ||
| Write-Host "Retrieving GitHub PAT from KeyVault $vaultName secret $secretName" | ||
| $pat = az keyvault secret show --vault-name $vaultName --name $secretName --query value -o tsv | ||
|
|
||
| if (!$pat) { | ||
| throw "Secret $secretName not found in KeyVault $vaultName." | ||
| } | ||
|
|
||
| $env:GITHUB_MCP_SERVER_TOKEN = $pat | ||
|
|
||
| # Log the PAT as a secret variable to avoid exposing it in logs | ||
| if ($pipelineRun) { | ||
| Write-Host "##vso[task.setsecret]$pat" | ||
| } | ||
| } | ||
| catch { | ||
| throw "Failed to retrieve GitHub PAT from KeyVault: $_" | ||
| } | ||
|
|
||
| # --- Authenticate to Azure DevOps Artifacts feed via AAD token --- | ||
| Write-Host "Acquiring Azure DevOps AAD token for feed authentication" | ||
| $adoResourceId = "499b84ac-1321-427f-aa17-267ca6975798" | ||
| $adoAccessToken = az account get-access-token --resource $adoResourceId --query accessToken -o tsv | ||
|
|
||
| if (!$adoAccessToken) { | ||
| throw "Failed to acquire Azure DevOps AAD access token. Ensure the AzureCLI@2 task has a valid service connection." | ||
| } | ||
|
|
||
| # Log the token as a secret variable to avoid exposing it in logs | ||
| if ($pipelineRun) { | ||
| Write-Host "##vso[task.setsecret]$adoAccessToken" | ||
| } | ||
|
|
||
| $encodedToken = [System.Uri]::EscapeDataString($adoAccessToken) | ||
| $indexUrl = "https://vsts:$encodedToken@pkgs.dev.azure.com/devdiv/_packaging/MicrosoftSweBench/pypi/simple/" | ||
hallipr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Write-Host "Authenticated pip index URL constructed." | ||
|
|
||
| $pythonCommand = Get-Command python | ||
| Write-Host "Using python from: $($pythonCommand.Path). Version: $(python --version)" | ||
hallipr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| Write-Host "Install/upgrade pip" | ||
| python -m pip install --upgrade pip | ||
| if ($LASTEXITCODE -ne 0) { | ||
| throw "pip install/upgrade failed with exit code $LASTEXITCODE" | ||
| } | ||
|
|
||
| Write-Host "Checking MSBench CLI versions from feed" | ||
| python -m pip index versions msbench-cli --no-input --index-url $indexUrl | ||
| if ($LASTEXITCODE -ne 0) { | ||
| throw "pip index versions failed with exit code $LASTEXITCODE" | ||
| } | ||
|
|
||
| Write-Host "Installing/upgrading MSBench CLI" | ||
| python -m pip install --upgrade msbench-cli --no-input --index-url $indexUrl | ||
| if ($LASTEXITCODE -ne 0) { | ||
| throw "pip install msbench-cli failed with exit code $LASTEXITCODE" | ||
| } | ||
|
|
||
| Write-Host "MSBench CLI version" | ||
| & 'msbench-cli' version | ||
hallipr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if ($LASTEXITCODE -ne 0) { | ||
| throw "msbench-cli version command failed with exit code $LASTEXITCODE" | ||
| } | ||
|
|
||
| $runArgs = @( | ||
| "run", | ||
| "--agent", "github-copilot-cli", | ||
| "--benchmark", $Benchmark, | ||
| "--model", $Model, | ||
| "--env", "GITHUB_MCP_SERVER_TOKEN" | ||
| ) | ||
|
|
||
| if ($NoWait) { | ||
| $runArgs += "--no-wait" | ||
| } | ||
|
|
||
| Write-Host "Running: msbench-cli $($runArgs -join ' ')" | ||
| & 'msbench-cli' @runArgs | ||
|
|
||
| if ($LASTEXITCODE -ne 0) { | ||
| throw "msbench-cli run failed with exit code $LASTEXITCODE" | ||
| } | ||
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.