466 строки
19 KiB
YAML
466 строки
19 KiB
YAML
# This is used in the pipeline Sample-Py-Zipdeploy-EchoBot-Linux-Test-yaml.
|
|
|
|
# 'Allow scripts to access the OAuth token' was selected in pipeline. Add the following YAML to any steps requiring access:
|
|
# env:
|
|
# MY_ACCESS_TOKEN: $(System.AccessToken)
|
|
# Variable 'AppId' is defined in Azure
|
|
# Variable 'AppSecret' is defined in Azure
|
|
# Variable 'AzureBotName' is defined in Azure
|
|
# Variable 'AzureSubscription' is defined in Azure
|
|
# Variable 'BotGroup' is defined in Azure
|
|
# Variable 'DeleteResourceGroup' is defined in Azure
|
|
# Variable 'MyGetPersonalAccessToken' is defined in Azure
|
|
# Variable 'MyGetFeedName' was defined in the Variables tab
|
|
# Variable 'PackageDependencyName' was defined in the Variables tab
|
|
# Variable 'runCodesignValidationInjection' is defined in Azure
|
|
# Variable 'SampleBotName' is defined in Azure
|
|
# Variable 'SampleFolderName' is defined in Azure
|
|
# Variable 'SampleRootPath' is defined in Azure
|
|
# Variable Group 'AzureDeploymentCredsVariableGroup' is defined in Azure
|
|
# Variable Group 'SamplesE2ETestsVariableGroup' is defined in Azure
|
|
# Variable Group 'MyGetPersonalAccessTokenVariableGroup' is defined in Azure
|
|
|
|
# Define the build number format.
|
|
name: $(Build.BuildId)
|
|
|
|
parameters:
|
|
- name: testLatestPackage
|
|
displayName: Test latest package version
|
|
type: boolean
|
|
default: true
|
|
- name: versionToTest
|
|
displayName: Version to test (Only if 'Test latest' is unchecked)
|
|
type: string
|
|
default: 'Example: 4.12.0.20210413.dev234515'
|
|
- name: packageFeed
|
|
displayName: Package feed to use
|
|
type: string
|
|
default: Azure
|
|
values:
|
|
- Azure
|
|
- MyGet
|
|
- PyPI
|
|
|
|
# Run this job every night at 2 AM (PST) on the main branch
|
|
schedules:
|
|
- cron: 0 9 * * *
|
|
displayName: Daily 2AM PST build
|
|
branches:
|
|
include:
|
|
- main
|
|
always: true
|
|
|
|
# Do not run PR validation
|
|
pr: none
|
|
|
|
# Do not run CI validation
|
|
trigger: none
|
|
|
|
resources:
|
|
repositories:
|
|
- repository: self
|
|
type: git
|
|
ref: main
|
|
|
|
#variables:
|
|
#- group: AzureDeploymentCredsVariableGroup
|
|
#- group: SamplesE2ETestsVariableGroup
|
|
#- group: MyGetPersonalAccessTokenVariableGroup
|
|
|
|
jobs:
|
|
- job: Job_1
|
|
displayName: Agent job 1
|
|
pool:
|
|
vmImage: windows-2019
|
|
steps:
|
|
- checkout: self
|
|
persistCredentials: True
|
|
|
|
- task: AzureCLI@2
|
|
displayName: 'Delete bot, app service, app service plan, group'
|
|
inputs:
|
|
azureSubscription: 'FUSE Temporary (174c5021-8109-4087-a3e2-a1de20420569)'
|
|
scriptType: ps
|
|
scriptLocation: inlineScript
|
|
inlineScript: |
|
|
Set-PSDebug -Trace 1;
|
|
|
|
Write-Host "1) Delete Bot:"
|
|
az bot delete --name $(AzureBotName) --resource-group $(BotGroup)
|
|
|
|
Write-Host "2) Delete App Service:"
|
|
az webapp delete --name $(AzureBotName) --resource-group $(BotGroup)
|
|
|
|
Write-Host "3) Delete App Service plan:"
|
|
az appservice plan delete --name $(AzureBotName) --resource-group $(BotGroup) --yes
|
|
|
|
Write-Host "4) Delete Resource Group:"
|
|
az group delete --name $(BotGroup) --yes
|
|
|
|
Set-PSDebug -Trace 0;
|
|
enabled: false
|
|
continueOnError: true
|
|
condition: and(succeededOrFailed(), ne(variables['DeleteResourceGroup'], 'false'))
|
|
|
|
- powershell: |
|
|
$packageName = "botbuilder-integration-aiohttp";
|
|
$url = "https://feeds.dev.azure.com/ConversationalAI/BotFramework/_apis/packaging/Feeds/SDK/Packages/26dde74d-6079-401c-a9e0-c6d839e02c18/versions?api-version=5.1-preview.1"
|
|
|
|
Write-Host "Get latest $packageName version number from ConversationalAI BotFramework SDK feed";
|
|
$result = Invoke-RestMethod -Uri $url -Method Get -ContentType "application/json";
|
|
[string]$latestVersion = $result.value[0].protocolMetadata.data.version;
|
|
|
|
$packageName;
|
|
$latestVersion;
|
|
"##vso[task.setvariable variable=TargetVersion;]$latestVersion";
|
|
displayName: 'From Azure feed get latest botbuilder package version - https://dev.azure.com/ConversationalAI/BotFramework/_packaging?_a=feed&feed=SDK'
|
|
condition: ${{ and(eq(parameters.testLatestPackage, true), eq(parameters.packageFeed, 'Azure')) }}
|
|
|
|
- powershell: |
|
|
$myGetFeedName = "botbuilderdaily_python";
|
|
$packageName = "botbuilder-ai";
|
|
$url = "https://botbuilder.myget.org/F/$myGetFeedName/python"
|
|
|
|
py -m pip install --index-url $url $packageName== 2>&1 | Tee-Object -Variable pipError | Out-Null
|
|
|
|
[string]$errorString = $pipError
|
|
$start = $errorString.IndexOf("from versions:") + 15;
|
|
$end = $errorString.IndexOf(")");
|
|
$versions = $errorString.Substring($start, $end - $start);
|
|
$versionsArray = $versions -Split ", ";
|
|
$latestVersion = $versionsArray[-1];
|
|
" ";
|
|
$packageName;
|
|
"Available versions:";
|
|
$versionsArray | Select -Last 30;
|
|
" ";
|
|
"Latest version:";
|
|
$latestVersion;
|
|
|
|
"##vso[task.setvariable variable=TargetVersion;]$latestVersion";
|
|
errorActionPreference: continue
|
|
ignoreLASTEXITCODE: true
|
|
displayName: 'From MyGet feed get latest Bot.Builder version number - https://botbuilder.myget.org/gallery/botbuilder-v4-dotnet-daily'
|
|
condition: ${{ and(eq(parameters.testLatestPackage, true), eq(parameters.packageFeed, 'MyGet')) }}
|
|
|
|
- powershell: |
|
|
$packageName = "botbuilder-integration-aiohttp";
|
|
|
|
py -m pip install yolk3k;
|
|
$result = py -m yolk -V $packageName;
|
|
|
|
$array = $result -split " ";
|
|
$latestVersion = $array[1];
|
|
" ";
|
|
$packageName;
|
|
$latestVersion;
|
|
|
|
"##vso[task.setvariable variable=TargetVersion;]$latestVersion";
|
|
displayName: 'From PyPI feed get latest botbuilder package version - https://pypi.org/search/?q=botbuilder&o='
|
|
condition: ${{ and(eq(parameters.testLatestPackage, true), eq(parameters.packageFeed, 'PyPI')) }}
|
|
|
|
- powershell: |
|
|
$targetVersion = "${{ parameters.versionToTest }}";
|
|
$targetVersion;
|
|
"##vso[task.setvariable variable=TargetVersion;]$targetVersion";
|
|
displayName: 'From user input get specific botbuilder version number'
|
|
condition: ${{ ne(parameters.testLatestPackage, true) }}
|
|
|
|
- powershell: 'gci env:* | sort-object name | Format-Table -AutoSize -Wrap'
|
|
displayName: 'Display env vars'
|
|
|
|
- task: tagBuildOrRelease@0
|
|
displayName: Tag Build with botbuilder version
|
|
inputs:
|
|
tags: |
|
|
Using botbuilder version $(TargetVersion)
|
|
From ${{ parameters.packageFeed }} feed
|
|
Test latest = ${{ parameters.testLatestPackage }}
|
|
|
|
- powershell: |
|
|
# This adapted from PyPySkillBotFunctionalTest, file BotFramework-FunctionalTests\build\yaml\pythonDeploySteps.yml, task Set BotBuilder Package Version & Registry Url.
|
|
|
|
$file = "$(SampleRootPath)/requirements.txt";
|
|
|
|
$indexUrl = "https://pkgs.dev.azure.com/ConversationalAI/BotFramework/_packaging/SDK/pypi/simple/"
|
|
$extraIndexUrl = "https://pypi.org/simple/"
|
|
|
|
$comparisonOperator = ""
|
|
$newVersion = ""
|
|
$pipInstallOption = "--pre" # Include prerelease and development versions.
|
|
|
|
# Add the index URL specs at the beginning of the requirements.txt file
|
|
$content = @(Get-Content $file)
|
|
Set-Content -Path $file -Value ("$pipInstallOption --index-url $indexUrl --extra-index-url $extraIndexUrl".Trim())
|
|
Add-Content -Path $file -Value $content
|
|
|
|
function UpdatePackageVersion($package) {
|
|
# Set Package version to empty value
|
|
$content = @(Get-Content $file)
|
|
$matchinfo = Select-String -Path $file -Pattern $package
|
|
|
|
$script = "$package $comparisonOperator $newVersion"
|
|
|
|
# Update or add dependency
|
|
if($matchinfo.LineNumber -gt 0) {
|
|
$content[$matchinfo.LineNumber - 1] = $script
|
|
Set-Content -Path $file -Value $content
|
|
|
|
} else {
|
|
Add-Content -Path $file -Value $script
|
|
}
|
|
}
|
|
|
|
UpdatePackageVersion "botbuilder-integration-aiohttp"
|
|
UpdatePackageVersion "botbuilder-dialogs"
|
|
UpdatePackageVersion "botbuilder-ai"
|
|
|
|
'------ $file -------'; get-content $file; '===================';
|
|
displayName: 'For Azure feed, set requirements.txt to get targeted botframework packages'
|
|
condition: ${{ eq(parameters.packageFeed, 'Azure') }}
|
|
|
|
- powershell: |
|
|
# This adapted from PyPySkillBotFunctionalTest, file BotFramework-FunctionalTests\build\yaml\pythonDeploySteps.yml, task Set BotBuilder Package Version & Registry Url.
|
|
|
|
$file = "$(SampleRootPath)/requirements.txt";
|
|
|
|
$indexUrl = "https://botbuilder.myget.org/F/botbuilderdaily_python/python/"
|
|
$extraIndexUrl = "https://pypi.org/simple/"
|
|
|
|
$comparisonOperator = ""
|
|
$newVersion = ""
|
|
$pipInstallOption = "--pre" # Include prerelease and development versions.
|
|
|
|
# Add the index URL specs at the beginning of the requirements.txt file
|
|
$content = @(Get-Content $file)
|
|
Set-Content -Path $file -Value ("$pipInstallOption --index-url $indexUrl --extra-index-url $extraIndexUrl".Trim())
|
|
Add-Content -Path $file -Value $content
|
|
|
|
function UpdatePackageVersion($package) {
|
|
# Set Package version to empty value
|
|
$content = @(Get-Content $file)
|
|
$matchinfo = Select-String -Path $file -Pattern $package
|
|
|
|
$script = "$package $comparisonOperator $newVersion"
|
|
|
|
# Update or add dependency
|
|
if($matchinfo.LineNumber -gt 0) {
|
|
$content[$matchinfo.LineNumber - 1] = $script
|
|
Set-Content -Path $file -Value $content
|
|
|
|
} else {
|
|
Add-Content -Path $file -Value $script
|
|
}
|
|
}
|
|
|
|
UpdatePackageVersion "botbuilder-integration-aiohttp"
|
|
UpdatePackageVersion "botbuilder-dialogs"
|
|
UpdatePackageVersion "botbuilder-ai"
|
|
|
|
'------ $file -------'; get-content $file; '===================';
|
|
displayName: 'For MyGet feed, set requirements.txt to get targeted botframework packages'
|
|
condition: ${{ eq(parameters.packageFeed, 'MyGet') }}
|
|
|
|
- powershell: |
|
|
# This adapted from PyPySkillBotFunctionalTest, file BotFramework-FunctionalTests\build\yaml\pythonDeploySteps.yml, task Set BotBuilder Package Version & Registry Url.
|
|
|
|
$file = "$(SampleRootPath)/requirements.txt";
|
|
|
|
$indexUrl = "https://pypi.org/simple/"
|
|
$extraIndexUrl = "https://pypi.org/simple/"
|
|
|
|
$comparisonOperator = ""
|
|
$newVersion = ""
|
|
$pipInstallOption = "--pre" # Include prerelease and development versions.
|
|
|
|
# Add the index URL specs at the beginning of the requirements.txt file
|
|
$content = @(Get-Content $file)
|
|
Set-Content -Path $file -Value ("$pipInstallOption --index-url $indexUrl --extra-index-url $extraIndexUrl".Trim())
|
|
Add-Content -Path $file -Value $content
|
|
|
|
function UpdatePackageVersion($package) {
|
|
# Set Package version to empty value
|
|
$content = @(Get-Content $file)
|
|
$matchinfo = Select-String -Path $file -Pattern $package
|
|
|
|
$script = "$package $comparisonOperator $newVersion"
|
|
|
|
# Update or add dependency
|
|
if($matchinfo.LineNumber -gt 0) {
|
|
$content[$matchinfo.LineNumber - 1] = $script
|
|
Set-Content -Path $file -Value $content
|
|
|
|
} else {
|
|
Add-Content -Path $file -Value $script
|
|
}
|
|
}
|
|
|
|
UpdatePackageVersion "botbuilder-integration-aiohttp"
|
|
UpdatePackageVersion "botbuilder-dialogs"
|
|
UpdatePackageVersion "botbuilder-ai"
|
|
|
|
'------ $file -------'; get-content $file; '===================';
|
|
displayName: 'For PyPI feed, set requirements.txt to get targeted botframework packages'
|
|
condition: ${{ eq(parameters.packageFeed, 'PyPI') }}
|
|
|
|
- task: UsePythonVersion@0
|
|
displayName: Use Python 3.x
|
|
|
|
- task: AzureCLI@2
|
|
displayName: 'Preexisting RG: create Azure resources. Runs in even builds.'
|
|
inputs:
|
|
azureSubscription: 'FUSE Temporary'
|
|
scriptType: ps
|
|
scriptLocation: inlineScript
|
|
inlineScript: |
|
|
Write-Host "`n***** Creating Azure resources using the preexisting-rg template *****";
|
|
Write-Host "This task runs for even-numbered builds. Build ID = $(Build.BuildId)";
|
|
Write-Host "************************************************************************";
|
|
Set-PSDebug -Trace 1;
|
|
|
|
az group create --location westus --name $(BotGroup);
|
|
|
|
# set up app service plan, app service (web app)
|
|
az deployment group create --resource-group "$(BotGroup)" --template-file "$(SampleRootPath)\DeploymentTemplates\DeployUseExistResourceGroup\template-BotApp-with-rg.json" --parameters appId="$(AppId)" appSecret="$(AppSecret)" appServiceName="$(AzureBotName)" newAppServicePlanName="$(AzureBotName)" newAppServicePlanLocation="westus" --name "$(AzureBotName)";
|
|
|
|
# set up bot channels registration
|
|
az deployment group create --resource-group "$(BotGroup)" --template-file "$(SampleRootPath)\DeploymentTemplates\DeployUseExistResourceGroup\template-AzureBot-with-rg.json" --parameters appId="$(AppId)" azureBotId="$(AzureBotName)";
|
|
|
|
Set-PSDebug -Trace 0;
|
|
condition: and(succeeded(), or( endsWith(variables['Build.BuildId'], 0), endsWith(variables['Build.BuildId'], 2), endsWith(variables['Build.BuildId'], 4), endsWith(variables['Build.BuildId'], 6), endsWith(variables['Build.BuildId'], 8)))
|
|
|
|
- task: AzureCLI@2
|
|
displayName: 'New RG: create Azure resources. Runs in odd builds.'
|
|
inputs:
|
|
azureSubscription: 'FUSE Temporary'
|
|
scriptType: ps
|
|
scriptLocation: inlineScript
|
|
inlineScript: |
|
|
Write-Host "`n***** Creating Azure resources using the new-rg template *****";
|
|
Write-Host "This task runs for odd-numbered builds. Build ID = $(Build.BuildId)";
|
|
Write-Host "****************************************************************";
|
|
Set-PSDebug -Trace 1;
|
|
|
|
# set up resource group, app service plan, app service (web app)
|
|
az deployment sub create --name "$(BotGroup)" --template-file "$(SampleRootPath)\DeploymentTemplates\DeployWithNewResourceGroup\template-BotApp-new-rg.json" --location "westus" --parameters appId=$(AppId) appSecret="$(AppSecret)" appServiceName="$(AzureBotName)" appServicePlanName="$(AzureBotName)" groupName="$(BotGroup)" groupLocation="westus" appServicePlanLocation="westus";
|
|
|
|
# set up bot channels registration
|
|
az deployment sub create --name "$(BotGroup)" --template-file "$(SampleRootPath)\DeploymentTemplates\DeployWithNewResourceGroup\template-AzureBot-new-rg.json" --location "westus" --parameters appId=$(AppId) azureBotId="$(AzureBotName)" groupName="$(BotGroup)" groupLocation="westus";
|
|
|
|
Set-PSDebug -Trace 0;
|
|
condition: and(succeeded(), or( endsWith(variables['Build.BuildId'], 1), endsWith(variables['Build.BuildId'], 3), endsWith(variables['Build.BuildId'], 5), endsWith(variables['Build.BuildId'], 7), endsWith(variables['Build.BuildId'], 9)))
|
|
|
|
- task: AzureCLI@2
|
|
displayName: Create directline channel
|
|
inputs:
|
|
azureSubscription: 'FUSE Temporary'
|
|
scriptType: ps
|
|
scriptLocation: inlineScript
|
|
inlineScript: |
|
|
az bot directline create --name "$(AzureBotName)" --resource-group "$(BotGroup)" > "$(System.DefaultWorkingDirectory)\DirectLineCreate.json" --debug
|
|
|
|
- task: ArchiveFiles@2
|
|
displayName: Zip the bot
|
|
inputs:
|
|
rootFolderOrFile: $(SampleRootPath)
|
|
includeRootFolder: false
|
|
archiveFile: $(Build.ArtifactStagingDirectory)/testbot.zip
|
|
|
|
- task: PublishPipelineArtifact@1
|
|
displayName: Publish zip file to Pipeline Artifacts
|
|
inputs:
|
|
path: $(Build.ArtifactStagingDirectory)
|
|
artifactName: zipfile
|
|
continueOnError: true
|
|
|
|
- task: AzureCLI@2
|
|
displayName: Zip deploy the bot to Azure
|
|
inputs:
|
|
azureSubscription: 'FUSE Temporary'
|
|
scriptType: ps
|
|
scriptLocation: inlineScript
|
|
inlineScript: |
|
|
az webapp deployment source config-zip --resource-group "$(BotGroup)" --name "$(AzureBotName)" --src "$(Build.ArtifactStagingDirectory)/testbot.zip" --debug
|
|
|
|
- powershell: |
|
|
# Key = Direct Line channel "Secret keys" in Azure portal
|
|
$json = Get-Content '$(System.DefaultWorkingDirectory)\DirectLineCreate.json' | Out-String | ConvertFrom-Json;
|
|
$key = $json.properties.properties.sites.key;
|
|
echo "##vso[task.setvariable variable=DIRECTLINE;]$key";
|
|
echo "##vso[task.setvariable variable=BOTID;]$(AzureBotName)";
|
|
Write-Host "setx DIRECTLINE $key";
|
|
Write-Host "setx BOTID $(AzureBotName)";
|
|
displayName: Set DIRECTLINE key, BOTID for running tests
|
|
|
|
- task: NuGetToolInstaller@1
|
|
displayName: "Use NuGet latest"
|
|
|
|
- powershell: |
|
|
$file = "$(System.DefaultWorkingDirectory)/samples/csharp_dotnetcore/tests/Samples.$(SampleBotName).FunctionalTests/nuget.config";
|
|
|
|
$content = @"
|
|
<?xml version="1.0" encoding="utf-8"?>
|
|
<configuration>
|
|
<packageSources>
|
|
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
|
|
</packageSources>
|
|
<activePackageSource>
|
|
<add key="All" value="(Aggregate source)" />
|
|
</activePackageSource>
|
|
</configuration>
|
|
"@;
|
|
|
|
New-Item -Path $file -ItemType "file" -Value $content;
|
|
'-------------'; get-content "$file"; '==================='
|
|
displayName: Create nuget.config for Samples.$(SampleBotName).FunctionalTests.csproj for NuGet.org feed
|
|
|
|
- task: NuGetCommand@2
|
|
displayName: NuGet restore dotnet Samples.$(SampleBotName).FunctionalTests.csproj
|
|
inputs:
|
|
solution: samples/csharp_dotnetcore/tests/Samples.$(SampleBotName).FunctionalTests/Samples.$(SampleBotName).FunctionalTests.csproj
|
|
nugetConfigPath: $(System.DefaultWorkingDirectory)/samples/csharp_dotnetcore/tests/Samples.$(SampleBotName).FunctionalTests/nuget.config
|
|
|
|
- task: DotNetCoreCLI@2
|
|
displayName: dotnet build dotnet Samples.$(SampleBotName).FunctionalTests.csproj
|
|
inputs:
|
|
projects: $(System.DefaultWorkingDirectory)/samples/csharp_dotnetcore/tests/Samples.$(SampleBotName).FunctionalTests/Samples.$(SampleBotName).FunctionalTests.csproj
|
|
|
|
- task: DotNetCoreCLI@2
|
|
displayName: dotnet test
|
|
inputs:
|
|
command: test
|
|
projects: $(System.DefaultWorkingDirectory)/samples/csharp_dotnetcore/tests/Samples.$(SampleBotName).FunctionalTests/**Tests.csproj
|
|
arguments: --verbosity Normal
|
|
|
|
- script: |
|
|
dir .. /s
|
|
displayName: 'Dir workspace'
|
|
continueOnError: true
|
|
condition: always()
|
|
|
|
- task: AzureCLI@2
|
|
displayName: Delete bot, app service, app service plan, group
|
|
inputs:
|
|
azureSubscription: 'FUSE Temporary'
|
|
scriptType: ps
|
|
scriptLocation: inlineScript
|
|
inlineScript: |
|
|
Set-PSDebug -Trace 1;
|
|
|
|
Write-Host "1) Delete Bot:";
|
|
az bot delete --name $(AzureBotName) --resource-group $(BotGroup);
|
|
|
|
Write-Host "2) Delete App Service:";
|
|
az webapp delete --name $(AzureBotName) --resource-group $(BotGroup);
|
|
|
|
Write-Host "3) Delete App Service plan:";
|
|
az appservice plan delete --name $(AzureBotName) --resource-group $(BotGroup) --yes;
|
|
|
|
Write-Host "4) Delete Resource Group:";
|
|
az group delete --name $(BotGroup) --yes;
|
|
|
|
Set-PSDebug -Trace 0;
|
|
condition: and(succeededOrFailed(), ne(variables['DeleteResourceGroup'], 'false'))
|
|
continueOnError: True
|
|
...
|