From 60e2c8b6ce792f3c4a0dfe7d3230a19ee451df36 Mon Sep 17 00:00:00 2001 From: "Haoran Sun (Business Central)" Date: Fri, 27 Nov 2026 12:49:54 +0100 Subject: [PATCH 1/2] Move Copilot evaluation and dataset validation to Azure DevOps pipelines GitHub's federated identity credentials for the BC-Bench app are blocked, so every workflow that signed in to Azure fails. Copilot evaluation and dataset validation now run as 1ES Azure DevOps pipelines in .azuredevops/ on the BC-Evals pools; the other evaluation workflows, their summarize/requeue helpers, and collect-and-screen are removed. CI summarizes its mock results locally instead of uploading them. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .azuredevops/.npmrc | 2 + .azuredevops/copilot-evaluation.yml | 94 +++++++ .azuredevops/dataset-validation.yml | 171 +++++++++++++ .../templates/copilot-evaluation-jobs.yml | 237 ++++++++++++++++++ .azuredevops/templates/get-github-token.yml | 9 + .azuredevops/templates/install-copilot.yml | 31 +++ .azuredevops/templates/list-entries-job.yml | 50 ++++ .azuredevops/templates/pipeline.yml | 26 ++ .../templates/remove-bc-container.yml | 12 + .azuredevops/templates/setup-bc.yml | 70 ++++++ .azuredevops/templates/setup-environment.yml | 82 ++++++ .azuredevops/templates/variables.yml | 37 +++ .github/actions/install-bcal/action.yml | 88 ------- .../setup-bc-container-repo/action.yml | 113 --------- .github/skills/update-agent-harness/SKILL.md | 2 +- .github/workflows/CI.yml | 27 +- .github/workflows/bcal-evaluation.yml | 216 ---------------- .github/workflows/claude-evaluation.yml | 196 --------------- .github/workflows/collect-and-screen.yml | 83 ------ .github/workflows/contamination.yml | 1 - .github/workflows/copilot-evaluation.yml | 199 --------------- .github/workflows/dataset-validation.yml | 130 ---------- .github/workflows/pin-evaluation-commit.yml | 43 ---- .github/workflows/pr-review-evaluation.yml | 177 ------------- .github/workflows/requeue-evaluation.yml | 87 ------- .github/workflows/summarize-results.yml | 172 ------------- CATEGORIES.md | 2 +- CONTRIBUTING.md | 19 +- EXPERIMENT.md | 25 +- README.md | 2 +- docs/code-review.md | 2 +- pyproject.toml | 2 +- scripts/Collect-And-Screen.ps1 | 105 -------- src/bcbench/results/base.py | 2 +- tests/test_agent_harness_action.py | 80 ++++++ tests/test_azure_pipelines.py | 50 ++++ tests/test_bcal_dataset_workflow.py | 130 ---------- tests/test_review_workflows.py | 205 --------------- 38 files changed, 989 insertions(+), 1990 deletions(-) create mode 100644 .azuredevops/.npmrc create mode 100644 .azuredevops/copilot-evaluation.yml create mode 100644 .azuredevops/dataset-validation.yml create mode 100644 .azuredevops/templates/copilot-evaluation-jobs.yml create mode 100644 .azuredevops/templates/get-github-token.yml create mode 100644 .azuredevops/templates/install-copilot.yml create mode 100644 .azuredevops/templates/list-entries-job.yml create mode 100644 .azuredevops/templates/pipeline.yml create mode 100644 .azuredevops/templates/remove-bc-container.yml create mode 100644 .azuredevops/templates/setup-bc.yml create mode 100644 .azuredevops/templates/setup-environment.yml create mode 100644 .azuredevops/templates/variables.yml delete mode 100644 .github/actions/install-bcal/action.yml delete mode 100644 .github/actions/setup-bc-container-repo/action.yml delete mode 100644 .github/workflows/bcal-evaluation.yml delete mode 100644 .github/workflows/claude-evaluation.yml delete mode 100644 .github/workflows/collect-and-screen.yml delete mode 100644 .github/workflows/copilot-evaluation.yml delete mode 100644 .github/workflows/dataset-validation.yml delete mode 100644 .github/workflows/pin-evaluation-commit.yml delete mode 100644 .github/workflows/pr-review-evaluation.yml delete mode 100644 .github/workflows/requeue-evaluation.yml delete mode 100644 .github/workflows/summarize-results.yml delete mode 100644 scripts/Collect-And-Screen.ps1 create mode 100644 tests/test_agent_harness_action.py create mode 100644 tests/test_azure_pipelines.py delete mode 100644 tests/test_bcal_dataset_workflow.py delete mode 100644 tests/test_review_workflows.py diff --git a/.azuredevops/.npmrc b/.azuredevops/.npmrc new file mode 100644 index 000000000..5536d58c6 --- /dev/null +++ b/.azuredevops/.npmrc @@ -0,0 +1,2 @@ +registry=https://dynamicssmb2.pkgs.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_packaging/BC_NpmFeed/npm/registry/ +always-auth=true diff --git a/.azuredevops/copilot-evaluation.yml b/.azuredevops/copilot-evaluation.yml new file mode 100644 index 000000000..063decf17 --- /dev/null +++ b/.azuredevops/copilot-evaluation.yml @@ -0,0 +1,94 @@ +# Evaluates GitHub Copilot CLI on one BC-Bench category: one entry per parallel job, then one job summarizes the run, +# uploads its scores to Kusto through bc-eval, and pushes a leaderboard// branch to merge. +# Categories that need a BC container run on the Windows pool, the others on the Linux pool (shared with BC-Evals). +trigger: none +pr: none + +parameters: +- name: category + displayName: Category + type: string + default: bug-fix + values: + - bug-fix + - test-generation + - code-review + - data-query + - extensibility-request-advisor + - extensibility-request-implement + - extensibility-request-triage +- name: model + displayName: Copilot model + type: string + default: gpt-5.6-luna + values: + - claude-sonnet-5 + - claude-opus-5 + - gpt-5.6-sol + - gpt-5.6-terra + - gpt-5.6-luna + - gpt-5.3-codex + - mai-code-1.1-flash + - gemini-3.7-flash +- name: test_run + displayName: Test run (a few random entries; nothing is published) + type: boolean + default: true +- name: al_mcp + displayName: Enable AL MCP server + type: boolean + default: false +- name: al_lsp + displayName: Enable AL LSP server + type: boolean + default: false +- name: bc_mcp + displayName: Enable the Business Central MCP server + type: boolean + default: false +- name: update_leaderboard + displayName: Push a leaderboard branch (full runs only) + type: boolean + default: true +- name: max_parallel + displayName: Maximum entries running at the same time + type: number + default: 20 + +variables: +- template: /.azuredevops/templates/variables.yml@self + +resources: + repositories: + - repository: 1esPipelines + type: git + name: 1ESPipelineTemplates/1ESPipelineTemplates + ref: refs/tags/release + # Internal dataset repository, cloned by scripts/Setup-ContainerAndRepository.ps1 with the build identity's token. + # Jobs that clone it declare `uses`, which grants that token access without checking it out. + - repository: NAV + type: git + name: Dynamics SMB/NAV + +extends: + template: /.azuredevops/templates/pipeline.yml@self + parameters: + stages: + - stage: evaluate + displayName: Copilot ${{ parameters.model }} on ${{ parameters.category }}${{ iif(parameters.test_run, ' (test run)', '') }} + jobs: + - template: /.azuredevops/templates/copilot-evaluation-jobs.yml@self + parameters: + category: ${{ parameters.category }} + model: ${{ parameters.model }} + test_run: ${{ parameters.test_run }} + al_mcp: ${{ parameters.al_mcp }} + al_lsp: ${{ parameters.al_lsp }} + bc_mcp: ${{ parameters.bc_mcp }} + update_leaderboard: ${{ parameters.update_leaderboard }} + max_parallel: ${{ parameters.max_parallel }} + # Keep in step with .github/actions/install-agent-harnesses/action.yml. + copilot_version: 1.0.82 + # Must match EvaluationCategory.requires_container and requires_repo (tests/test_azure_pipelines.py). + container: ${{ in(parameters.category, 'bug-fix', 'test-generation', 'data-query') }} + skip_repo: ${{ in(parameters.category, 'data-query') }} diff --git a/.azuredevops/dataset-validation.yml b/.azuredevops/dataset-validation.yml new file mode 100644 index 000000000..c18d5c2b0 --- /dev/null +++ b/.azuredevops/dataset-validation.yml @@ -0,0 +1,171 @@ +# Verifies that every bug-fix entry still builds and its tests still run in a BC container, catching regressions from +# infrastructure changes. The weekly scheduled run also resolves the latest public BC artifact URLs, verifies the full +# dataset against them, and pushes an artifacts/refresh- branch with the new scripts/BCBenchArtifactPins.json +# for a manual PR. Manual runs use the saved pins. +trigger: none +pr: none + +schedules: +- cron: "0 0 * * 0" + displayName: Weekly validation with refreshed BC artifacts + branches: + include: + - main + always: true + +parameters: +# Defaults apply to the scheduled run. +- name: test_run + displayName: Test run (a few random entries) + type: boolean + default: false +- name: modified_only + displayName: Only entries added or modified compared to main + type: boolean + default: false +- name: max_parallel + displayName: Maximum entries running at the same time + type: number + default: 20 + +variables: +- template: /.azuredevops/templates/variables.yml@self + +resources: + repositories: + - repository: 1esPipelines + type: git + name: 1ESPipelineTemplates/1ESPipelineTemplates + ref: refs/tags/release + # Internal dataset repository, cloned by scripts/Setup-ContainerAndRepository.ps1 with the build identity's token. + # Jobs that clone it declare `uses`, which grants that token access without checking it out. + - repository: NAV + type: git + name: Dynamics SMB/NAV + +extends: + template: /.azuredevops/templates/pipeline.yml@self + parameters: + stages: + - stage: validate + displayName: Dataset validation${{ iif(parameters.test_run, ' (test run)', '') }} + jobs: + - template: /.azuredevops/templates/list-entries-job.yml@self + parameters: + category: bug-fix + test_run: ${{ parameters.test_run }} + modified_only: ${{ parameters.modified_only }} + + - job: pins + displayName: Resolve the latest BC artifact URLs + condition: eq(variables['Build.Reason'], 'Schedule') + steps: + - template: /.azuredevops/templates/setup-environment.yml@self + + - task: DownloadPackage@1 + displayName: Download BcContainerHelper + inputs: + packageType: nuget + feed: /DynamicsSMBPackages + definition: BcContainerHelper + version: latest + downloadPath: $(Agent.TempDirectory)/BcContainerHelper + + - task: PowerShell@2 + name: refresh + displayName: Resolve the latest artifact URLs + inputs: + pwsh: true + targetType: inline + workingDirectory: $(Build.SourcesDirectory) + script: | + $ErrorActionPreference = 'Stop' + Import-Module "$(Agent.TempDirectory)/BcContainerHelper/BcContainerHelper.psd1" -Force -DisableNameChecking + Import-Module ./scripts/BenchmarkUtils.psm1 -Force -DisableNameChecking + $json = (Get-BCBenchLatestArtifactUrls | ConvertTo-Json -Depth 2) + "`n" + Write-Host $json + $pins = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($json)) + Write-Host "##vso[task.setvariable variable=pins;isOutput=true]$pins" + + - job: verify + displayName: Verify + dependsOn: [list_entries, pins] + condition: >- + and(not(canceled()), + eq(dependencies.list_entries.result, 'Succeeded'), + ne(dependencies.list_entries.outputs['entries.count'], '0'), + in(dependencies.pins.result, 'Succeeded', 'Skipped')) + timeoutInMinutes: 120 + uses: + repositories: + - NAV + pool: + name: $(eval_pool_windows) + os: windows + strategy: + matrix: $[ dependencies.list_entries.outputs['entries.matrix'] ] + maxParallel: ${{ parameters.max_parallel }} + variables: + Pins: $[ dependencies.pins.outputs['refresh.pins'] ] + steps: + - template: /.azuredevops/templates/setup-environment.yml@self + parameters: + os: windows + + - task: PowerShell@2 + displayName: Use the refreshed artifact URLs + condition: and(succeeded(), eq(variables['Build.Reason'], 'Schedule')) + inputs: + pwsh: true + targetType: inline + workingDirectory: $(Build.SourcesDirectory) + script: '[IO.File]::WriteAllBytes((Join-Path scripts BCBenchArtifactPins.json), [Convert]::FromBase64String("$(Pins)"))' + + - template: /.azuredevops/templates/get-github-token.yml@self + + - template: /.azuredevops/templates/setup-bc.yml@self + parameters: + category: bug-fix + github_token: $(CopilotFunctionalGithubToken) + + - task: PowerShell@2 + displayName: Verify build and tests of $(EntryId) + timeoutInMinutes: 60 + env: + ENTRY_ID: $(EntryId) + BC_SERVER_PASSWORD: $(BC_SERVER_PASSWORD) + inputs: + pwsh: true + targetType: inline + workingDirectory: $(Build.SourcesDirectory) + script: ./scripts/Verify-BuildAndTests.ps1 -InstanceId $env:ENTRY_ID -RepoPath ([IO.Path]::GetFullPath("$(RepoPath)")) + + - template: /.azuredevops/templates/remove-bc-container.yml@self + + - job: propose_pins + displayName: Push the verified artifact URLs + dependsOn: [pins, verify] + condition: and(succeeded(), eq(variables['Build.Reason'], 'Schedule')) + variables: + Pins: $[ dependencies.pins.outputs['refresh.pins'] ] + steps: + - checkout: self + persistCredentials: true + + - bash: | + set -euo pipefail + path=scripts/BCBenchArtifactPins.json + echo "$(Pins)" | base64 --decode > "$path" + if git diff --quiet -- "$path"; then + echo "The pinned artifact URLs are already the latest." + exit 0 + fi + branch="artifacts/refresh-$(Build.BuildId)-$(System.JobAttempt)" + git config user.name "BC-Bench pipeline" + git config user.email "bc-bench-pipeline@users.noreply.github.com" + git switch -c "$branch" + git add "$path" + git commit -m "Refresh pinned BC artifact URLs" + git push origin "$branch" + echo "Open a PR from $branch to update the pins." + displayName: Push a branch with the refreshed pins diff --git a/.azuredevops/templates/copilot-evaluation-jobs.yml b/.azuredevops/templates/copilot-evaluation-jobs.yml new file mode 100644 index 000000000..af017f91e --- /dev/null +++ b/.azuredevops/templates/copilot-evaluation-jobs.yml @@ -0,0 +1,237 @@ +# Jobs of .azuredevops/copilot-evaluation.yml. +# Scoring runs only if every entry job succeeded, so incomplete runs are never published: re-run the failed jobs first. +parameters: +- name: category + type: string +- name: model + type: string +- name: test_run + type: boolean +- name: al_mcp + type: boolean +- name: al_lsp + type: boolean +- name: bc_mcp + type: boolean +- name: update_leaderboard + type: boolean +- name: max_parallel + type: number +- name: copilot_version + type: string +# Whether the category needs a BC container, which runs on the Windows pool. +- name: container + type: boolean +- name: skip_repo + type: boolean + +jobs: +- template: /.azuredevops/templates/list-entries-job.yml@self + parameters: + category: ${{ parameters.category }} + test_run: ${{ parameters.test_run }} + +- job: evaluate + displayName: Evaluate + dependsOn: list_entries + condition: and(succeeded(), ne(dependencies.list_entries.outputs['entries.count'], '0')) + timeoutInMinutes: 180 + uses: + repositories: + - NAV + strategy: + matrix: $[ dependencies.list_entries.outputs['entries.matrix'] ] + maxParallel: ${{ parameters.max_parallel }} + ${{ if parameters.container }}: + pool: + name: $(eval_pool_windows) + os: windows + templateContext: + outputs: + - output: pipelineArtifact + displayName: Publish the entry's results + condition: succeeded() + targetPath: $(ResultsDir) + artifactName: results_$(EntryId) + # A failed attempt keeps its own name, so re-running the failed job can still publish results_. + - output: pipelineArtifact + displayName: Publish the failed attempt's results + condition: or(failed(), canceled()) + targetPath: $(ResultsDir) + artifactName: results_$(EntryId)_failed_$(System.JobAttempt) + steps: + # Published even when the job fails before writing any results, and publishing a missing folder fails. + - ${{ if parameters.container }}: + - powershell: New-Item -ItemType Directory -Force -Path "$(ResultsDir)" | Out-Null + displayName: Create the results folder + - ${{ else }}: + - bash: mkdir -p "$(ResultsDir)" + displayName: Create the results folder + + - template: /.azuredevops/templates/setup-environment.yml@self + parameters: + os: ${{ iif(parameters.container, 'windows', 'linux') }} + + - template: /.azuredevops/templates/get-github-token.yml@self + + - template: /.azuredevops/templates/setup-bc.yml@self + parameters: + category: ${{ parameters.category }} + skip_container: ${{ not(parameters.container) }} + skip_repo: ${{ parameters.skip_repo }} + bc_mcp: ${{ parameters.bc_mcp }} + github_token: $(CopilotFunctionalGithubToken) + + - ${{ if or(parameters.al_mcp, parameters.al_lsp) }}: + # The AL tool targets .NET 8 for BC versions before 29. + - task: UseDotNet@2 + displayName: Install .NET 8 runtime + inputs: + packageType: runtime + version: 8.x + + - task: PowerShell@2 + displayName: Install AL Tool + env: + ENTRY_ID: $(EntryId) + inputs: + pwsh: true + targetType: inline + workingDirectory: $(Build.SourcesDirectory) + script: | + $ErrorActionPreference = 'Stop' + $PSNativeCommandUseErrorActionPreference = $true + Import-Module ./scripts/BenchmarkUtils.psm1 -Force -DisableNameChecking + $version = Get-BCBenchEntryVersion -InstanceId $env:ENTRY_ID -Category "${{ parameters.category }}" + $framework = if (([System.Version]$version).Major -lt 29) { '8.0' } else { '10.0' } + dotnet tool install --global Microsoft.Dynamics.BusinessCentral.Development.Tools --version 18.0.37.11445-beta --framework "net$framework" --source $(nuget_feed) + + - template: /.azuredevops/templates/install-copilot.yml@self + parameters: + copilot_version: ${{ parameters.copilot_version }} + + - task: PowerShell@2 + displayName: Run GitHub Copilot CLI on $(EntryId) + timeoutInMinutes: 120 + env: + ENTRY_ID: $(EntryId) + COPILOT_GITHUB_TOKEN: $(CopilotFunctionalGithubToken) + GH_TOKEN: $(CopilotFunctionalGithubToken) + ${{ if parameters.container }}: + BC_SERVER_PASSWORD: $(BC_SERVER_PASSWORD) + inputs: + pwsh: true + targetType: inline + workingDirectory: $(Build.SourcesDirectory) + script: | + uv run bcbench evaluate copilot $env:ENTRY_ID ` + --model "${{ parameters.model }}" ` + --category "${{ parameters.category }}" ` + --repo-path ([IO.Path]::GetFullPath("$(RepoPath)")) ` + --output-dir "$(ResultsDir)" ${{ iif(parameters.al_mcp, '--al-mcp', '') }} ${{ iif(parameters.al_lsp, '--al-lsp', '') }} ${{ iif(parameters.bc_mcp, '--bc-mcp', '') }} + exit $LASTEXITCODE + + - ${{ if parameters.container }}: + - template: /.azuredevops/templates/remove-bc-container.yml@self + +- job: summarize + displayName: ${{ iif(parameters.test_run, 'Summarize (test run, not published)', 'Summarize and publish') }} + dependsOn: evaluate + timeoutInMinutes: 30 + variables: + SummaryDir: $(ResultsDir)/$(Build.BuildId) + templateContext: + outputs: + - output: pipelineArtifact + displayName: Publish the evaluation summary + condition: always() + targetPath: $(SummaryDir) + artifactName: summary_$(System.JobAttempt) + steps: + - checkout: self + # The leaderboard step pushes a branch with the pipeline's GitHub connection. + persistCredentials: true + + - bash: mkdir -p "$(SummaryDir)" + displayName: Create the summary folder + + - template: /.azuredevops/templates/setup-environment.yml@self + + - task: DownloadPipelineArtifact@2 + displayName: Download every entry's results + inputs: + buildType: current + itemPattern: "**/*.jsonl" + targetPath: $(Pipeline.Workspace)/entries + + - bash: | + set -euo pipefail + # A retried entry leaves its failed attempt's artifact beside the successful one; only the successful attempt counts. + for artifact in "$(Pipeline.Workspace)"/entries/results_*/; do + case "$artifact" in *_failed_[0-9]*/) continue ;; esac + cp -R "$artifact". "$(ResultsDir)/" + done + displayName: Combine the entries' results + + - task: PowerShell@2 + displayName: Summarize results + inputs: + pwsh: true + targetType: inline + workingDirectory: $(Build.SourcesDirectory) + script: | + $ErrorActionPreference = 'Stop' + $PSNativeCommandUseErrorActionPreference = $true + $branch = $env:BUILD_SOURCEBRANCH -replace '^refs/heads/', '' + uv run bcbench result summarize --category "${{ parameters.category }}" --result-dir "$(ResultsDir)" --bceval-output bceval_results.jsonl --summary-output evaluation_summary.json --git-ref $branch + + - task: AzureCLI@2 + displayName: ${{ iif(parameters.test_run, 'Score with bc-eval (not uploaded)', 'Score with bc-eval and upload to Kusto') }} + env: + EVALUATION_AGENT: GitHub Copilot CLI + EVALUATION_MODEL: ${{ parameters.model }} + EVALUATION_TIER: gold + inputs: + azureSubscription: dynamicssmb2-Dynamics SMB-NavInfrastructure-Test + scriptType: bash + scriptLocation: inlineScript + workingDirectory: $(Build.SourcesDirectory) + inlineScript: | + set -euo pipefail + # bcbench writes step outputs in the GitHub Actions format. + export GITHUB_OUTPUT="$(mktemp)" + uv run bcbench category bceval-config --category "${{ parameters.category }}" + while IFS='=' read -r key value; do declare "bceval_${key}=${value}"; done < "$GITHUB_OUTPUT" + export JUDGE_MODEL="${bceval_judge_model:-}" + + uv tool install bc-eval==0.11.1 --python 3.13 --index "$PIP_INDEX_URL" + + branch="${BUILD_SOURCEBRANCH#refs/heads/}" + run_tags="${EVALUATION_AGENT},${EVALUATION_MODEL//./-},${branch//./-},tier-${EVALUATION_TIER}" + bceval metrics calculate \ + --feature-name "BC-Bench" \ + --eval-suite-name "${{ parameters.category }}" \ + --eval-run-name "${EVALUATION_AGENT} (${EVALUATION_MODEL}) - #$(Build.BuildId)" \ + --tags "$run_tags" \ + --source "$(Build.SourceVersion)" \ + --input-file "$(SummaryDir)/bceval_results.jsonl" \ + --evaluator-definitions "$(Build.SourcesDirectory)/evaluator/scores.py" \ + --evaluators "$bceval_evaluators" \ + --core-score "$bceval_core_score" \ + --metric-definitions "$(Build.SourcesDirectory)/evaluator/metrics.py" \ + --metrics "bc_bench_metrics" ${{ iif(parameters.test_run, '', '--storage kusto') }} + + - ${{ if and(not(parameters.test_run), parameters.update_leaderboard) }}: + - bash: | + set -euo pipefail + branch="leaderboard/${{ parameters.category }}/$(Build.BuildId)" + git config user.name "BC-Bench pipeline" + git config user.email "bc-bench-pipeline@users.noreply.github.com" + git fetch --no-tags origin main + git checkout -b "$branch" FETCH_HEAD + uv run bcbench result update "$(SummaryDir)/evaluation_summary.json" + git add "docs/_data/${{ parameters.category }}.json" + git commit -m "Update leaderboard: GitHub Copilot CLI (${{ parameters.model }}) - Build $(Build.BuildId)" + git push origin "$branch" + echo "Merge $branch to publish the run to the leaderboard." + displayName: Push a leaderboard branch diff --git a/.azuredevops/templates/get-github-token.yml b/.azuredevops/templates/get-github-token.yml new file mode 100644 index 000000000..f2edcd3b9 --- /dev/null +++ b/.azuredevops/templates/get-github-token.yml @@ -0,0 +1,9 @@ +# Fetches the github.com token (Copilot requests and public clones) from BC-Evals' Key Vault as $(CopilotFunctionalGithubToken). +steps: +- task: AzureKeyVault@2 + displayName: Fetch GitHub token + inputs: + azureSubscription: dynamicssmb2-Dynamics SMB-NavInfrastructure-Test + KeyVaultName: bc-ai-eval-pipelines + SecretsFilter: CopilotFunctionalGithubToken + RunAsPreJob: false diff --git a/.azuredevops/templates/install-copilot.yml b/.azuredevops/templates/install-copilot.yml new file mode 100644 index 000000000..3152478ec --- /dev/null +++ b/.azuredevops/templates/install-copilot.yml @@ -0,0 +1,31 @@ +# Installs the pinned GitHub Copilot CLI from BC_NpmFeed (an npmjs mirror). +# Keep copilot_version in step with .github/actions/install-agent-harnesses/action.yml. +parameters: +- name: copilot_version + type: string + +steps: +- task: UseNode@1 + displayName: Install Node.js + inputs: + version: 24.x + +- task: npmAuthenticate@0 + displayName: Authenticate npm with Azure Artifacts + inputs: + workingFile: $(Build.SourcesDirectory)/.azuredevops/.npmrc + +- task: PowerShell@2 + displayName: Install GitHub Copilot CLI ${{ parameters.copilot_version }} + retryCountOnTaskFailure: 2 + env: + # Global installs do not read a project-level .npmrc. + NPM_CONFIG_USERCONFIG: $(Build.SourcesDirectory)/.azuredevops/.npmrc + inputs: + pwsh: true + targetType: inline + script: | + $ErrorActionPreference = 'Stop' + $PSNativeCommandUseErrorActionPreference = $true + npm install --global "@github/copilot@${{ parameters.copilot_version }}" + copilot --version diff --git a/.azuredevops/templates/list-entries-job.yml b/.azuredevops/templates/list-entries-job.yml new file mode 100644 index 000000000..bb2ccde21 --- /dev/null +++ b/.azuredevops/templates/list-entries-job.yml @@ -0,0 +1,50 @@ +# Lists a category's dataset entries as a job matrix (output entries.matrix, one EntryId per job) and their count (entries.count). +parameters: +- name: category + type: string +- name: test_run + type: boolean + default: false +- name: modified_only + type: boolean + default: false + +jobs: +- job: list_entries + displayName: List entries + steps: + - checkout: self + ${{ if parameters.modified_only }}: + fetchDepth: 0 + + - template: /.azuredevops/templates/setup-environment.yml@self + + - task: PowerShell@2 + name: entries + displayName: List ${{ parameters.category }} entries + inputs: + pwsh: true + targetType: inline + workingDirectory: $(Build.SourcesDirectory) + script: | + $ErrorActionPreference = 'Stop' + $PSNativeCommandUseErrorActionPreference = $true + if ('${{ parameters.modified_only }}' -eq 'True') { + git fetch --no-tags origin main:refs/remotes/origin/main + } + # bcbench writes step outputs in the GitHub Actions format. + $env:GITHUB_OUTPUT = New-TemporaryFile + uv run bcbench dataset list --category "${{ parameters.category }}" --github-output entries ${{ iif(parameters.modified_only, '--modified-only', iif(parameters.test_run, '--test-run', '')) }} + $line = Get-Content $env:GITHUB_OUTPUT | Where-Object { $_.StartsWith('entries=') } + $ids = @($line.Substring('entries='.Length) | ConvertFrom-Json) + + # Matrix keys name the jobs: letters, digits and underscores, at most 100 characters. The ordinal keeps them unique. + $matrix = [ordered]@{} + $n = 0 + foreach ($id in $ids) { + $n++ + $key = ('e{0:d3}_{1}' -f $n, ($id -replace '\W', '_')) + $matrix[$key.Substring(0, [Math]::Min(100, $key.Length))] = @{ EntryId = $id } + } + Write-Host "##vso[task.setvariable variable=matrix;isOutput=true]$($matrix | ConvertTo-Json -Compress)" + Write-Host "##vso[task.setvariable variable=count;isOutput=true]$($ids.Count)" diff --git a/.azuredevops/templates/pipeline.yml b/.azuredevops/templates/pipeline.yml new file mode 100644 index 000000000..e1ccda567 --- /dev/null +++ b/.azuredevops/templates/pipeline.yml @@ -0,0 +1,26 @@ +# 1ES Pipeline Templates (https://aka.ms/1espt) wrapper, mirroring BC-Evals' .pipelines/common/1es-eval-pipeline.yml. +# Publish artifacts through templateContext.outputs on each job: 1ES PT rejects plain publish steps. +parameters: +- name: stages + type: stageList + +extends: + template: v1/1ES.Unofficial.PipelineTemplate.yml@1esPipelines + parameters: + pool: + name: $(eval_pool_linux) + os: linux + settings: + networkIsolationPolicy: Permissive,CFSClean2 + sdl: + # The source-scanning tools only run on Windows. + sourceAnalysisPool: + name: $(eval_pool_windows) + os: windows + policheck: + break: true + # The internal NAV repository is declared only so the build identity can clone dataset entries from it. + sourceRepositoriesToScan: + exclude: + - repository: NAV + stages: ${{ parameters.stages }} diff --git a/.azuredevops/templates/remove-bc-container.yml b/.azuredevops/templates/remove-bc-container.yml new file mode 100644 index 000000000..16edeb202 --- /dev/null +++ b/.azuredevops/templates/remove-bc-container.yml @@ -0,0 +1,12 @@ +# Removes the BC container setup-bc.yml created: pool VMs are reused, and the setup refuses an existing container. +steps: +- task: PowerShell@2 + displayName: Remove BC container + condition: always() + inputs: + pwsh: true + targetType: inline + script: | + if (-not $env:BC_CONTAINER_NAME) { return } + Import-Module BcContainerHelper -DisableNameChecking + Remove-BcContainer -containerName $env:BC_CONTAINER_NAME diff --git a/.azuredevops/templates/setup-bc.yml b/.azuredevops/templates/setup-bc.yml new file mode 100644 index 000000000..f36fcf6c8 --- /dev/null +++ b/.azuredevops/templates/setup-bc.yml @@ -0,0 +1,70 @@ +# Creates the entry's BC container and clones its repository, through scripts/Setup-ContainerAndRepository.ps1. +# Exports BC_CONTAINER_NAME, BC_SERVER_URL, BC_SERVER_INSTANCE, BC_SERVER_USERNAME, BC_COMPANY (and BC_MCP_URL) as variables, +# and BC_SERVER_PASSWORD as a secret one: map it into the env of the steps that need it. +parameters: +- name: category + type: string +- name: skip_container + type: boolean + default: false +- name: skip_repo + type: boolean + default: false +- name: bc_mcp + type: boolean + default: false +# github.com token for cloning public GitHub repositories +- name: github_token + type: string + +steps: +- ${{ if not(parameters.skip_container) }}: + # The PowerShell Gallery is blocked: DynamicsSMBPackages mirrors it, and the task authenticates as the build identity. + - task: DownloadPackage@1 + displayName: Download BcContainerHelper + inputs: + packageType: nuget + feed: /DynamicsSMBPackages + definition: BcContainerHelper + version: latest + downloadPath: $(Agent.TempDirectory)/Modules/BcContainerHelper + + - powershell: Write-Host "##vso[task.setvariable variable=PSModulePath]$(Agent.TempDirectory)\Modules;$env:PSModulePath" + displayName: Put BcContainerHelper on PSModulePath + +- task: PowerShell@2 + displayName: Set up ${{ iif(parameters.skip_container, 'repository', 'BC container and repository') }} for $(EntryId) + timeoutInMinutes: 40 + env: + ENTRY_ID: $(EntryId) + # The build identity reads the internal Azure DevOps repositories. + ADO_TOKEN: $(System.AccessToken) + GITHUB_TOKEN: ${{ parameters.github_token }} + inputs: + pwsh: true + targetType: inline + workingDirectory: $(Build.SourcesDirectory) + script: | + $ErrorActionPreference = 'Stop' + if ('${{ parameters.skip_container }}' -ne 'True') { + # Short-lived, only used for the duration of the job. + $password = -join ((48..57) + (65..90) + (97..122) | Get-Random -Count 32 | ForEach-Object { [char]$_ }) + Write-Host "##vso[task.setvariable variable=BC_SERVER_PASSWORD;issecret=true]$password" + $env:BC_SERVER_PASSWORD = $password + $name = "bcbench-$($env:ENTRY_ID.Split('-')[1])" + $container = [ordered]@{ BC_CONTAINER_NAME = $name; BC_SERVER_URL = "http://$name"; BC_SERVER_INSTANCE = 'BC'; BC_SERVER_USERNAME = 'admin' } + foreach ($key in $container.Keys) { + Write-Host "##vso[task.setvariable variable=$key]$($container[$key])" + Set-Item "env:$key" $container[$key] + } + } + + # The script exports variables in the GitHub Actions format. + $env:GITHUB_ENV = New-TemporaryFile + # Native separators: the folder is shared with the container. + $repoPath = [IO.Path]::GetFullPath("$(RepoPath)") + ./scripts/Setup-ContainerAndRepository.ps1 -InstanceId $env:ENTRY_ID -Category "${{ parameters.category }}" -RepoPath $repoPath ${{ iif(parameters.skip_container, '-SkipContainer', '') }} ${{ iif(parameters.skip_repo, '-SkipRepo', '') }} ${{ iif(parameters.bc_mcp, '-BcMcp', '') }} + Get-Content $env:GITHUB_ENV | ForEach-Object { + $key, $value = $_ -split '=', 2 + Write-Host "##vso[task.setvariable variable=$key]$value" + } diff --git a/.azuredevops/templates/setup-environment.yml b/.azuredevops/templates/setup-environment.yml new file mode 100644 index 000000000..35bafc28f --- /dev/null +++ b/.azuredevops/templates/setup-environment.yml @@ -0,0 +1,82 @@ +# Installs .NET 10, PowerShell 7, Python and uv, then syncs the bcbench environment. +# The pool images have neither PowerShell 7 nor (on Windows) Python, so both come from DynamicsSMBPackages. +parameters: +- name: os + type: string + default: linux + values: [linux, windows] + +steps: +- task: UseDotNet@2 + displayName: Install .NET 10 SDK + inputs: + packageType: sdk + version: 10.x + +- task: NuGetAuthenticate@1 + displayName: Authenticate .NET tool installs with Azure Artifacts + +- ${{ if eq(parameters.os, 'windows') }}: + - powershell: | + $ErrorActionPreference = 'Stop' + dotnet tool install --global PowerShell --version $(powershell_version) --source $(nuget_feed) + if ($LASTEXITCODE -ne 0) { throw "PowerShell 7 install failed (exit code $LASTEXITCODE)." } + Write-Host "##vso[task.prependpath]$HOME\.dotnet\tools" + displayName: Install PowerShell 7 + retryCountOnTaskFailure: 3 + + - task: DownloadPackage@1 + displayName: Download Python $(python_version) + inputs: + packageType: nuget + feed: /DynamicsSMBPackages + definition: python + version: $(python_version) + downloadPath: $(Agent.TempDirectory)\python + + - powershell: | + Write-Host "##vso[task.prependpath]$(Agent.TempDirectory)\python\tools\Scripts" + Write-Host "##vso[task.prependpath]$(Agent.TempDirectory)\python\tools" + displayName: Put Python on PATH +- ${{ else }}: + - bash: | + set -euo pipefail + dotnet tool install --global PowerShell --version $(powershell_version) --source $(nuget_feed) + echo "##vso[task.prependpath]$HOME/.dotnet/tools" + displayName: Install PowerShell 7 + retryCountOnTaskFailure: 3 + +- task: PipAuthenticate@1 + displayName: Authenticate pip with Azure Artifacts + inputs: + artifactFeeds: $(System.TeamProject)/$(python_feed) + onlyAddExtraIndex: false + +- task: PowerShell@2 + displayName: Install uv and sync bcbench + inputs: + pwsh: true + targetType: inline + workingDirectory: $(Build.SourcesDirectory) + script: | + $ErrorActionPreference = 'Stop' + $PSNativeCommandUseErrorActionPreference = $true + if ($IsWindows) { + python -m pip install "uv==$(uv_version)" + # Use the Python installed above rather than downloading one. + Write-Host "##vso[task.setvariable variable=UV_PYTHON_DOWNLOADS]never" + $env:UV_PYTHON_DOWNLOADS = 'never' + } + else { + # The agent isn't root: pip installs into the user scheme, whose scripts directory isn't on PATH. + python3 -m pip install --user "uv==$(uv_version)" + $bin = python3 -c "import os, sysconfig; print(sysconfig.get_path('scripts', f'{os.name}_user'))" + $env:PATH = "$bin$([IO.Path]::PathSeparator)$env:PATH" + Write-Host "##vso[task.prependpath]$bin" + } + # The proxy re-signs TLS; trust the system certificate store for downloads. + Write-Host "##vso[task.setvariable variable=UV_SYSTEM_CERTS]1" + $env:UV_SYSTEM_CERTS = '1' + uv --version + uv sync --frozen + Write-Host "##vso[task.setvariable variable=UV_NO_SYNC]1" diff --git a/.azuredevops/templates/variables.yml b/.azuredevops/templates/variables.yml new file mode 100644 index 000000000..b28d774ac --- /dev/null +++ b/.azuredevops/templates/variables.yml @@ -0,0 +1,37 @@ +variables: +# Shared with the BC-Evals eval pipelines: Linux runs orchestration and remote-repo categories, +# Windows runs the categories that need a BC container. +- name: eval_pool_linux + value: d365bc-agentpool-BC-Evals-Linux + readonly: true +- name: eval_pool_windows + value: d365bc-agentpool-BC-Evals-Win + readonly: true +# An exact release: Windows jobs install it from DynamicsSMBPackages, which needs one. +- name: python_version + value: 3.13.17 + readonly: true +- name: uv_version + value: 0.12.19 + readonly: true +- name: powershell_version + value: 7.6.6 + readonly: true +- name: nuget_feed + value: https://pkgs.dev.azure.com/dynamicssmb2/_packaging/DynamicsSMBPackages/nuget/v3/index.json + readonly: true +- name: python_feed + value: BC_PythonFeed + readonly: true +# bcbench reads the run ID from GITHUB_RUN_ID (src/bcbench/cli_options.py). +- name: GITHUB_RUN_ID + value: $(Build.BuildId) + readonly: true +# The pool VMs' managed identity has no access to the eval resources; bc-eval must use the Azure CLI that AzureCLI@2 signs in. +- name: AZURE_TOKEN_CREDENTIALS + value: AzureCliCredential + readonly: true +- name: ResultsDir + value: $(Build.SourcesDirectory)/evaluation_results +- name: RepoPath + value: $(Agent.TempDirectory)/testbed diff --git a/.github/actions/install-bcal/action.yml b/.github/actions/install-bcal/action.yml deleted file mode 100644 index fbb8d62de..000000000 --- a/.github/actions/install-bcal/action.yml +++ /dev/null @@ -1,88 +0,0 @@ -name: Install BCal -description: Install BCal from the internal feed, either the latest prerelease or an exact version - -inputs: - client-id: - description: Azure client ID for the ADO feed - required: true - tenant-id: - description: Azure tenant ID for the ADO feed - required: true - package-id: - description: BCal NuGet package ID - required: true - feed: - description: "Feed to install from: official, or experiment (the internal test feed)" - required: false - default: official - official-feed-url: - description: Official BCal NuGet feed URL - required: true - experiment-feed-url: - description: Internal test feed URL; required when feed is experiment - required: false - default: "" - version: - description: Exact NuGet version to install; empty installs the latest prerelease - required: false - default: "" - -runs: - using: composite - steps: - - name: Azure Login (OIDC) for ADO feed - uses: azure/login@a641126d1b8aa4d1fa005f4f92df94a3a4c4c906 # v3 - with: - client-id: ${{ inputs.client-id }} - tenant-id: ${{ inputs.tenant-id }} - allow-no-subscriptions: true - - - name: Install Azure Artifacts credential provider - shell: pwsh - run: | - dotnet tool install --global Microsoft.Artifacts.CredentialProvider.NuGet.Tool - - echo "$HOME\.dotnet\tools" >> $env:GITHUB_PATH - - - name: Install BCal package - shell: pwsh - env: - BCAL_PACKAGE_ID: ${{ inputs.package-id }} - BCAL_FEED: ${{ inputs.feed }} - BCAL_OFFICIAL_FEED_URL: ${{ inputs.official-feed-url }} - BCAL_EXPERIMENT_FEED_URL: ${{ inputs.experiment-feed-url }} - BCAL_REQUESTED_VERSION: ${{ inputs.version }} - run: | - $PSNativeCommandUseErrorActionPreference = $false - - $feedUrl = switch ($env:BCAL_FEED) { - "official" { $env:BCAL_OFFICIAL_FEED_URL } - "experiment" { $env:BCAL_EXPERIMENT_FEED_URL } - default { throw "Unknown BCal feed '$env:BCAL_FEED'; expected official or experiment." } - } - if (-not $feedUrl) { throw "No feed URL configured for BCal feed '$env:BCAL_FEED'." } - - $adoToken = az account get-access-token --resource 499b84ac-1321-427f-aa17-267ca6975798 --query accessToken -o tsv - Write-Output "::add-mask::$adoToken" - - $endpoints = @{ - endpointCredentials = @( - @{ - endpoint = $feedUrl - username = "anything" - password = $adoToken - } - ) - } | ConvertTo-Json -Compress -Depth 5 - $env:VSS_NUGET_EXTERNAL_FEED_ENDPOINTS = $endpoints - - [string[]]$versionArgs = if ($env:BCAL_REQUESTED_VERSION) { @("--version", $env:BCAL_REQUESTED_VERSION) } else { @("--prerelease") } - - # The ADO Artifacts NuGet credential provider intermittently fails to load the service index; retry transient feed errors. - for ($attempt = 1; $attempt -le 3; $attempt++) { - dotnet tool install --global $env:BCAL_PACKAGE_ID @versionArgs --source $feedUrl - if ($LASTEXITCODE -eq 0) { break } - if ($attempt -eq 3) { throw "bcal CLI install failed after 3 attempts (exit code $LASTEXITCODE)." } - Write-Output "::warning::bcal CLI install attempt $attempt failed (exit $LASTEXITCODE); retrying in 20s" - Start-Sleep -Seconds 20 - } diff --git a/.github/actions/setup-bc-container-repo/action.yml b/.github/actions/setup-bc-container-repo/action.yml deleted file mode 100644 index 98b360b73..000000000 --- a/.github/actions/setup-bc-container-repo/action.yml +++ /dev/null @@ -1,113 +0,0 @@ -name: Setup BC Container and Repository -description: Install BcContainerHelper and setup BC container along with repository - -inputs: - instance-id: - description: Instance ID for the dataset entry - required: true - category: - description: Category for the dataset entry - required: true - azure-client-id: - description: Azure AD application client ID for OIDC authentication - required: true - azure-tenant-id: - description: Azure AD tenant ID for OIDC authentication - required: true - github-token: - description: GitHub token for accessing public repositories - required: true - skip-container: - description: Skip BC container setup (only clone repository) - required: false - default: "false" - skip-repo: - description: Skip cloning the dataset repository (workspace is scaffolded by the pipeline) - required: false - default: "false" - bc-mcp: - description: Provision the BC MCP server in the container (publishes the MCP configuration app) - required: false - default: "false" - -outputs: - repo_path: - description: Path to the cloned repository - value: ${{ steps.setup.outputs.repo_path }} - al_tool_dotnet_version: - description: .NET version required by the AL tool for this entry - value: ${{ steps.bcversion.outputs.al_tool_dotnet_version }} - -runs: - using: composite - steps: - - name: Generate BC container name and credentials - if: inputs.skip-container != 'true' - run: | - # Generate a 32-character random password using Get-Random - # The password is short-lived and only used for the duration of the workflow - $password = -join ((48..57) + (65..90) + (97..122) | Get-Random -Count 32 | ForEach-Object { [char]$_ }) - - # Mask the password in GitHub Actions logs - Write-Output "::add-mask::$password" - - $containerName = "bcbench-$("${{ inputs.instance-id }}".Split('-')[1])" - "BC_CONTAINER_NAME=$containerName" | Out-File -FilePath $env:GITHUB_ENV -Append - - # Connection target + credentials consumed by altool - "BC_SERVER_URL=http://$containerName" | Out-File -FilePath $env:GITHUB_ENV -Append - "BC_SERVER_INSTANCE=BC" | Out-File -FilePath $env:GITHUB_ENV -Append - "BC_SERVER_USERNAME=admin" | Out-File -FilePath $env:GITHUB_ENV -Append - "BC_SERVER_PASSWORD=$password" | Out-File -FilePath $env:GITHUB_ENV -Append - shell: pwsh - - - name: Install BcContainerHelper module - if: inputs.skip-container != 'true' - run: | - Install-Module -Name BcContainerHelper -Force -AllowClobber -AllowPrerelease - shell: pwsh - - - name: Azure Login with OIDC for cloning internal repository - if: inputs.skip-repo != 'true' - uses: azure/login@a641126d1b8aa4d1fa005f4f92df94a3a4c4c906 # v3 - with: - client-id: ${{ inputs.azure-client-id }} - tenant-id: ${{ inputs.azure-tenant-id }} - allow-no-subscriptions: true - - - name: Resolve BC version, artifact, and AL tool framework - id: bcversion - if: inputs.skip-container != 'true' - shell: pwsh - run: | - Import-Module ./scripts/BenchmarkUtils.psm1 -Force -DisableNameChecking - $version = Get-BCBenchEntryVersion -InstanceId "${{ inputs.instance-id }}" -Category "${{ inputs.category }}" - $alToolDotNetVersion = if (([System.Version]$version).Major -lt 29) { "8.0" } else { "10.0" } - "al_tool_dotnet_version=$alToolDotNetVersion" | Out-File -FilePath $env:GITHUB_OUTPUT -Append - - $url = (Get-BCBenchArtifactConfig -Version $version -Category "${{ inputs.category }}").artifactUrl - $hash = [Convert]::ToHexString([Security.Cryptography.SHA256]::HashData([Text.Encoding]::UTF8.GetBytes($url))) - "cache_key=bcartifacts-$hash" | Out-File -FilePath $env:GITHUB_OUTPUT -Append - - - name: Cache BC sandbox artifacts - if: inputs.skip-container != 'true' - uses: actions/cache@caa296126883cff596d87d8935842f9db880ef25 # v5 - with: - path: C:\bcartifacts.cache - key: ${{ steps.bcversion.outputs.cache_key }} - - - name: Setup BC container and repository for ${{ inputs.instance-id }} - id: setup - env: - GITHUB_TOKEN: ${{ inputs.github-token }} - run: | - Write-Output "::add-mask::$env:GITHUB_TOKEN" - - # Get Azure DevOps access token via OIDC - if ('${{ inputs.skip-repo }}' -ne 'true') { - $env:ADO_TOKEN = az account get-access-token --resource "499b84ac-1321-427f-aa17-267ca6975798" --query accessToken -o tsv - Write-Output "::add-mask::$env:ADO_TOKEN" - } - - .\scripts\Setup-ContainerAndRepository.ps1 -InstanceId "${{ inputs.instance-id }}" -Category "${{ inputs.category }}" ${{ inputs.skip-container == 'true' && '-SkipContainer' || '' }} ${{ inputs.skip-repo == 'true' && '-SkipRepo' || '' }} ${{ inputs.bc-mcp == 'true' && '-BcMcp' || '' }} - shell: pwsh diff --git a/.github/skills/update-agent-harness/SKILL.md b/.github/skills/update-agent-harness/SKILL.md index a8d51294d..42bf2661c 100644 --- a/.github/skills/update-agent-harness/SKILL.md +++ b/.github/skills/update-agent-harness/SKILL.md @@ -31,7 +31,7 @@ Use this table when the model set changes: - `.github/actions/install-agent-harnesses/action.yml` - `src/bcbench/agent/copilot/agent.py` and `src/bcbench/cli_options.py` - `packages/bcbench-core/src/bcbench_core/agent/copilot/` (CLI invocation and metrics parsing) -- `.github/workflows/copilot-evaluation.yml` +- `.azuredevops/copilot-evaluation.yml` (`copilot_version` and model choices) - `.github/workflows/contamination.yml` - Defaults under `src/bcbench/commands/` and `src/bcbench/config.py` - Copilot-focused tests under `tests/` diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 249a2dcb2..24319edf2 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -150,15 +150,20 @@ jobs: retention-days: 1 summarize-results: + runs-on: ubuntu-latest needs: [mock-evaluation, select-category] - uses: $/.github/workflows/summarize-results.yml - permissions: - contents: write - id-token: write - with: - results-dir: ${{ needs.mock-evaluation.outputs.results-dir }} - model: ${{ github.run_id }} - agent: "mock-agent" - mock: true - category: ${{ needs.select-category.outputs.category }} - secrets: inherit + steps: + - name: Checkout repository + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + + - name: Setup Python with UV + uses: $/.github/actions/setup-python-uv + + - name: Download mock evaluation results + uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 + with: + path: ${{ env.EVALUATION_RESULTS_DIR }}/ + merge-multiple: true + + - name: Summarize mock evaluation results + run: uv run bcbench result summarize --category "${{ needs.select-category.outputs.category }}" --result-dir "${{ env.EVALUATION_RESULTS_DIR }}" diff --git a/.github/workflows/bcal-evaluation.yml b/.github/workflows/bcal-evaluation.yml deleted file mode 100644 index 8ce4f4971..000000000 --- a/.github/workflows/bcal-evaluation.yml +++ /dev/null @@ -1,216 +0,0 @@ -name: Evaluation with bcal -run-name: BCal ${{ inputs.tier || 'gold' }} ${{ inputs.bcal-feed || 'official' }}@${{ inputs.bcal-version || 'latest' }} (${{ inputs.external-model || 'gpt-55-chat' }}${{ inputs.completion-review-model && inputs.completion-review-model != 'none' && format('/review:{0}', inputs.completion-review-model) || '' }}) - ${{ inputs.test-run && 'test' || 'full' }} -permissions: - contents: read - actions: write - -on: - workflow_dispatch: - inputs: - tier: - description: "NL2AL dataset tier to evaluate" - required: false - default: gold - type: choice - options: - - gold - - challenge - bcal-feed: - description: "BCal package feed: official, or the internal test feed for experimental builds" - required: false - default: official - type: choice - options: - - official - - experiment - bcal-version: - description: "Exact BCal NuGet version; leave empty for the latest prerelease" - required: false - default: "" - type: string - external-model: - description: "Model alias to use through the bc-eval M365 LLM API client" - required: false - default: "gpt-55-chat" - type: choice - options: - - "gpt-6-luna" - - "gpt-56-reasoning-nano-luna" - - "gpt-56-reasoning-sol" - - "gpt-55-chat" - completion-review-model: - description: "Separate model for BCal's completion review; none uses external-model" - required: false - default: "none" - type: choice - options: - - "none" - - "gpt-6-luna" - - "gpt-56-reasoning-nano-luna" - - "gpt-56-reasoning-sol" - - "gpt-55-chat" - test-run: - description: "Indicate this is a test run (with few entries)" - required: false - default: true - type: boolean - schedule: - - cron: "0 3 * * 0" - - -concurrency: - group: bcal-evaluation-${{ inputs.test-run && 'test' || 'full' }} - cancel-in-progress: false - -env: - EVALUATION_RESULTS_DIR: evaluation_results - TIER: ${{ inputs.tier || 'gold' }} - BCAL_REQUESTED_VERSION: ${{ inputs.bcal-version }} - -jobs: - get-entries: - uses: $/.github/workflows/get-entries.yml - with: - test-run: ${{ inputs.test-run || false }} - category: nl2al - tier: ${{ inputs.tier || 'gold' }} - - evaluate-with-bcal: - runs-on: windows-latest - needs: get-entries - outputs: - results-dir: ${{ env.EVALUATION_RESULTS_DIR }} - if: needs.get-entries.outputs.entries != '[]' - environment: - name: ado-read - deployment: false - permissions: - contents: read - id-token: write - name: ${{ matrix.entry }} - strategy: - fail-fast: false - max-parallel: 32 - matrix: - entry: ${{ fromJson(needs.get-entries.outputs.entries) }} - steps: - - name: Checkout repository - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - - - name: Setup Python with UV - uses: $/.github/actions/setup-python-uv - - - name: Install bcal CLI from internal feed - uses: $/.github/actions/install-bcal - with: - client-id: ${{ secrets.AZURE_CLIENT_ID }} - tenant-id: ${{ secrets.AZURE_TENANT_ID }} - package-id: ${{ secrets.BCAL_PACKAGE_ID }} - feed: ${{ inputs.bcal-feed || 'official' }} - official-feed-url: ${{ secrets.BCAL_FEED_URL }} - experiment-feed-url: ${{ secrets.BCAL_TEST_FEED_URL }} - version: ${{ env.BCAL_REQUESTED_VERSION }} - - - name: Build bc-eval LLM API bridge venv - shell: pwsh - run: | - $PSNativeCommandUseErrorActionPreference = $false - - $adoToken = az account get-access-token --resource 499b84ac-1321-427f-aa17-267ca6975798 --query accessToken -o tsv - Write-Output "::add-mask::$adoToken" - - # Match the bridge runtime to BC-Bench so BCal can safely inherit its Python environment. - uv venv .bcal-llm-api-venv --python .\.venv\Scripts\python.exe - - # Same transient ADO feed flakiness as the bcal install above; retry the package pull. - for ($attempt = 1; $attempt -le 3; $attempt++) { - uv pip install --python .\.bcal-llm-api-venv\Scripts\python.exe "bc-eval==0.11.0" --index "https://anything:$($adoToken)@dynamicssmb2.pkgs.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_packaging/BC_PythonFeed/pypi/simple/" - if ($LASTEXITCODE -eq 0) { break } - if ($attempt -eq 3) { throw "bc-eval install failed after 3 attempts (exit code $LASTEXITCODE)." } - Write-Output "::warning::bc-eval install attempt $attempt failed (exit $LASTEXITCODE); retrying in 20s" - Start-Sleep -Seconds 20 - } - - - name: Resolve BC version for cache key - id: bcversion - shell: pwsh - run: uv run bcbench dataset version "${{ matrix.entry }}" --category nl2al --tier "$env:TIER" --github-output version - - # Cache BcContainerHelper's artifact folder (its hardcoded default path) keyed by this entry's BC version - - name: Cache BC sandbox artifacts - id: bccache - uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 - with: - path: C:\bcartifacts.cache - key: bcartifacts-${{ steps.bcversion.outputs.version }} - - - name: Download BC Application symbols - if: steps.bccache.outputs.cache-hit != 'true' - shell: pwsh - run: | - Install-Module -Name BcContainerHelper -Force -AllowClobber -AllowPrerelease - .\scripts\Download-BCSymbols.ps1 -Category nl2al -Tier "$env:TIER" -InstanceId "${{ matrix.entry }}" - - - name: Azure Login (OIDC) for LLM API certificate Key Vault - uses: azure/login@a641126d1b8aa4d1fa005f4f92df94a3a4c4c906 # v3 - with: - client-id: ${{ secrets.AZURE_CLIENT_ID }} - tenant-id: ${{ secrets.AZURE_TENANT_ID }} - allow-no-subscriptions: true - - - name: Fetch LLM API client certificate from Key Vault - shell: pwsh - env: - CERTIFICATE_KEY_VAULT_NAME: ${{ secrets.CAPI_CERTIFICATE_KEY_VAULT_NAME }} - CERTIFICATE_NAME: ${{ secrets.CAPI_CERTIFICATE_NAME }} - run: | - if (-not $env:CERTIFICATE_KEY_VAULT_NAME -or -not $env:CERTIFICATE_NAME) { - throw "CAPI_CERTIFICATE_KEY_VAULT_NAME / CAPI_CERTIFICATE_NAME secrets must be set." - } - $b64 = az keyvault secret show --vault-name $env:CERTIFICATE_KEY_VAULT_NAME --name $env:CERTIFICATE_NAME --query value -o tsv - if (-not $b64) { - throw "Failed to fetch LLM API client certificate from Key Vault." - } - [IO.File]::WriteAllBytes("$env:RUNNER_TEMP\llm-api-cert.pfx", [Convert]::FromBase64String($b64)) - - - name: Run BCal for entry ${{ matrix.entry }} - timeout-minutes: 28 - env: - BCAL_LLM_MODEL: ${{ inputs.external-model || 'gpt-55-chat' }} - BCAL_COMPLETION_REVIEW_MODEL: ${{ inputs.completion-review-model != 'none' && inputs.completion-review-model || '' }} - LLM_API_TENANT_ID: ${{ secrets.CAPI_TENANT_ID }} - LLM_API_CLIENT_ID: ${{ secrets.CAPI_CLIENT_ID }} - shell: pwsh - run: | - $env:LLM_API_CERTIFICATE_FILE = "$env:RUNNER_TEMP\llm-api-cert.pfx" - if (-not (Test-Path $env:LLM_API_CERTIFICATE_FILE)) { - throw "Expected LLM API client cert at $env:LLM_API_CERTIFICATE_FILE but it was not fetched from Key Vault." - } - $env:BCAL_LLM_COMMAND = "$env:GITHUB_WORKSPACE\.bcal-llm-api-venv\Scripts\python.exe $env:GITHUB_WORKSPACE\src\bcbench\agent\bcal\bc_eval_llm_api_bridge.py" - - uv run bcbench evaluate bcal "${{ matrix.entry }}" --tier "$env:TIER" --output-dir "${{ env.EVALUATION_RESULTS_DIR }}" - - - name: Upload evaluation results - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 - if: always() - with: - name: evaluation-results-${{ github.run_id }}-${{ matrix.entry }} - path: ${{ env.EVALUATION_RESULTS_DIR }}/**/*.jsonl - retention-days: ${{ inputs.test-run && 1 || 30 }} - - summarize-results: - needs: evaluate-with-bcal - uses: $/.github/workflows/summarize-results.yml - permissions: - contents: write - id-token: write - with: - results-dir: ${{ needs.evaluate-with-bcal.outputs.results-dir }} - model: ${{ inputs.external-model || 'gpt-55-chat' }} - agent: BCal-external-command - mock: ${{ inputs.test-run || false }} - category: nl2al - tier: ${{ inputs.tier || 'gold' }} - experiment: ${{ inputs.bcal-feed == 'experiment' }} - skip-leaderboard: true - secrets: inherit diff --git a/.github/workflows/claude-evaluation.yml b/.github/workflows/claude-evaluation.yml deleted file mode 100644 index 312bbb842..000000000 --- a/.github/workflows/claude-evaluation.yml +++ /dev/null @@ -1,196 +0,0 @@ -name: Evaluation with Claude Code -permissions: - contents: read - actions: write - -on: - workflow_dispatch: - inputs: - model: - description: "Claude Code model to use for evaluation" - required: false - default: "claude-haiku-4-5" - type: choice - options: - - "claude-sonnet-5" - - "claude-opus-5" - - "claude-haiku-4-5" - category: - description: "Evaluation category to run" - required: false - default: "bug-fix" - type: choice - options: - - "bug-fix" - - "test-generation" - - "code-review" - - "data-query" - - "extensibility-request-advisor" - - "extensibility-request-implement" - - "extensibility-request-triage" - test-run: - description: "Indicate this is a test run (with few entries)" - required: false - default: true - type: boolean - al-mcp: - description: "Enable AL MCP server" - required: false - default: false - type: boolean - al-lsp: - description: "Enable AL LSP server" - required: false - default: false - type: boolean - bc-mcp: - description: "Enable the Business Central MCP server" - required: false - default: false - type: boolean - repeat: - description: "Number of times to run sequentially (ignored for test runs)" - required: false - default: "1" - type: choice - options: - - "1" - - "2" - - "3" - - "4" - - "5" - git-ref: - description: "Branch to record for experiment tracking (auto-filled on requeue; leave blank for manual runs)" - required: false - default: "" - type: string - -concurrency: - group: claude-evaluation-${{ inputs.test-run && 'test' || 'full' }} - cancel-in-progress: false - -env: - EVALUATION_RESULTS_DIR: evaluation_results - -jobs: - pin-commit: - uses: $/.github/workflows/pin-evaluation-commit.yml - permissions: - contents: write - with: - agent: claude - test-run: ${{ inputs.test-run }} - repeat: ${{ inputs.repeat }} - - get-entries: - uses: $/.github/workflows/get-entries.yml - with: - test-run: ${{ inputs.test-run }} - category: ${{ inputs.category }} - - evaluate-with-claude-code: - runs-on: ${{ needs.get-entries.outputs.runner }} - needs: get-entries - outputs: - results-dir: ${{ env.EVALUATION_RESULTS_DIR }} - if: needs.get-entries.outputs.entries != '[]' - environment: - name: ado-read - deployment: false - permissions: - contents: read - id-token: write - copilot-requests: write # code-review semantic judge runs via Copilot CLI - name: ${{ matrix.entry }} - strategy: - fail-fast: false - max-parallel: 24 - matrix: - entry: ${{ fromJson(needs.get-entries.outputs.entries) }} - steps: - - name: Checkout repository - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - - - name: Setup BC Container and Repository - id: setup-env - timeout-minutes: 40 - uses: $/.github/actions/setup-bc-container-repo - with: - instance-id: ${{ matrix.entry }} - category: ${{ inputs.category }} - azure-client-id: ${{ secrets.AZURE_CLIENT_ID }} - azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }} - github-token: ${{ secrets.GITHUB_TOKEN }} - skip-container: ${{ needs.get-entries.outputs.requires-container != 'true' }} - skip-repo: ${{ needs.get-entries.outputs.requires-repo != 'true' }} - bc-mcp: ${{ inputs.bc-mcp }} - - - name: Setup Python with UV - uses: $/.github/actions/setup-python-uv - - - name: Install AL Tool - if: ${{ inputs.al-mcp || inputs.al-lsp }} - shell: pwsh - run: | - dotnet tool install -g Microsoft.Dynamics.BusinessCentral.Development.Tools --version 18.0.37.11445-beta --framework "net${{ steps.setup-env.outputs.al_tool_dotnet_version }}" - echo "$HOME\.dotnet\tools" >> $env:GITHUB_PATH - - - name: Install Agent Harnesses - uses: $/.github/actions/install-agent-harnesses - - - name: Run Claude Code for entry ${{ matrix.entry }} - timeout-minutes: 120 - shell: pwsh - env: - CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.ANTHROPIC_API_KEY }} - COPILOT_GITHUB_TOKEN: ${{ github.token }} # used by the code-review semantic judge - GH_TOKEN: ${{ github.token }} - run: | - Write-Output "::add-mask::$env:CLAUDE_CODE_OAUTH_TOKEN" - Write-Output "::add-mask::$env:COPILOT_GITHUB_TOKEN" - - uv run bcbench evaluate claude "${{ matrix.entry }}" ` - --model "${{ inputs.model }}" ` - --category "${{ inputs.category }}" ` - --repo-path "${{ steps.setup-env.outputs.repo_path }}" ` - --output-dir "${{ env.EVALUATION_RESULTS_DIR }}" ` - ${{ inputs.al-mcp && '--al-mcp' || '' }} ` - ${{ inputs.al-lsp && '--al-lsp' || '' }} ` - ${{ inputs.bc-mcp && '--bc-mcp' || '' }} - - - name: Upload evaluation results - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 - if: always() - with: - name: evaluation-results-${{ github.run_id }}-${{ matrix.entry }} - path: ${{ env.EVALUATION_RESULTS_DIR }}/**/*.jsonl - retention-days: ${{ inputs.test-run && 1 || 30 }} - - summarize-results: - needs: evaluate-with-claude-code - uses: $/.github/workflows/summarize-results.yml - permissions: - contents: write - id-token: write - with: - results-dir: ${{ needs.evaluate-with-claude-code.outputs.results-dir }} - model: ${{ inputs.model }} - agent: "Claude Code" - mock: ${{ inputs.test-run }} - category: ${{ inputs.category }} - git-ref: ${{ inputs.git-ref || github.ref_name }} - secrets: inherit - - requeue: - needs: [summarize-results, pin-commit] - if: ${{ !cancelled() && !failure() && !inputs.test-run }} - uses: $/.github/workflows/requeue-evaluation.yml - permissions: - contents: write - actions: write - with: - workflow-file: claude-evaluation.yml - repeat: ${{ inputs.repeat }} - existing-tag: ${{ needs.pin-commit.outputs.tag-name }} - workflow-inputs: | - {"model": "${{ inputs.model }}", "category": "${{ inputs.category }}", "test-run": "${{ inputs.test-run }}", "al-mcp": "${{ inputs.al-mcp }}", "al-lsp": "${{ inputs.al-lsp }}", "bc-mcp": "${{ inputs.bc-mcp }}", "git-ref": "${{ inputs.git-ref || github.ref_name }}"} diff --git a/.github/workflows/collect-and-screen.yml b/.github/workflows/collect-and-screen.yml deleted file mode 100644 index fb1e23937..000000000 --- a/.github/workflows/collect-and-screen.yml +++ /dev/null @@ -1,83 +0,0 @@ -name: Collect and Screen Dataset Candidates -permissions: - contents: write - actions: write - -on: - workflow_dispatch: - inputs: - since-days: - description: "Look at PRs merged within the last N days" - required: false - default: "7" - type: string - repo: - description: "Source GitHub repository (OWNER/REPO)" - required: false - default: "microsoft/BCApps" - type: string - limit: - description: "Maximum number of merged PRs to consider" - required: false - default: "50" - type: string - base-branch: - description: "Only consider PRs merged into this base branch" - required: false - default: "main" - type: string - schedule: - - cron: "0 4 * * 1" - -jobs: - collect-and-screen: - runs-on: ubuntu-latest - outputs: - branch: ${{ steps.run.outputs.branch }} - steps: - - name: Checkout repository - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - fetch-depth: 0 - - - name: Setup Python with UV - uses: $/.github/actions/setup-python-uv - - - name: Discover, screen, and collect passing PRs - id: run - shell: pwsh - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - $ErrorActionPreference = 'Stop' - - $week = [System.Globalization.ISOWeek]::GetWeekOfYear((Get-Date).ToUniversalTime()).ToString('00') - $branch = "dataset/week-$week" - - git config user.name 'github-actions[bot]' - git config user.email 'github-actions[bot]@users.noreply.github.com' - git checkout -B $branch - - .\scripts\Collect-And-Screen.ps1 ` - -Repo '${{ inputs.repo || 'microsoft/BCApps' }}' ` - -SinceDays ${{ inputs.since-days || '7' }} ` - -Limit ${{ inputs.limit || '50' }} ` - -BaseBranch '${{ inputs.base-branch || 'main' }}' ` - -SummaryFile $env:GITHUB_STEP_SUMMARY - - if (-not (git status --porcelain)) { - Write-Host 'No dataset changes; nothing to push.' - Add-Content -Path $env:GITHUB_OUTPUT -Value 'branch=' - return - } - - git add dataset/bcbench.jsonl dataset/problemstatement - git commit -m "auto: collect candidates from ${{ inputs.repo || 'microsoft/BCApps' }}" - git push --force origin $branch - Add-Content -Path $env:GITHUB_OUTPUT -Value "branch=$branch" - - - name: Trigger dataset validation on pushed branch - if: steps.run.outputs.branch != '' - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: gh workflow run dataset-validation.yml --ref "${{ steps.run.outputs.branch }}" -f modified-only=true -f test-run=false diff --git a/.github/workflows/contamination.yml b/.github/workflows/contamination.yml index f5ed54fb5..ab13bfc2a 100644 --- a/.github/workflows/contamination.yml +++ b/.github/workflows/contamination.yml @@ -57,7 +57,6 @@ jobs: if: needs.get-entries.outputs.entries != '[]' permissions: contents: read - id-token: write copilot-requests: write strategy: fail-fast: false diff --git a/.github/workflows/copilot-evaluation.yml b/.github/workflows/copilot-evaluation.yml deleted file mode 100644 index 170d29cc8..000000000 --- a/.github/workflows/copilot-evaluation.yml +++ /dev/null @@ -1,199 +0,0 @@ -name: Evaluation with GitHub Copilot -permissions: - contents: read - actions: write - -on: - workflow_dispatch: - inputs: - model: - description: "Copilot model to use for evaluation" - required: false - default: "gpt-5.6-luna" - type: choice - options: - - "claude-sonnet-5" - - "claude-opus-5" - - "gpt-5.6-sol" - - "gpt-5.6-terra" - - "gpt-5.6-luna" - - "gpt-5.3-codex" - - "mai-code-1.1-flash" - - "gemini-3.7-flash" - category: - description: "Evaluation category to run" - required: false - default: "bug-fix" - type: choice - options: - - "bug-fix" - - "test-generation" - - "code-review" - - "data-query" - - "extensibility-request-advisor" - - "extensibility-request-implement" - - "extensibility-request-triage" - test-run: - description: "Indicate this is a test run (with few entries)" - required: false - default: true - type: boolean - al-mcp: - description: "Enable AL MCP server" - required: false - default: false - type: boolean - al-lsp: - description: "Enable AL LSP server" - required: false - default: false - type: boolean - bc-mcp: - description: "Enable the Business Central MCP server" - required: false - default: false - type: boolean - repeat: - description: "Number of times to run sequentially (ignored for test runs)" - required: false - default: "1" - type: choice - options: - - "1" - - "2" - - "3" - - "4" - - "5" - git-ref: - description: "Branch to record for experiment tracking (auto-filled on requeue; leave blank for manual runs)" - required: false - default: "" - type: string - -concurrency: - group: copilot-evaluation-${{ inputs.test-run && 'test' || 'full' }}-${{ inputs.category }} - cancel-in-progress: false - -env: - EVALUATION_RESULTS_DIR: evaluation_results - -jobs: - pin-commit: - uses: $/.github/workflows/pin-evaluation-commit.yml - permissions: - contents: write - with: - agent: copilot - test-run: ${{ inputs.test-run }} - repeat: ${{ inputs.repeat }} - - get-entries: - uses: $/.github/workflows/get-entries.yml - with: - test-run: ${{ inputs.test-run }} - category: ${{ inputs.category }} - - evaluate-with-copilot-cli: - runs-on: ${{ needs.get-entries.outputs.runner }} - needs: get-entries - outputs: - results-dir: ${{ env.EVALUATION_RESULTS_DIR }} - if: needs.get-entries.outputs.entries != '[]' - environment: - name: ado-read - deployment: false - permissions: - contents: read - id-token: write - copilot-requests: write - name: ${{ matrix.entry }} - strategy: - fail-fast: false - max-parallel: 64 - matrix: - entry: ${{ fromJson(needs.get-entries.outputs.entries) }} - steps: - - name: Checkout repository - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - - - name: Setup BC Container and Repository - id: setup-env - timeout-minutes: 40 - uses: $/.github/actions/setup-bc-container-repo - with: - instance-id: ${{ matrix.entry }} - category: ${{ inputs.category }} - azure-client-id: ${{ secrets.AZURE_CLIENT_ID }} - azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }} - github-token: ${{ secrets.GITHUB_TOKEN }} - skip-container: ${{ needs.get-entries.outputs.requires-container != 'true' }} - skip-repo: ${{ needs.get-entries.outputs.requires-repo != 'true' }} - bc-mcp: ${{ inputs.bc-mcp }} - - - name: Setup Python with UV - uses: $/.github/actions/setup-python-uv - - - name: Install AL Tool - if: ${{ inputs.al-mcp || inputs.al-lsp }} - shell: pwsh - run: | - dotnet tool install -g Microsoft.Dynamics.BusinessCentral.Development.Tools --version 18.0.37.11445-beta --framework "net${{ steps.setup-env.outputs.al_tool_dotnet_version }}" - echo "$HOME\.dotnet\tools" >> $env:GITHUB_PATH - - - name: Install evaluation CLIs - uses: $/.github/actions/install-agent-harnesses - - - name: Run GitHub Copilot CLI for entry ${{ matrix.entry }} - timeout-minutes: 120 - shell: pwsh - env: - COPILOT_GITHUB_TOKEN: ${{ github.token }} - GH_TOKEN: ${{ github.token }} - run: | - Write-Output "::add-mask::$env:COPILOT_GITHUB_TOKEN" - - uv run bcbench evaluate copilot "${{ matrix.entry }}" ` - --model "${{ inputs.model }}" ` - --category "${{ inputs.category }}" ` - --repo-path "${{ steps.setup-env.outputs.repo_path }}" ` - --output-dir "${{ env.EVALUATION_RESULTS_DIR }}" ` - ${{ inputs.al-mcp && '--al-mcp' || '' }} ` - ${{ inputs.al-lsp && '--al-lsp' || '' }} ` - ${{ inputs.bc-mcp && '--bc-mcp' || '' }} - - - name: Upload evaluation results - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 - if: always() - with: - name: evaluation-results-${{ github.run_id }}-${{ matrix.entry }} - path: ${{ env.EVALUATION_RESULTS_DIR }}/**/*.jsonl - retention-days: ${{ inputs.test-run && 1 || 30 }} - - summarize-results: - needs: evaluate-with-copilot-cli - uses: $/.github/workflows/summarize-results.yml - permissions: - contents: write - id-token: write - with: - results-dir: ${{ needs.evaluate-with-copilot-cli.outputs.results-dir }} - model: ${{ inputs.model }} - agent: "GitHub Copilot CLI" - mock: ${{ inputs.test-run }} - category: ${{ inputs.category }} - git-ref: ${{ inputs.git-ref || github.ref_name }} - secrets: inherit - - requeue: - needs: [summarize-results, pin-commit] - if: ${{ !cancelled() && !failure() && !inputs.test-run }} - uses: $/.github/workflows/requeue-evaluation.yml - permissions: - contents: write - actions: write - with: - workflow-file: copilot-evaluation.yml - repeat: ${{ inputs.repeat }} - existing-tag: ${{ needs.pin-commit.outputs.tag-name }} - workflow-inputs: | - {"model": "${{ inputs.model }}", "category": "${{ inputs.category }}", "test-run": "${{ inputs.test-run }}", "al-mcp": "${{ inputs.al-mcp }}", "al-lsp": "${{ inputs.al-lsp }}", "bc-mcp": "${{ inputs.bc-mcp }}", "git-ref": "${{ inputs.git-ref || github.ref_name }}"} diff --git a/.github/workflows/dataset-validation.yml b/.github/workflows/dataset-validation.yml deleted file mode 100644 index a9fabe5e7..000000000 --- a/.github/workflows/dataset-validation.yml +++ /dev/null @@ -1,130 +0,0 @@ -# Designed for bug-fix and test-generation dataset, verifies the flow of building and -# testing still works as expected, avoiding regressions caused by underlying -# infrastructure changes. -name: Dataset Validation and Verification -permissions: - contents: read - -on: - workflow_dispatch: - inputs: - test-run: - description: "Indicate this is a test run (with few entries)" - required: false - default: true - type: boolean - modified-only: - description: "Only verify modified entries" - required: false - default: false - type: boolean - schedule: - - cron: "0 0 * * 0" - -jobs: - get-entries: - uses: $/.github/workflows/get-entries.yml - with: - modified-only: ${{ inputs.modified-only || false }} - test-run: ${{ inputs.test-run || false }} - category: "bug-fix" - - prepare-artifacts: - runs-on: ubuntu-latest - needs: get-entries - if: github.event_name == 'schedule' && needs.get-entries.outputs.entries != '[]' - outputs: - pins: ${{ steps.refresh.outputs.pins }} - steps: - - name: Checkout repository - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - - - name: Refresh pinned artifact URLs - id: refresh - shell: pwsh - run: | - Install-Module -Name BcContainerHelper -Force -AllowClobber -AllowPrerelease - Import-Module BcContainerHelper -Force -DisableNameChecking - Import-Module ./scripts/BenchmarkUtils.psm1 -Force -DisableNameChecking - - $latestUrls = Get-BCBenchLatestArtifactUrls - $urlsJson = ($latestUrls | ConvertTo-Json -Depth 2) + "`n" - $pins = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($urlsJson)) - "pins=$pins" | Out-File -FilePath $env:GITHUB_OUTPUT -Append - - verify-build-and-tests: - runs-on: [GitHub-BCBench] - needs: [get-entries, prepare-artifacts] - if: always() && needs.get-entries.result == 'success' && needs.get-entries.outputs.entries != '[]' && (github.event_name != 'schedule' || needs.prepare-artifacts.result == 'success') - environment: - name: ado-read - deployment: false - permissions: - contents: read - id-token: write - name: ${{ matrix.entry }} - strategy: - fail-fast: false - matrix: - entry: ${{ fromJson(needs.get-entries.outputs.entries) }} - steps: - - name: Checkout repository - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - - - name: Use refreshed artifact URLs - if: github.event_name == 'schedule' - shell: pwsh - env: - PINS: ${{ needs.prepare-artifacts.outputs.pins }} - run: | - [IO.File]::WriteAllBytes((Join-Path 'scripts' 'BCBenchArtifactPins.json'), [Convert]::FromBase64String($env:PINS)) - - - name: Setup BC Container and Repository - id: setup-env - timeout-minutes: 40 - uses: $/.github/actions/setup-bc-container-repo - with: - instance-id: ${{ matrix.entry }} - category: "bug-fix" - azure-client-id: ${{ secrets.AZURE_CLIENT_ID }} - azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }} - github-token: ${{ secrets.GITHUB_TOKEN }} - - - name: Run build and test verification for ${{ matrix.entry }} - timeout-minutes: 60 - run: .\scripts\Verify-BuildAndTests.ps1 -InstanceId "${{ matrix.entry }}" -RepoPath "${{ steps.setup-env.outputs.repo_path }}" - shell: pwsh - - propose-artifacts: - runs-on: ubuntu-latest - needs: [prepare-artifacts, verify-build-and-tests] - if: github.event_name == 'schedule' && needs.verify-build-and-tests.result == 'success' - permissions: - contents: write - steps: - - name: Checkout repository - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - - - name: Apply verified artifact URLs - shell: pwsh - env: - PINS: ${{ needs.prepare-artifacts.outputs.pins }} - run: | - [IO.File]::WriteAllBytes((Join-Path 'scripts' 'BCBenchArtifactPins.json'), [Convert]::FromBase64String($env:PINS)) - - - name: Push verified artifact branch for manual PR - shell: pwsh - run: | - $path = Join-Path 'scripts' 'BCBenchArtifactPins.json' - git diff --quiet -- $path - if ($LASTEXITCODE -eq 0) { return } - if ($LASTEXITCODE -ne 1) { throw 'Could not compare artifact pins.' } - - $PSNativeCommandUseErrorActionPreference = $true - $branch = "artifacts/refresh-${{ github.run_id }}-${{ github.run_attempt }}" - git config user.name 'github-actions[bot]' - git config user.email 'github-actions[bot]@users.noreply.github.com' - git switch -c $branch - git add $path - git commit -m 'Refresh pinned BC artifact URLs' - git push origin $branch diff --git a/.github/workflows/pin-evaluation-commit.yml b/.github/workflows/pin-evaluation-commit.yml deleted file mode 100644 index 8d2685db3..000000000 --- a/.github/workflows/pin-evaluation-commit.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: Pin Evaluation Commit - -on: - workflow_call: - inputs: - agent: - description: Agent identifier used in the ephemeral tag name - required: true - type: string - test-run: - description: Whether this is a test run - required: true - type: boolean - repeat: - description: Current repeat count - required: true - type: string - outputs: - tag-name: - description: Ephemeral tag pinning the initial evaluation commit - value: ${{ jobs.pin-commit.outputs.tag-name }} - -permissions: - contents: write - -jobs: - pin-commit: - runs-on: ubuntu-latest - if: ${{ !inputs.test-run && inputs.repeat != '1' && !startsWith(github.ref, 'refs/tags/eval-run-') }} - outputs: - tag-name: ${{ steps.create-tag.outputs.tag-name }} - steps: - - name: Create ephemeral tag pinning this commit - id: create-tag - env: - GH_TOKEN: ${{ github.token }} - run: | - TAG_NAME="eval-run-${{ inputs.agent }}-${{ github.run_id }}" - gh api repos/${{ github.repository }}/git/refs \ - --method POST \ - -f ref="refs/tags/${TAG_NAME}" \ - -f sha="${{ github.sha }}" - echo "tag-name=${TAG_NAME}" >> "$GITHUB_OUTPUT" diff --git a/.github/workflows/pr-review-evaluation.yml b/.github/workflows/pr-review-evaluation.yml deleted file mode 100644 index 226a24424..000000000 --- a/.github/workflows/pr-review-evaluation.yml +++ /dev/null @@ -1,177 +0,0 @@ -name: Evaluation with BC PR Review -permissions: - contents: read - actions: write - -on: - workflow_dispatch: - inputs: - model: - description: "Copilot model used internally by BC PR Review" - required: false - default: "gpt-5.6-luna" - type: choice - options: - - "claude-sonnet-5" - - "claude-opus-5" - - "gpt-5.6-sol" - - "gpt-5.6-terra" - - "gpt-5.6-luna" - - "gpt-5.3-codex" - - "mai-code-1.1-flash" - - "gemini-3.7-flash" - engine-sha: - description: "Full BC-ALAgents commit SHA (blank uses the default pin)" - required: false - default: "" - type: string - test-run: - description: "Indicate this is a test run (with few entries)" - required: false - default: true - type: boolean - modified-only: - description: "Only evaluate added or modified entries (never publishes results)" - required: false - default: false - type: boolean - repeat: - description: "Number of times to run sequentially (ignored for test runs)" - required: false - default: "1" - type: choice - options: - - "1" - - "2" - - "3" - - "4" - - "5" - git-ref: - description: "Branch to record for experiment tracking (auto-filled on requeue; leave blank for manual runs)" - required: false - default: "" - type: string - -concurrency: - group: pr-review-evaluation-${{ inputs.modified-only && 'modified' || inputs.test-run && 'test' || 'full' }} - cancel-in-progress: false - -env: - EVALUATION_RESULTS_DIR: evaluation_results - -jobs: - pin-commit: - uses: $/.github/workflows/pin-evaluation-commit.yml - permissions: - contents: write - with: - agent: pr-review - # A modified-only run never requeues, so it must not leave an ephemeral tag behind. - test-run: ${{ inputs.test-run || inputs.modified-only }} - repeat: ${{ inputs.repeat }} - - get-entries: - uses: $/.github/workflows/get-entries.yml - with: - modified-only: ${{ inputs.modified-only }} - test-run: ${{ inputs.test-run }} - category: code-review - - evaluate-with-pr-review: - runs-on: ${{ needs.get-entries.outputs.runner }} - needs: get-entries - outputs: - results-dir: ${{ env.EVALUATION_RESULTS_DIR }} - if: needs.get-entries.outputs.entries != '[]' - environment: - name: ado-read - deployment: false - permissions: - contents: read - id-token: write - copilot-requests: write - name: ${{ matrix.entry }} - strategy: - fail-fast: false - max-parallel: 64 - matrix: - entry: ${{ fromJson(needs.get-entries.outputs.entries) }} - steps: - - name: Checkout repository - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - - - name: Setup Repository - id: setup-env - timeout-minutes: 40 - uses: $/.github/actions/setup-bc-container-repo - with: - instance-id: ${{ matrix.entry }} - category: code-review - azure-client-id: ${{ secrets.AZURE_CLIENT_ID }} - azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }} - github-token: ${{ secrets.GITHUB_TOKEN }} - skip-container: true - skip-repo: false - - - name: Setup Python with UV - uses: $/.github/actions/setup-python-uv - - - name: Install evaluation CLIs - id: install-harnesses - uses: $/.github/actions/install-agent-harnesses - with: - engine-sha: ${{ inputs.engine-sha }} - - - name: Run BC PR Review for entry ${{ matrix.entry }} - timeout-minutes: 120 - shell: pwsh - env: - COPILOT_GITHUB_TOKEN: ${{ github.token }} - GH_TOKEN: ${{ github.token }} - run: | - Write-Output "::add-mask::$env:COPILOT_GITHUB_TOKEN" - - uv run bcbench evaluate pr-review "${{ matrix.entry }}" ` - --model "${{ inputs.model }}" ` - --engine-path "${{ steps.install-harnesses.outputs.bc-alagents-path }}" ` - --repo-path "${{ steps.setup-env.outputs.repo_path }}" ` - --output-dir "${{ env.EVALUATION_RESULTS_DIR }}" - - - name: Upload evaluation results - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 - if: always() - with: - name: evaluation-results-${{ github.run_id }}-${{ matrix.entry }} - path: ${{ env.EVALUATION_RESULTS_DIR }}/**/*.jsonl - retention-days: ${{ (inputs.test-run || inputs.modified-only) && 1 || 30 }} - - summarize-results: - needs: evaluate-with-pr-review - uses: $/.github/workflows/summarize-results.yml - permissions: - contents: write - id-token: write - with: - results-dir: ${{ needs.evaluate-with-pr-review.outputs.results-dir }} - model: ${{ inputs.model }} - agent: "BC PR Review" - # Scores only the modified entries, so publishing it to Braintrust/Kusto or the - # leaderboard would record a partial corpus as a benchmark result. - mock: ${{ inputs.test-run || inputs.modified-only || inputs.engine-sha != '' }} - category: code-review - git-ref: ${{ inputs.git-ref || github.ref_name }} - secrets: inherit - - requeue: - needs: [summarize-results, pin-commit] - if: ${{ !cancelled() && !failure() && !inputs.test-run && !inputs.modified-only }} - uses: $/.github/workflows/requeue-evaluation.yml - permissions: - contents: write - actions: write - with: - workflow-file: pr-review-evaluation.yml - repeat: ${{ inputs.repeat }} - existing-tag: ${{ needs.pin-commit.outputs.tag-name }} - workflow-inputs: | - {"model": "${{ inputs.model }}", "engine-sha": ${{ toJSON(inputs.engine-sha) }}, "test-run": "${{ inputs.test-run }}", "git-ref": "${{ inputs.git-ref || github.ref_name }}"} diff --git a/.github/workflows/requeue-evaluation.yml b/.github/workflows/requeue-evaluation.yml deleted file mode 100644 index 2fa216e15..000000000 --- a/.github/workflows/requeue-evaluation.yml +++ /dev/null @@ -1,87 +0,0 @@ -name: Requeue Evaluation - -on: - workflow_call: - inputs: - workflow-file: - description: "The workflow file to requeue" - required: true - type: string - repeat: - description: "Current repeat count" - required: true - type: string - workflow-inputs: - description: "JSON string of workflow inputs to pass (excluding repeat)" - required: true - type: string - existing-tag: - description: "Ephemeral tag already created earlier in the run (avoids re-creating it at requeue time)" - required: false - default: "" - type: string - -permissions: - contents: write - actions: write - -jobs: - requeue-if-needed: - runs-on: ubuntu-latest - if: ${{ inputs.repeat != '1' }} - steps: - - name: Reuse tag for requeue - env: - GH_TOKEN: ${{ github.token }} - INPUTS_JSON: ${{ inputs.workflow-inputs }} - run: | - REF="${{ github.ref }}" - - if [[ "${REF}" == refs/tags/eval-run-* ]]; then - # Already running from an ephemeral tag: reuse it - TAG_NAME="${{ github.ref_name }}" - echo "Reusing existing ephemeral tag: ${TAG_NAME}" - elif [[ -n "${{ inputs.existing-tag }}" ]]; then - # A tag was already created earlier in this run (see the pin-commit job) - TAG_NAME="${{ inputs.existing-tag }}" - echo "Using previously created ephemeral tag: ${TAG_NAME}" - else - echo "No ephemeral tag is available for requeue." - exit 1 - fi - - # Build the workflow dispatch command with inputs from JSON - NEXT_REPEAT=$(( ${{ inputs.repeat }} - 1 )) - - # Build the arguments array safely (handles spaces and special chars) - ARGS=() - while IFS= read -r line; do - key="${line%%=*}" - value="${line#*=}" - ARGS+=("-f" "${key}=${value}") - done < <(printf '%s' "${INPUTS_JSON}" | jq -r 'to_entries[] | select(.value != null) | "\(.key)=\(.value)"') - - # Trigger the workflow using the tag as ref - gh workflow run ${{ inputs.workflow-file }} \ - --repo ${{ github.repository }} \ - --ref "${TAG_NAME}" \ - -f repeat="${NEXT_REPEAT}" \ - "${ARGS[@]}" - - cleanup-ephemeral-tag: - runs-on: ubuntu-latest - if: ${{ inputs.repeat == '1' }} - steps: - - name: Delete ephemeral tag if running from one - env: - GH_TOKEN: ${{ github.token }} - run: | - REF="${{ github.ref }}" - if [[ "${REF}" == refs/tags/eval-run-* ]]; then - TAG_NAME="${{ github.ref_name }}" - echo "Cleaning up ephemeral tag: ${TAG_NAME}" - gh api repos/${{ github.repository }}/git/refs/tags/${TAG_NAME} \ - --method DELETE || echo "Tag deletion failed or already deleted" - else - echo "Not running from an ephemeral tag (ref: ${REF}), skipping cleanup" - fi diff --git a/.github/workflows/summarize-results.yml b/.github/workflows/summarize-results.yml deleted file mode 100644 index d489808bb..000000000 --- a/.github/workflows/summarize-results.yml +++ /dev/null @@ -1,172 +0,0 @@ -name: Summarize Evaluation Results - -on: - workflow_call: - inputs: - results-dir: - description: Directory to download results to - required: true - type: string - model: - description: "model to use for evaluation" - required: true - type: string - agent: - description: "type of agent used for evaluation" - required: true - type: string - mock: - description: "whether a mock evaluation was used" - required: false - type: boolean - default: false - category: - description: "Evaluation category" - required: true - type: string - tier: - description: "Dataset tier the run was evaluated on" - required: false - type: string - default: "gold" - experiment: - description: "Mark the run as an experiment rather than a baseline" - required: false - type: boolean - default: false - skip-leaderboard: - description: "Whether to skip updating the leaderboard" - required: false - type: boolean - default: false - git-ref: - description: "Git ref (branch) the evaluation was dispatched from; preserved across requeue for experiment tracking" - required: false - type: string - default: "" - -env: - BCEVAL_RESULT_FILE: bceval_results.jsonl - SUMMARY_OUTPUT_FILE: evaluation_summary.json - -jobs: - summarize-results: - name: Results - environment: - name: ado-read - deployment: false - permissions: - contents: write - id-token: write - runs-on: ubuntu-latest - env: - EVALUATION_TIER: ${{ inputs.tier }} - EVALUATION_AGENT: ${{ inputs.agent }} - EVALUATION_MODEL: ${{ inputs.model }} - EVALUATION_GIT_REF: ${{ inputs.git-ref || github.ref_name }} - steps: - - name: Checkout repository - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - - - name: Setup Python with UV - uses: $/.github/actions/setup-python-uv - - - name: Download all evaluation results - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 - with: - path: ${{ inputs.results-dir }}/ - merge-multiple: true - - - name: Summarize evaluation results - run: uv run bcbench result summarize --category "${{ inputs.category }}" --result-dir "${{ inputs.results-dir }}" --bceval-output "${{ env.BCEVAL_RESULT_FILE }}" --summary-output "${{ env.SUMMARY_OUTPUT_FILE }}" --git-ref "$EVALUATION_GIT_REF" - - - name: Upload evaluation summary to artifacts - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 - with: - name: evaluation-summary - path: ${{ inputs.results-dir }}/${{ github.run_id }}/${{ env.SUMMARY_OUTPUT_FILE }} - if-no-files-found: error - retention-days: ${{ inputs.mock && 1 || 30 }} - - - name: Azure Login with OIDC for bceval package - uses: azure/login@a641126d1b8aa4d1fa005f4f92df94a3a4c4c906 # v3 - with: - client-id: ${{ secrets.AZURE_CLIENT_ID }} - tenant-id: ${{ secrets.AZURE_TENANT_ID }} - allow-no-subscriptions: true - - - name: Resolve bceval evaluator config for category - id: bceval - run: uv run bcbench category bceval-config --category "${{ inputs.category }}" - - - name: Upload result using bceval - env: - JUDGE_MODEL: ${{ steps.bceval.outputs.judge_model }} - run: | - # Get Azure DevOps access token from Azure CLI (uses the OIDC token from azure/login) - ADO_TOKEN=$(az account get-access-token --resource 499b84ac-1321-427f-aa17-267ca6975798 --query accessToken -o tsv) - echo "::add-mask::$ADO_TOKEN" - - uv tool install bc-eval==0.11.0 --python 3.13 --index "https://anything:${ADO_TOKEN}@dynamicssmb2.pkgs.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_packaging/BC_PythonFeed/pypi/simple/" - - # Upload summary using bc-eval - MODEL_TAG="$EVALUATION_MODEL" - MODEL_TAG="${MODEL_TAG//./-}" - BRANCH_TAG="$EVALUATION_GIT_REF" - BRANCH_TAG="${BRANCH_TAG//./-}" - RUN_NAME="${EVALUATION_AGENT} (${EVALUATION_MODEL}) - #${GITHUB_RUN_ID}" - RUN_TAGS="${EVALUATION_AGENT},${MODEL_TAG},${BRANCH_TAG},tier-${EVALUATION_TIER}" - if [[ "$EVALUATION_TIER" != "gold" ]]; then - RUN_NAME="${RUN_NAME} [${EVALUATION_TIER}]" - fi - - bceval metrics calculate \ - --feature-name "BC-Bench" \ - --eval-suite-name "${{ inputs.category }}" \ - --eval-run-name "$RUN_NAME" \ - --tags "$RUN_TAGS" \ - --source "${{ github.sha }}" \ - --input-file "${{ inputs.results-dir }}/${{ github.run_id }}/${{ env.BCEVAL_RESULT_FILE }}" \ - --evaluator-definitions "${{ github.workspace }}/evaluator/scores.py" \ - --evaluators "${{ steps.bceval.outputs.evaluators }}" \ - --core-score "${{ steps.bceval.outputs.core_score }}" \ - --metric-definitions "${{ github.workspace }}/evaluator/metrics.py" \ - --metrics "bc_bench_metrics" \ - ${{ inputs.experiment && '--eval-run-type experiment' || '' }} \ - ${{ !inputs.mock && '--storage kusto' || '' }} - - - name: Update leaderboard in a new branch - if: ${{ !inputs.mock && !inputs.skip-leaderboard }} - run: | - git fetch origin main - - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" - - # Derive a stable branch name for the entire multi-run chain. - # When running from a requeue tag (eval-run--), - # extract the original run_id so all runs in the chain share one branch. - REF="${{ github.ref }}" - if [[ "${REF}" == refs/tags/eval-run-* ]]; then - TAG_NAME="${{ github.ref_name }}" - STABLE_ID="${TAG_NAME##*-}" - else - STABLE_ID="${{ github.run_id }}" - fi - - branchName="leaderboard/${{ inputs.category }}/${STABLE_ID}" - - # Reuse existing branch from a prior run in this chain, or create new from main - if git ls-remote --exit-code --heads origin "$branchName" >/dev/null 2>&1; then - git fetch origin "$branchName" - git checkout -b "$branchName" "origin/$branchName" - else - git checkout -b "$branchName" origin/main - fi - - uv run bcbench result update "${{ inputs.results-dir }}/${{ github.run_id }}/${{ env.SUMMARY_OUTPUT_FILE }}" - - git add docs/_data/${{ inputs.category }}.json - git commit -m "Update leaderboard: ${{ inputs.agent }} (${{ inputs.model }}) - Run ${{ github.run_id }}" - - git push --set-upstream origin $branchName diff --git a/CATEGORIES.md b/CATEGORIES.md index ba75cfbe1..7f5ba2887 100644 --- a/CATEGORIES.md +++ b/CATEGORIES.md @@ -32,7 +32,7 @@ Use the existing implementations as examples: `bug-fix` and `test-generation` fo 3. Add a result class under [src/bcbench/results/](src/bcbench/results/) and map it from `EvaluationCategory.result_class`. 4. Add a pipeline under [src/bcbench/evaluate/](src/bcbench/evaluate/), or, for a category in [src/bcbench/categories/](src/bcbench/categories/), one module holding its entry, `bcbench_core.evaluation.Category` and definition. 5. Add the prompt template to [src/bcbench/agent/shared/config.yaml](src/bcbench/agent/shared/config.yaml). -6. Add the category to workflow choice lists in [.github/workflows/](.github/workflows/), especially evaluation workflows and CI category selection. +6. Add the category to the `category` values in [.azuredevops/copilot-evaluation.yml](.azuredevops/copilot-evaluation.yml) (and its container/repository routing there). 7. Add docs, leaderboard data, notebooks, and tests for the category where relevant. ## Validation diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 673c63d73..25c100631 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -76,22 +76,15 @@ uv run pre-commit run --all-files Replace the dataset tasks with your own, you can keep the ones from `BCApps` as the repository is public. The tasks follow `__-`, the `/` by default points to GitHub repositories. If your tasks come from Azure DevOps, update the ADO branch in `scripts/BCBenchUtils.psm1` (currently hardcoded to `microsoftinternal`). -### GitHub Actions +### Pipelines -The upstream workflows are wired for Microsoft's internal environment. To run them on your fork: - -- Replace self-hosted runner label `GitHub-BCBench` with the standard GitHub Action runners. -- Remove or update GitHub environment `ado-read`, it is used to clone from Azure DevOps. -- Set repository secrets: - - `COPILOT_PAT` — GitHub Copilot CLI tokens - - `ANTHROPIC_API_KEY` — Claude Code API Key -- Remove the Braintrust / bc-eval upload in `.github/workflows/summarize-results.yml`. +CI and the contamination probe are GitHub Actions workflows. Copilot evaluation and dataset validation are Azure DevOps pipelines in [`.azuredevops/`](.azuredevops/), wired for Microsoft's internal pools, Key Vault, and Kusto. On a fork, run evaluations locally with `bcbench evaluate`, or adapt those pipelines to your own agents and credentials. ## Versioning Policy BC-Bench uses [semantic versioning](https://semver.org/) to track changes that may affect evaluation results. The version is stored in `pyproject.toml` and automatically embedded in all evaluation results. -`benchmark_version` identifies the release and its default harness pins. Results separately record the actual harness as `agent_version` (Copilot/Claude CLI version or BC-ALAgents SHA), without changing `ExperimentConfiguration`. A one-off `engine-sha` override does not require a benchmark version bump because its results are never published; changing a released default pin still follows the policy below and belongs on a branch with an [experiment PR](EXPERIMENT.md#experiment-pr-template). +`benchmark_version` identifies the release and its default harness pins. Results separately record the actual harness as `agent_version` (Copilot/Claude CLI version or BC-ALAgents SHA), without changing `ExperimentConfiguration`. Changing a released default pin still follows the policy below and belongs on a branch with an [experiment PR](EXPERIMENT.md#experiment-pr-template). ### When to Bump Versions @@ -123,7 +116,7 @@ Use the repository's [`update-agent-harness` skill](.github/skills/update-agent- The short maintainer checklist is: -1. Find the current hardcoded CLI pin in [`.github/actions/install-agent-harnesses/action.yml`](.github/actions/install-agent-harnesses/action.yml). +1. Find the current hardcoded CLI pin in [`.github/actions/install-agent-harnesses/action.yml`](.github/actions/install-agent-harnesses/action.yml); the Copilot CLI pin is repeated as `copilot_version` in [`.azuredevops/copilot-evaluation.yml`](.azuredevops/copilot-evaluation.yml). 2. Review first-party release notes for every version between the current and target pins. Check BC-Bench's flags, authentication, non-interactive behavior, logs, and metrics parsing for breaking changes. 3. Curate models for benchmark value. Do not add every available model: prefer models that represent a new frontier, provider, capability, or cost tier, and skip older or redundant models that add little comparative value. 4. Keep model choices and defaults synchronized across `src/bcbench/cli_options.py`, evaluation workflows, command defaults, and judge configuration. @@ -142,12 +135,12 @@ Keep evaluation tools pinned so benchmark runs remain reproducible. For example, ### Refresh BC sandbox artifacts -Public `w1` sandbox URLs are pinned by version in [`scripts/BCBenchArtifactPins.json`](scripts/BCBenchArtifactPins.json), so we are more resilient to upstream changes. Manual dataset-validation runs use the saved pins. The scheduled run resolves the latest URLs, verifies them across the full bug-fix dataset, and pushes a pins-only branch for a manual PR only if every job succeeds. BC Insider artifacts remain dynamically resolved. +Public `w1` sandbox URLs are pinned by version in [`scripts/BCBenchArtifactPins.json`](scripts/BCBenchArtifactPins.json), so we are more resilient to upstream changes. Manual runs of the [dataset validation pipeline](.azuredevops/dataset-validation.yml) use the saved pins. The scheduled run resolves the latest URLs, verifies them across the full bug-fix dataset, and pushes a pins-only branch for a manual PR only if every job succeeds. BC Insider artifacts remain dynamically resolved. ### Bump the BC PR Review engine 1. Update the pinned `microsoft/BC-ALAgents` commit in `.github/actions/install-agent-harnesses/action.yml` -2. Run a test evaluation through the `pr-review` workflow +2. Run a test evaluation with `bcbench evaluate pr-review` 3. Bump the BC-Bench version following the Versioning Policy 4. Include the exact BC-ALAgents commit SHA in the BC-Bench release notes diff --git a/EXPERIMENT.md b/EXPERIMENT.md index a68c355f5..bc3fe0777 100644 --- a/EXPERIMENT.md +++ b/EXPERIMENT.md @@ -74,9 +74,9 @@ Results record `ExperimentConfiguration.plugins` as `"@"` / `"/` branch. Merge that branch to publish to the leaderboard. +Each run publishes artifacts and pushes a `leaderboard//` branch. Merge the branches to publish to the leaderboard. ### 6. Reviewing results -- The `summarize-results` job prints per-run scores in the Actions log. +- The summarize job prints per-run scores in the pipeline log. - Download artifacts locally. - For deeper analysis, see `notebooks/bug-fix/` and `notebooks/test-generation/`. diff --git a/README.md b/README.md index be8585a27..b74c68733 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # BC-Bench -[![Dataset Validation and Verification](https://github.com/microsoft/BC-Bench/actions/workflows/dataset-validation.yml/badge.svg?event=schedule)](https://github.com/microsoft/BC-Bench/actions/workflows/dataset-validation.yml) [![CI](https://github.com/microsoft/BC-Bench/actions/workflows/CI.yml/badge.svg)](https://github.com/microsoft/BC-Bench/actions/workflows/CI.yml) +[![CI](https://github.com/microsoft/BC-Bench/actions/workflows/CI.yml/badge.svg)](https://github.com/microsoft/BC-Bench/actions/workflows/CI.yml) A benchmark for evaluating coding agents on real-world Business Central (AL) development tasks, inspired by [SWE-Bench](https://github.com/swe-bench/SWE-bench). diff --git a/docs/code-review.md b/docs/code-review.md index 65e2c80f3..6b2f1f750 100644 --- a/docs/code-review.md +++ b/docs/code-review.md @@ -47,7 +47,7 @@ BC-ALAgents is the PR Review harness boundary. Its repo and default commit are p For a durable experiment, push the pipeline and/or BCQuality changes through a BC-ALAgents branch, update the action pin to that immutable commit, then run BC-Bench from a branch with a draft PR describing the experiment (see [EXPERIMENT.md](https://github.com/microsoft/BC-Bench/blob/main/EXPERIMENT.md)). This keeps the reproducible dependency chain BC-Bench -> BC-ALAgents -> BCQuality, and records why the revision was evaluated. -The `pr-review` workflow also accepts an `engine-sha` input — a full 40-character BC-ALAgents commit SHA — as a **convenience** for a quick look at a revision without branching or re-pinning. It does not replace the process above: nothing records the intent behind the run, so an override is scored but never published to Braintrust/Kusto or the leaderboard. Blank keeps the default pin, requeued repeats retain the override, and the SHA that ran is recorded as `agent_version` on every result — read it from the job summary and run artifacts. +For a quick look at a revision without branching or re-pinning, run `bcbench evaluate pr-review --engine-path ` locally. It does not replace the process above: nothing records the intent behind the run, so do not publish its results. Either way, hold everything else fixed: the benchmark version, the model, the Copilot CLI version the engine uses internally, and the configured minimum severity. Locally, `bcbench evaluate pr-review --engine-path ` requires a clean engine checkout and uses the configured severity; use `bcbench run pr-review` for dirty-checkout smoke tests or `--min-severity` overrides. diff --git a/pyproject.toml b/pyproject.toml index da51dabac..9a385beec 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -98,7 +98,7 @@ exclude = ["notebooks/"] all = "error" [tool.ty.analysis] -# bc-eval is internal and installed only into a separate venv by bcal-evaluation.yml +# bc-eval is internal and installed only by the evaluation pipeline (.azuredevops/) allowed-unresolved-imports = ["bc_eval.**"] [dependency-groups] diff --git a/scripts/Collect-And-Screen.ps1 b/scripts/Collect-And-Screen.ps1 deleted file mode 100644 index c2e246b38..000000000 --- a/scripts/Collect-And-Screen.ps1 +++ /dev/null @@ -1,105 +0,0 @@ -<# -.SYNOPSIS -Discover merged PRs in a GitHub repo, screen them with bcbench, and collect passing ones. - -.DESCRIPTION -For each merged PR within the lookback window, runs `bcbench collect screen` -and (if it passes) `bcbench collect gh`, writing new dataset entries into -the working tree. Committing/pushing is left to the caller (e.g. the -`collect-and-screen.yml` workflow). - -.PARAMETER Repo -Source GitHub repository (OWNER/REPO). Defaults to microsoft/BCApps. - -.PARAMETER SinceDays -Look at PRs merged within the last N days. - -.PARAMETER Limit -Maximum number of merged PRs to consider. - -.PARAMETER BaseBranch -Only consider PRs merged into this base branch. Defaults to main. - -.PARAMETER SummaryFile -Optional path to append a markdown summary to (e.g. $env:GITHUB_STEP_SUMMARY). - -.EXAMPLE -.\scripts\Collect-And-Screen.ps1 -SinceDays 2 -Limit 5 -#> - -[CmdletBinding()] -param( - [string]$Repo = 'microsoft/BCApps', - [int]$SinceDays = 7, - [int]$Limit = 200, - [string]$BaseBranch = 'main', - [string]$SummaryFile -) - -$ErrorActionPreference = 'Stop' - -Import-Module (Join-Path $PSScriptRoot '..\packages\bcbench-core\src\bcbench_core\powershell\BCBenchUtils.psm1') -Force -Import-Module (Join-Path $PSScriptRoot 'BenchmarkUtils.psm1') -Force - -$latestRelease = Get-LatestReleaseBranch -Repo $Repo -if (-not $latestRelease) { throw "No releases/* branch found in $Repo" } -$envVersion = $latestRelease -replace '^releases/', '' -Write-Log "Latest release branch in $Repo`: $latestRelease (environment_setup_version=$envVersion)" -Level Info - -$since = (Get-Date).ToUniversalTime().AddDays(-$SinceDays).ToString('yyyy-MM-dd') -Write-Log "Searching merged PRs in $Repo (base: $BaseBranch) since $since (limit $Limit)" -Level Info - -$requiredLabel = 'AL: Apps (W1)' -$jqFilter = "[.[] | select((.labels | length) == 1 and .labels[0].name == `"$requiredLabel`") | .number]" -$prsJson = & gh pr list --repo $Repo --state merged --base $BaseBranch --label $requiredLabel ` - --search "merged:>=$since" --limit $Limit --json 'number,labels' --jq $jqFilter -if ($LASTEXITCODE -ne 0) { throw "gh pr list failed" } - -[int[]]$prs = ($prsJson | ConvertFrom-Json) -Write-Log "Found $($prs.Count) merged PR(s) labeled exclusively '$requiredLabel'" -Level Info - -$passed = New-Object System.Collections.Generic.List[PSObject] -foreach ($pr in $prs) { - if ($env:CI -eq 'true') { Write-Host "::group::PR #$pr" } - Write-Log "Screening PR #$pr" -Level Info - - & uv run bcbench collect screen $pr --repo $Repo - $screenExit = $LASTEXITCODE - - if ($screenExit -eq 0) { - & uv run bcbench collect gh $pr --repo $Repo --environment-setup-version $envVersion - if ($LASTEXITCODE -eq 0) { - $instanceId = "$($Repo -replace '/', '__')-$pr" - $passed.Add([PSCustomObject]@{ Id = $instanceId; Url = "https://github.com/$Repo/pull/$pr" }) - Write-Log "Collected PR #$pr -> $instanceId" -Level Success - } - else { - Write-Log "PR #$pr passed screening but could not be collected" -Level Warning - } - } - else { - Write-Log "Skipped PR #$pr (did not pass screening)" -Level Info - } - - if ($env:CI -eq 'true') { Write-Host "::endgroup::" } -} - -if ($SummaryFile) { - $summary = @() - $summary += '## Screening summary' - $summary += '' - $summary += "Repo: ``$Repo``" - $summary += '' - $summary += "Base: ``$BaseBranch``" - $summary += '' - $summary += "Env: ``$envVersion``" - $summary += '' - $summary += "Window: last $SinceDays day(s) (since $since)" - $summary += '' - $summary += "Considered: $($prs.Count)" - $summary += '' - $summary += "Passed screening + collected: $($passed.Count)" - $summary += '' - foreach ($item in $passed) { $summary += "- [$($item.Id)]($($item.Url))" } - Add-Content -Path $SummaryFile -Value ($summary -join [Environment]::NewLine) -} diff --git a/src/bcbench/results/base.py b/src/bcbench/results/base.py index a4bbec242..96db01336 100644 --- a/src/bcbench/results/base.py +++ b/src/bcbench/results/base.py @@ -70,7 +70,7 @@ def save(self, output_dir: Path, result_file: str) -> None: output_dir.mkdir(parents=True, exist_ok=True) with output_file.open("a", encoding="utf-8") as f: result_dict = self.model_dump(mode="json") - # Per-instance JSONL result files are uploaded as workflow artifacts and are the only inputs required by the summarize-results workflow. + # Per-instance JSONL result files are uploaded as workflow artifacts and are the only inputs required by the evaluation pipeline's summarize job. f.write(json.dumps(result_dict) + "\n") logger.info(f"Saved evaluation result for {self.instance_id} to {output_file}") diff --git a/tests/test_agent_harness_action.py b/tests/test_agent_harness_action.py new file mode 100644 index 000000000..103e9d988 --- /dev/null +++ b/tests/test_agent_harness_action.py @@ -0,0 +1,80 @@ +import os +import shutil +import subprocess +from pathlib import Path + +import pytest +import yaml + +ACTIONS = Path(__file__).parents[1] / ".github" / "actions" +DEFAULT_ENGINE_SHA = "ecf8e31759d6ddd6d78e3a0b7836b40134368009" +PWSH = shutil.which("pwsh") + + +def test_agent_harness_action_pins_published_copilot_version() -> None: + action = (ACTIONS / "install-agent-harnesses" / "action.yml").read_text(encoding="utf-8") + + assert "@github/copilot@1.0.82" in action + + +def test_agent_harness_action_pins_and_exports_bc_alagents() -> None: + action = (ACTIONS / "install-agent-harnesses" / "action.yml").read_text(encoding="utf-8") + config = yaml.safe_load(action) + validation = next(step for step in config["runs"]["steps"] if step.get("id") == "engine-sha") + checkout = next(step for step in config["runs"]["steps"] if step.get("uses", "").startswith("actions/checkout@")) + + assert "repository: microsoft/BC-ALAgents" in action + assert "bc-alagents-path:" in action + assert config["inputs"]["engine-sha"]["required"] is False + assert config["inputs"]["engine-sha"]["default"] == "" + assert validation["env"]["ENGINE_SHA"] == "${{ inputs.engine-sha || '" + DEFAULT_ENGINE_SHA + "' }}" + assert "${{" not in validation["run"] + assert action.count(DEFAULT_ENGINE_SHA) == 1 + assert config["runs"]["steps"].index(validation) < config["runs"]["steps"].index(checkout) + assert checkout["with"]["ref"] == "${{ steps.engine-sha.outputs.sha }}" + assert checkout["with"]["persist-credentials"] is False + assert set(config["outputs"]) == {"bc-alagents-path"} + + +@pytest.mark.skipif(PWSH is None, reason="PowerShell is required to test the composite action script") +@pytest.mark.parametrize( + ("engine_sha", "valid"), + [ + ("", True), + ("a" * 40, True), + ("ABCDEF0123" * 4, True), + ("main", False), + ("v1.39.6", False), + ("ecf8e31", False), + ("a" * 39, False), + ("a" * 41, False), + ("g" * 40, False), + (" " * 40, False), + ("a" * 40 + "\n", False), + ("a" * 40 + "\r\n", False), + ("a" * 40 + "; Write-Output injected", False), + ("$(Write-Output injected)", False), + ], +) +def test_agent_harness_action_validates_engine_sha(engine_sha: str, valid: bool, tmp_path: Path) -> None: + assert PWSH is not None + action = yaml.safe_load((ACTIONS / "install-agent-harnesses" / "action.yml").read_text(encoding="utf-8")) + validation = next(step for step in action["runs"]["steps"] if step.get("id") == "engine-sha") + output = tmp_path / "github-output" + resolved_sha = engine_sha or DEFAULT_ENGINE_SHA + + result = subprocess.run( + [PWSH, "-NoProfile", "-NonInteractive", "-Command", validation["run"]], + env={**os.environ, "ENGINE_SHA": resolved_sha, "GITHUB_OUTPUT": str(output)}, + capture_output=True, + text=True, + check=False, + ) + + if valid: + assert result.returncode == 0, result.stderr + assert output.read_text(encoding="utf-8") == f"sha={resolved_sha}\n" + else: + assert result.returncode != 0 + assert "engine-sha must be a full 40-character hexadecimal commit SHA." in result.stderr + assert not output.exists() diff --git a/tests/test_azure_pipelines.py b/tests/test_azure_pipelines.py new file mode 100644 index 000000000..c049dc488 --- /dev/null +++ b/tests/test_azure_pipelines.py @@ -0,0 +1,50 @@ +import re +from pathlib import Path +from typing import Any + +import yaml + +from bcbench.types import EvaluationCategory + +ROOT = Path(__file__).parents[1] +COPILOT_EVALUATION = ROOT / ".azuredevops" / "copilot-evaluation.yml" + + +def _copilot_evaluation() -> dict[str, Any]: + pipeline = yaml.safe_load(COPILOT_EVALUATION.read_text(encoding="utf-8")) + assert isinstance(pipeline, dict) + return pipeline + + +def _jobs_template_parameters() -> dict[str, Any]: + parameters = _copilot_evaluation()["extends"]["parameters"]["stages"][0]["jobs"][0]["parameters"] + assert isinstance(parameters, dict) + return parameters + + +def _categories_in(expression: object) -> set[str]: + assert isinstance(expression, str) + match = re.fullmatch(r"\$\{\{ in\(parameters\.category, (.+)\) \}\}", expression) + assert match, expression + return set(re.findall(r"'([^']+)'", match.group(1))) + + +def test_copilot_evaluation_offers_every_copilot_category() -> None: + category = next(p for p in _copilot_evaluation()["parameters"] if p["name"] == "category") + + # NL2AL is evaluated with BCal in BC-Evals. + assert set(category["values"]) == {c.value for c in EvaluationCategory} - {EvaluationCategory.NL2AL.value} + + +def test_copilot_evaluation_routes_categories_by_their_environment() -> None: + parameters = _jobs_template_parameters() + copilot_categories = [c for c in EvaluationCategory if c is not EvaluationCategory.NL2AL] + + assert _categories_in(parameters["container"]) == {c.value for c in copilot_categories if c.requires_container} + assert _categories_in(parameters["skip_repo"]) == {c.value for c in copilot_categories if not c.requires_repo} + + +def test_copilot_evaluation_pins_the_same_copilot_cli_as_the_harness_action() -> None: + action = (ROOT / ".github" / "actions" / "install-agent-harnesses" / "action.yml").read_text(encoding="utf-8") + + assert f"@github/copilot@{_jobs_template_parameters()['copilot_version']}" in action diff --git a/tests/test_bcal_dataset_workflow.py b/tests/test_bcal_dataset_workflow.py deleted file mode 100644 index 16624a054..000000000 --- a/tests/test_bcal_dataset_workflow.py +++ /dev/null @@ -1,130 +0,0 @@ -from pathlib import Path -from typing import Any - -import yaml - -from bcbench.types import DatasetTier - -WORKFLOWS = Path(__file__).parents[1] / ".github" / "workflows" -SELECTED_TIER = "${{ inputs.tier || 'gold' }}" - - -def _workflow_text(name: str) -> str: - text = (WORKFLOWS / name).read_text(encoding="utf-8") - assert yaml.safe_load(text) - return text - - -def _workflow(name: str): - return yaml.safe_load(_workflow_text(name)) - - -def _step(workflow: dict[Any, Any], job: str, name: str) -> dict[str, Any]: - return _step_named(workflow["jobs"][job]["steps"], name) - - -def _step_named(steps: list[dict[str, Any]], name: str) -> dict[str, Any]: - return next(step for step in steps if step.get("name") == name) - - -def test_bcal_tier_choices_match_dataset_tiers(): - tier = _workflow("bcal-evaluation.yml")[True]["workflow_dispatch"]["inputs"]["tier"] - - assert tier["default"] == DatasetTier.GOLD - assert tier["options"] == list(DatasetTier) - - -def test_bcal_threads_selected_tier_through_every_job(): - workflow = _workflow("bcal-evaluation.yml") - text = _workflow_text("bcal-evaluation.yml") - - assert workflow["env"]["TIER"] == SELECTED_TIER - assert workflow["jobs"]["get-entries"]["with"]["tier"] == SELECTED_TIER - assert workflow["jobs"]["summarize-results"]["with"]["tier"] == SELECTED_TIER - assert '--category nl2al --tier "$env:TIER" --github-output version' in text - assert 'evaluate bcal "${{ matrix.entry }}" --tier "$env:TIER"' in text - - -def test_bcal_downloads_symbols_from_the_selected_tier(): - step = _step(_workflow("bcal-evaluation.yml"), "evaluate-with-bcal", "Download BC Application symbols") - - assert '-Category nl2al -Tier "$env:TIER"' in step["run"] - - -def test_bcal_run_identity_includes_tier_and_package_selection(): - workflow = _workflow("bcal-evaluation.yml") - - assert workflow["run-name"].startswith(f"BCal {SELECTED_TIER} ${{{{ inputs.bcal-feed || 'official' }}}}@${{{{ inputs.bcal-version || 'latest' }}}} ") - assert workflow["concurrency"]["group"] == "bcal-evaluation-${{ inputs.test-run && 'test' || 'full' }}" - - -def test_bcal_supports_gpt6_luna_for_generation_and_completion_review(): - workflow = _workflow("bcal-evaluation.yml") - inputs = workflow[True]["workflow_dispatch"]["inputs"] - run = _step(workflow, "evaluate-with-bcal", "Run BCal for entry ${{ matrix.entry }}") - - assert "gpt-6-luna" in inputs["external-model"]["options"] - assert run["env"]["BCAL_LLM_MODEL"] == "${{ inputs.external-model || 'gpt-55-chat' }}" - assert workflow["jobs"]["summarize-results"]["with"]["model"] == run["env"]["BCAL_LLM_MODEL"] - assert "gpt-6-luna" in inputs["completion-review-model"]["options"] - - -def test_bcal_completion_review_model_offers_external_models_or_none(): - workflow = _workflow("bcal-evaluation.yml") - inputs = workflow[True]["workflow_dispatch"]["inputs"] - review_model = inputs["completion-review-model"] - run = _step(workflow, "evaluate-with-bcal", "Run BCal for entry ${{ matrix.entry }}") - - assert review_model["default"] == "none" - assert review_model["options"] == ["none", *inputs["external-model"]["options"]] - assert run["env"]["BCAL_COMPLETION_REVIEW_MODEL"] == "${{ inputs.completion-review-model != 'none' && inputs.completion-review-model || '' }}" - - -def test_bcal_feed_selects_official_or_internal_test_feed(): - workflow = _workflow("bcal-evaluation.yml") - feed = workflow[True]["workflow_dispatch"]["inputs"]["bcal-feed"] - install = _step(workflow, "evaluate-with-bcal", "Install bcal CLI from internal feed") - - assert feed["default"] == "official" - assert feed["options"] == ["official", "experiment"] - assert install["with"]["feed"] == "${{ inputs.bcal-feed || 'official' }}" - assert install["with"]["official-feed-url"] == "${{ secrets.BCAL_FEED_URL }}" - assert install["with"]["experiment-feed-url"] == "${{ secrets.BCAL_TEST_FEED_URL }}" - - -def test_bcal_installs_selected_package(): - workflow = _workflow_text("bcal-evaluation.yml") - install = _step(_workflow("bcal-evaluation.yml"), "evaluate-with-bcal", "Install bcal CLI from internal feed") - action = yaml.safe_load((WORKFLOWS.parent / "actions" / "install-bcal" / "action.yml").read_text(encoding="utf-8")) - action_install = _step_named(action["runs"]["steps"], "Install BCal package") - - assert install["uses"] == "$/.github/actions/install-bcal" - assert install["with"]["version"] == "${{ env.BCAL_REQUESTED_VERSION }}" - assert "bcal-version-mode" not in workflow - assert '@("--version", $env:BCAL_REQUESTED_VERSION)' in action_install["run"] - assert '@("--prerelease")' in action_install["run"] - assert "--source $feedUrl" in action_install["run"] - assert 'throw "No feed URL configured' in action_install["run"] - assert "--add-source" not in action_install["run"] - assert "${{ inputs." not in action_install["run"] - - -def test_experimental_feed_runs_are_published_as_experiments(): - job = _workflow("bcal-evaluation.yml")["jobs"]["summarize-results"] - summarize = _workflow("summarize-results.yml") - - assert job["with"]["experiment"] == "${{ inputs.bcal-feed == 'experiment' }}" - assert summarize[True]["workflow_call"]["inputs"]["experiment"]["default"] is False - assert "${{ inputs.experiment && '--eval-run-type experiment' || '' }}" in _step(summarize, "summarize-results", "Upload result using bceval")["run"] - - -def test_bceval_workflows_use_supported_version_and_storage(): - bcal = _step(_workflow("bcal-evaluation.yml"), "evaluate-with-bcal", "Build bc-eval LLM API bridge venv")["run"] - summarize = _step(_workflow("summarize-results.yml"), "summarize-results", "Upload result using bceval") - - assert '"bc-eval==0.11.0"' in bcal - assert "bc-eval==0.11.0 --python 3.13" in summarize["run"] - assert "--storage braintrust" not in summarize["run"] - assert "--storage kusto" in summarize["run"] - assert "BRAINTRUST_PROJECT_ID" not in summarize["env"] - assert "BRAINTRUST_API_KEY" not in summarize["env"] diff --git a/tests/test_review_workflows.py b/tests/test_review_workflows.py deleted file mode 100644 index 3f58a14a0..000000000 --- a/tests/test_review_workflows.py +++ /dev/null @@ -1,205 +0,0 @@ -import json -import os -import shutil -import subprocess -from pathlib import Path - -import pytest -import yaml - -WORKFLOWS = Path(__file__).parents[1] / ".github" / "workflows" -ACTIONS = Path(__file__).parents[1] / ".github" / "actions" -AGENT_CONFIG = Path(__file__).parents[1] / "src" / "bcbench" / "agent" / "shared" / "config.yaml" -DEFAULT_ENGINE_SHA = "ecf8e31759d6ddd6d78e3a0b7836b40134368009" -PWSH = shutil.which("pwsh") - - -def _workflow(name: str) -> str: - text = (WORKFLOWS / name).read_text(encoding="utf-8") - assert yaml.safe_load(text) - return text - - -def test_copilot_workflow_routes_code_review_through_copilot() -> None: - workflow = _workflow("copilot-evaluation.yml") - - assert '"code-review"' in workflow - assert "bcbench evaluate copilot" in workflow - assert "bcbench evaluate pr-review" not in workflow - assert "BC_PR_REVIEW_ROOT" not in workflow - assert 'agent: "GitHub Copilot CLI"' in workflow - - -def test_claude_workflow_routes_code_review_through_claude() -> None: - workflow = _workflow("claude-evaluation.yml") - - assert '"code-review"' in workflow - assert "bcbench evaluate claude" in workflow - assert 'agent: "Claude Code"' in workflow - - -def test_pr_review_workflow_is_fixed_to_code_review() -> None: - workflow = _workflow("pr-review-evaluation.yml") - config = yaml.safe_load(AGENT_CONFIG.read_text(encoding="utf-8")) - - assert "category: code-review" in workflow - assert "bcbench evaluate pr-review" in workflow - assert "Checkout BC-ALAgents review engine" not in workflow - assert '--engine-path "${{ steps.install-harnesses.outputs.bc-alagents-path }}"' in workflow - assert config["pr_review"] == {"min_severity": "Medium"} - assert "BC_PR_REVIEW_ROOT:" not in workflow - assert "install-agent-harnesses" in workflow - assert "install-eval-clis" not in workflow - assert "copilot-requests: write" in workflow - assert 'agent: "BC PR Review"' in workflow - assert '"mai-code-1.1-flash"' in workflow - assert "mai-code-1-flash-picker" not in workflow - assert '"gemini-3.7-flash"' in workflow - assert "gemini-3.6-flash" not in workflow - for input_name in ("model:", "engine-sha:", "test-run:", "repeat:", "git-ref:", "modified-only:"): - assert input_name in workflow - - -def test_pr_review_workflow_passes_optional_engine_sha_to_harness_action() -> None: - workflow = yaml.safe_load(_workflow("pr-review-evaluation.yml")) - engine_input = workflow[True]["workflow_dispatch"]["inputs"]["engine-sha"] - install = next(step for step in workflow["jobs"]["evaluate-with-pr-review"]["steps"] if step.get("id") == "install-harnesses") - - assert engine_input["required"] is False - assert engine_input["default"] == "" - assert engine_input["type"] == "string" - assert install["with"]["engine-sha"] == "${{ inputs.engine-sha }}" - assert DEFAULT_ENGINE_SHA not in _workflow("pr-review-evaluation.yml") - - -def test_engine_sha_override_is_never_published_as_a_benchmark_result() -> None: - """An override runs a revision other than the reviewed default pin, so it must stay off the dashboards.""" - workflow = yaml.safe_load(_workflow("pr-review-evaluation.yml")) - summarize = workflow["jobs"]["summarize-results"]["with"] - - assert summarize["mock"] == "${{ inputs.test-run || inputs.modified-only || inputs.engine-sha != '' }}" - # Repeats stay available so an override can be measured over several runs. - assert "inputs.engine-sha" not in workflow["jobs"]["requeue"]["if"] - - -@pytest.mark.parametrize("engine_sha", ["", "a" * 40, "A" * 40, "'\"$(echo injected)"]) -def test_pr_review_requeue_preserves_engine_sha(engine_sha: str) -> None: - workflow = yaml.safe_load(_workflow("pr-review-evaluation.yml")) - payload = workflow["jobs"]["requeue"]["with"]["workflow-inputs"] - expression = "${{ toJSON(inputs.engine-sha) }}" - - assert expression in payload - assert json.loads(payload.replace(expression, json.dumps(engine_sha)))["engine-sha"] == engine_sha - - -def test_requeue_workflow_reads_inputs_from_environment() -> None: - workflow = yaml.safe_load(_workflow("requeue-evaluation.yml")) - requeue = workflow["jobs"]["requeue-if-needed"]["steps"][0] - - assert requeue["env"]["INPUTS_JSON"] == "${{ inputs.workflow-inputs }}" - assert "${{ inputs.workflow-inputs }}" not in requeue["run"] - assert """printf '%s' "${INPUTS_JSON}" | jq""" in requeue["run"] - assert "select(.value != null)" in requeue["run"] - assert '"${ARGS[@]}"' in requeue["run"] - - -def test_pr_review_workflow_propagates_modified_only() -> None: - workflow = _workflow("pr-review-evaluation.yml") - - # Entry selection is delegated to get-entries.yml, which already implements --modified-only. - assert "modified-only: ${{ inputs.modified-only }}" in workflow - - -def test_pr_review_workflow_treats_modified_only_as_a_partial_run() -> None: - """A modified-only run scores a subset, so it must not be recorded as a benchmark result.""" - workflow = _workflow("pr-review-evaluation.yml") - - # Publishing to Braintrust/Kusto and the leaderboard is gated on `mock`. - assert "inputs.test-run || inputs.modified-only ||" in workflow - assert "retention-days: ${{ (inputs.test-run || inputs.modified-only) && 1 || 30 }}" in workflow - # One run verifies the new entries; repeats are for the full corpus after merge. - assert "!inputs.test-run && !inputs.modified-only" in workflow - # With requeue disabled, pin-commit must not create a tag nothing would clean up. - assert "test-run: ${{ inputs.test-run || inputs.modified-only }}" in workflow - # A requeued run is always a full-corpus run, so the payload must not carry the flag. - assert "modified-only" not in workflow.split("workflow-inputs:")[1] - - -def test_agent_harness_action_pins_published_copilot_version() -> None: - action = (ACTIONS / "install-agent-harnesses" / "action.yml").read_text(encoding="utf-8") - - assert "@github/copilot@1.0.82" in action - - -def test_agent_harness_action_pins_and_exports_bc_alagents() -> None: - action = (ACTIONS / "install-agent-harnesses" / "action.yml").read_text(encoding="utf-8") - config = yaml.safe_load(action) - validation = next(step for step in config["runs"]["steps"] if step.get("id") == "engine-sha") - checkout = next(step for step in config["runs"]["steps"] if step.get("uses", "").startswith("actions/checkout@")) - - assert "repository: microsoft/BC-ALAgents" in action - assert "bc-alagents-path:" in action - assert config["inputs"]["engine-sha"]["required"] is False - assert config["inputs"]["engine-sha"]["default"] == "" - assert validation["env"]["ENGINE_SHA"] == "${{ inputs.engine-sha || '" + DEFAULT_ENGINE_SHA + "' }}" - assert "${{" not in validation["run"] - assert action.count(DEFAULT_ENGINE_SHA) == 1 - assert config["runs"]["steps"].index(validation) < config["runs"]["steps"].index(checkout) - assert checkout["with"]["ref"] == "${{ steps.engine-sha.outputs.sha }}" - assert checkout["with"]["persist-credentials"] is False - assert set(config["outputs"]) == {"bc-alagents-path"} - - -@pytest.mark.skipif(PWSH is None, reason="PowerShell is required to test the composite action script") -@pytest.mark.parametrize( - ("engine_sha", "valid"), - [ - ("", True), - ("a" * 40, True), - ("ABCDEF0123" * 4, True), - ("main", False), - ("v1.39.6", False), - ("ecf8e31", False), - ("a" * 39, False), - ("a" * 41, False), - ("g" * 40, False), - (" " * 40, False), - ("a" * 40 + "\n", False), - ("a" * 40 + "\r\n", False), - ("a" * 40 + "; Write-Output injected", False), - ("$(Write-Output injected)", False), - ], -) -def test_agent_harness_action_validates_engine_sha(engine_sha: str, valid: bool, tmp_path: Path) -> None: - assert PWSH is not None - action = yaml.safe_load((ACTIONS / "install-agent-harnesses" / "action.yml").read_text(encoding="utf-8")) - validation = next(step for step in action["runs"]["steps"] if step.get("id") == "engine-sha") - output = tmp_path / "github-output" - resolved_sha = engine_sha or DEFAULT_ENGINE_SHA - - result = subprocess.run( - [PWSH, "-NoProfile", "-NonInteractive", "-Command", validation["run"]], - env={**os.environ, "ENGINE_SHA": resolved_sha, "GITHUB_OUTPUT": str(output)}, - capture_output=True, - text=True, - check=False, - ) - - if valid: - assert result.returncode == 0, result.stderr - assert output.read_text(encoding="utf-8") == f"sha={resolved_sha}\n" - else: - assert result.returncode != 0 - assert "engine-sha must be a full 40-character hexadecimal commit SHA." in result.stderr - assert not output.exists() - - -def test_agent_workflows_select_al_tool_dotnet_version_for_bc_version() -> None: - setup_action = (ACTIONS / "setup-bc-container-repo" / "action.yml").read_text(encoding="utf-8") - - assert 'Major -lt 29) { "8.0" } else { "10.0" }' in setup_action - assert "al_tool_dotnet_version=$alToolDotNetVersion" in setup_action - - for workflow_name in ("claude-evaluation.yml", "copilot-evaluation.yml"): - workflow = _workflow(workflow_name) - assert '--framework "net${{ steps.setup-env.outputs.al_tool_dotnet_version }}"' in workflow From 60643233e730c488489799950a0e1f21b0c39c89 Mon Sep 17 00:00:00 2001 From: "Haoran Sun (Business Central)" Date: Fri, 27 Nov 2026 13:11:41 +0100 Subject: [PATCH 2/2] Leave contamination unchanged and drop the pipeline tests Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .azuredevops/copilot-evaluation.yml | 2 +- .github/workflows/contamination.yml | 1 + tests/test_azure_pipelines.py | 50 ------------------- ...ess_action.py => test_review_workflows.py} | 0 4 files changed, 2 insertions(+), 51 deletions(-) delete mode 100644 tests/test_azure_pipelines.py rename tests/{test_agent_harness_action.py => test_review_workflows.py} (100%) diff --git a/.azuredevops/copilot-evaluation.yml b/.azuredevops/copilot-evaluation.yml index 063decf17..f553fd8c9 100644 --- a/.azuredevops/copilot-evaluation.yml +++ b/.azuredevops/copilot-evaluation.yml @@ -89,6 +89,6 @@ extends: max_parallel: ${{ parameters.max_parallel }} # Keep in step with .github/actions/install-agent-harnesses/action.yml. copilot_version: 1.0.82 - # Must match EvaluationCategory.requires_container and requires_repo (tests/test_azure_pipelines.py). + # Must match EvaluationCategory.requires_container and requires_repo. container: ${{ in(parameters.category, 'bug-fix', 'test-generation', 'data-query') }} skip_repo: ${{ in(parameters.category, 'data-query') }} diff --git a/.github/workflows/contamination.yml b/.github/workflows/contamination.yml index ab13bfc2a..f5ed54fb5 100644 --- a/.github/workflows/contamination.yml +++ b/.github/workflows/contamination.yml @@ -57,6 +57,7 @@ jobs: if: needs.get-entries.outputs.entries != '[]' permissions: contents: read + id-token: write copilot-requests: write strategy: fail-fast: false diff --git a/tests/test_azure_pipelines.py b/tests/test_azure_pipelines.py deleted file mode 100644 index c049dc488..000000000 --- a/tests/test_azure_pipelines.py +++ /dev/null @@ -1,50 +0,0 @@ -import re -from pathlib import Path -from typing import Any - -import yaml - -from bcbench.types import EvaluationCategory - -ROOT = Path(__file__).parents[1] -COPILOT_EVALUATION = ROOT / ".azuredevops" / "copilot-evaluation.yml" - - -def _copilot_evaluation() -> dict[str, Any]: - pipeline = yaml.safe_load(COPILOT_EVALUATION.read_text(encoding="utf-8")) - assert isinstance(pipeline, dict) - return pipeline - - -def _jobs_template_parameters() -> dict[str, Any]: - parameters = _copilot_evaluation()["extends"]["parameters"]["stages"][0]["jobs"][0]["parameters"] - assert isinstance(parameters, dict) - return parameters - - -def _categories_in(expression: object) -> set[str]: - assert isinstance(expression, str) - match = re.fullmatch(r"\$\{\{ in\(parameters\.category, (.+)\) \}\}", expression) - assert match, expression - return set(re.findall(r"'([^']+)'", match.group(1))) - - -def test_copilot_evaluation_offers_every_copilot_category() -> None: - category = next(p for p in _copilot_evaluation()["parameters"] if p["name"] == "category") - - # NL2AL is evaluated with BCal in BC-Evals. - assert set(category["values"]) == {c.value for c in EvaluationCategory} - {EvaluationCategory.NL2AL.value} - - -def test_copilot_evaluation_routes_categories_by_their_environment() -> None: - parameters = _jobs_template_parameters() - copilot_categories = [c for c in EvaluationCategory if c is not EvaluationCategory.NL2AL] - - assert _categories_in(parameters["container"]) == {c.value for c in copilot_categories if c.requires_container} - assert _categories_in(parameters["skip_repo"]) == {c.value for c in copilot_categories if not c.requires_repo} - - -def test_copilot_evaluation_pins_the_same_copilot_cli_as_the_harness_action() -> None: - action = (ROOT / ".github" / "actions" / "install-agent-harnesses" / "action.yml").read_text(encoding="utf-8") - - assert f"@github/copilot@{_jobs_template_parameters()['copilot_version']}" in action diff --git a/tests/test_agent_harness_action.py b/tests/test_review_workflows.py similarity index 100% rename from tests/test_agent_harness_action.py rename to tests/test_review_workflows.py