# # Runs functional tests against the Slack channel. # # "name" here defines the build number format. Build number is accessed via $(Build.BuildNumber) name: $(Build.BuildId) pool: vmImage: $[ coalesce( variables['VMImage'], 'windows-2019' ) ] # or 'windows-latest' or 'vs2017-win2016' trigger: # ci trigger batch: true branches: include: - main paths: include: - '*' exclude: - doc/ - specs/ - LICENSE - README.md - UsingTestPyPI.md pr: # pr trigger branches: include: - main paths: include: - pipelines/botbuilder-python-ci-slack-test.yml variables: AppId: $(SlackTestBotAppId) AppSecret: $(SlackTestBotAppSecret) BotGroup: $(SlackTestBotBotGroup) BotName: $(SlackTestBotBotName) SlackBotToken: $(SlackTestBotSlackBotToken) SlackClientSigningSecret: $(SlackTestBotSlackClientSigningSecret) SlackVerificationToken: $(SlackTestBotSlackVerificationToken) # AzureSubscription: define this in Azure # SlackTestBotAppId: define this in Azure # SlackTestBotAppSecret: define this in Azure # SlackTestBotBotGroup: define this in Azure # SlackTestBotBotName: define this in Azure # SlackTestBotSlackBotToken: define this in Azure # SlackTestBotSlackChannel: define this in Azure # SlackTestBotSlackClientSigningSecret: define this in Azure # SlackTestBotSlackVerificationToken: define this in Azure # DeleteResourceGroup: (optional) define in Azure steps: - powershell: 'gci env:* | sort-object name | Format-Table -AutoSize -Wrap' displayName: 'Display env vars' - task: AzureCLI@2 displayName: 'Create Azure resources' inputs: azureSubscription: $(AzureSubscription) scriptType: pscore scriptLocation: inlineScript inlineScript: | Set-PSDebug -Trace 1; # set up resource group, bot channels registration, app service, app service plan az deployment sub create --name "$(BotName)" --template-file "$(System.DefaultWorkingDirectory)/libraries/functional-tests/slacktestbot/deploymentTemplates/template-with-new-rg.json" --location "westus" --parameters groupName="$(BotGroup)" appId="$(AppId)" appSecret="$(AppSecret)" botId="$(BotName)" botSku="F0" newAppServicePlanName="$(BotName)" newWebAppName="$(BotName)" slackVerificationToken="$(SlackVerificationToken)" slackBotToken="$(SlackBotToken)" slackClientSigningSecret="$(SlackClientSigningSecret)" groupLocation="westus" newAppServicePlanLocation="westus"; Set-PSDebug -Trace 0; - powershell: | 7z a -tzip "$(System.DefaultWorkingDirectory)/libraries/functional-tests/slacktestbot/bot.zip" "$(System.DefaultWorkingDirectory)/libraries/functional-tests/slacktestbot/*" -aoa displayName: 'Zip Bot' - task: AzureCLI@1 displayName: 'Deploy bot' inputs: azureSubscription: $(AzureSubscription) scriptType: ps scriptLocation: inlineScript inlineScript: | az webapp deployment source config-zip --resource-group "$(BotGroup)" --name "$(BotName)" --src "$(System.DefaultWorkingDirectory)/libraries/functional-tests/slacktestbot/bot.zip" --timeout 300 - script: | python -m pip install --upgrade pip pip install -r ./libraries/functional-tests/requirements.txt pip install pytest displayName: 'Install test dependencies' - script: | pytest test_slack_client.py workingDirectory: '$(System.DefaultWorkingDirectory)/libraries/functional-tests/tests/' displayName: Run test env: BotName: $(SlackTestBotBotName) SlackBotToken: $(SlackTestBotSlackBotToken) SlackChannel: $(SlackTestBotSlackChannel) SlackClientSigningSecret: $(SlackTestBotSlackClientSigningSecret) SlackVerificationToken: $(SlackTestBotSlackVerificationToken) - task: AzureCLI@1 displayName: 'Delete resources' inputs: azureSubscription: $(AzureSubscription) scriptLocation: inlineScript inlineScript: 'call az group delete -n "$(BotGroup)" --yes' condition: and(always(), ne(variables['DeleteResourceGroup'], 'false'))