|  | 
|  | 1 | +#!/usr/bin/env pwsh | 
|  | 2 | + | 
|  | 3 | +<# | 
|  | 4 | +.SYNOPSIS | 
|  | 5 | +    Configures local repo for online evaluation tests, which use external resources. | 
|  | 6 | +
 | 
|  | 7 | +.DESCRIPTION | 
|  | 8 | +    This script copies appsettings files from a location on the developer's machine to the test | 
|  | 9 | +    project directories so that the tests are configured to connect to external resources. The online  | 
|  | 10 | +    configuration files are gitignore'd and not checked in to the repo. | 
|  | 11 | +
 | 
|  | 12 | +.PARAMETER Configure | 
|  | 13 | +    Configure this repo for online evaluation tests, by copying appsettings files from the developer's  | 
|  | 14 | +    machine to this repo. | 
|  | 15 | +.PARAMETER Unconfigure | 
|  | 16 | +    Unconfigure this repo for online evaluation tests, by removing the appsettings files from this repo. | 
|  | 17 | +.PARAMETER ConfigRoot | 
|  | 18 | +    ConfigRoot specifies where to copy the configuration files from. The default is $HOME/.config/dotnet-extensions. | 
|  | 19 | +#> | 
|  | 20 | + | 
|  | 21 | +param ( | 
|  | 22 | +    [switch]$Configure=$False, | 
|  | 23 | +    [switch]$Unconfigure=$False, | 
|  | 24 | +    [string]$ConfigRoot=$Null | 
|  | 25 | +) | 
|  | 26 | + | 
|  | 27 | +Write-Host "$PSScriptRoot" | 
|  | 28 | + | 
|  | 29 | +if ($Configure -and $Unconfigure) { | 
|  | 30 | +    Write-Error -Message "Cannot specify both -Configure and -Unconfigure" | 
|  | 31 | +    Exit 1 | 
|  | 32 | +} | 
|  | 33 | + | 
|  | 34 | +if (!(Test-Path $ConfigRoot)) { | 
|  | 35 | +    $ConfigRoot = "$HOME/.config/dotnet-extensions" | 
|  | 36 | +} | 
|  | 37 | + | 
|  | 38 | +$ProjectRoot = Resolve-Path "$PSScriptRoot/../test/Libraries" | 
|  | 39 | +$ReportingConfig = "Microsoft.Extensions.AI.Evaluation.Reporting.Tests/appsettings.local.json" | 
|  | 40 | +$IntegrationConfig = "Microsoft.Extensions.AI.Evaluation.Integration.Tests/appsettings.local.json" | 
|  | 41 | + | 
|  | 42 | +if ($Configure) { | 
|  | 43 | +    if (!(Test-Path -Path "$ConfigRoot/$ReportingConfig")) { | 
|  | 44 | +        Write-Host "No configuration found at $ConfigRoot/$ReportingConfig" | 
|  | 45 | +        Exit 0 | 
|  | 46 | +    } | 
|  | 47 | +    if (!(Test-Path -Path "$ConfigRoot/$IntegrationConfig")) { | 
|  | 48 | +        Write-Host "No configuration found at $ConfigRoot/$IntegrationConfig" | 
|  | 49 | +        Exit 0 | 
|  | 50 | +    } | 
|  | 51 | + | 
|  | 52 | +    Copy-Item -Path "$ConfigRoot/$ReportingConfig" -Destination "$ProjectRoot/$ReportingConfig" -Force | 
|  | 53 | +    Copy-Item -Path "$ConfigRoot/$IntegrationConfig" -Destination "$ProjectRoot/$IntegrationConfig" -Force | 
|  | 54 | + | 
|  | 55 | +    Write-Host "Test configured to use external resources" | 
|  | 56 | +} elseif ($Unconfigure) { | 
|  | 57 | +    Remove-Item -Path "$ProjectRoot/$ReportingConfig" -Force | 
|  | 58 | +    Remove-Item -Path "$ProjectRoot/$IntegrationConfig" -Force | 
|  | 59 | + | 
|  | 60 | +    Write-Host "Test unconfigured from using external resources" | 
|  | 61 | +} else { | 
|  | 62 | +    Write-Error -Message "Must specify either -Configure or -Unconfigure" | 
|  | 63 | +    Exit 1 | 
|  | 64 | +} | 
|  | 65 | + | 
0 commit comments