File size: 3,964 Bytes
0827183
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#
# 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'))