-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbrowser-tests-build-ci.yml
135 lines (109 loc) · 4.86 KB
/
browser-tests-build-ci.yml
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#
# Run functional tests on browser bot deployed to Azure.
#
pool:
vmImage: 'windows-latest'
trigger:
- main
pr:
- main
variables:
TestResourceGroup: 'BrowserBotTest$(Build.BuildId)'
TestAppServicePlan: 'BrowserBotServicePlan$(Build.BuildId)'
TestWebApp: 'BrowserBotWebApp$(Build.BuildId)'
TESTURI: 'https://$(TestWebApp).azurewebsites.net/'
# AzureSubscription: define this in Azure
# ChromeDriverVersionOverride: (optional) define this in Azure. Sample values: '107.0.1'; '' (= no override)
steps:
- task: PowerShell@2
inputs:
targetType: inline
script: |
# Create DateTimeTag for Resource Group
$DateTimeTag=Get-Date -Format "yyyy-MM-ddTHH:mm:ssZ"
"##vso[task.setvariable variable=DateTimeTag]$DateTimeTag";
displayName: 'Create DateTimeTag for Resource Group'
# Get-Date on Azure DevOps returns a datetime relative to UTC-0, so "Z" is being used instead of the dynamic "K".
- task: PowerShell@2
inputs:
targetType: inline
script: |
$packageName = "chromedriver";
Write-Host "Get $packageName second latest version from npmjs.com";
$versions = npm view $packageName versions | ConvertFrom-Json;
$versionToUse = $versions[-2];
Write-Host "$packageName second latest = $versionToUse";
" "
if ($null -ne $Env:ChromeDriverVersionOverride -and $Env:ChromeDriverVersionOverride.Trim() -ne '') {
Write-Host "Pipeline var ChromeDriverVersionOverride is set.";
$versionToUse = $Env:ChromeDriverVersionOverride;
Write-Host "Use override value = $versionToUse";
} else {
Write-Host "Pipeline var ChromeDriverVersionOverride is not set.";
Write-Host "Use value = $versionToUse";
}
"##vso[task.setvariable variable=DriverVersion;]$versionToUse";
displayName: 'Get chromedriver version number to use'
- task: PowerShell@2
inputs:
targetType: inline
script: |
# This lets the pipeline automatically keep up with Chrome browser upgrades.
# Chrome browser upgrades on ADO agents lag behind chromedriver upgrades, so
# if we use the second latest chromedriver, that should keep the tests working.
$path = "$(System.DefaultWorkingDirectory)/testing/browser-functional/package.json";
$package = 'chromedriver';
$newVersion = "$(DriverVersion)";
$find = "$package`": `"\S*`"";
$replace = "$package`": `"$newVersion`"";
Get-ChildItem -Path "$path" | % {
$_.FullName;
$content = Get-Content -Raw $_.FullName;
$content -Replace "$find", "$replace" | Set-Content $_.FullName;
'-------------'; get-content $_.FullName; '==================='
}
displayName: 'Upgrade chromedriver version reference'
- task: NodeTool@0
displayName: use node 16.x
inputs:
versionSpec: 16.x
- script: cd testing/browser-functional/browser-echo-bot && yarn && yarn build
displayName: yarn install and build browser-echo-bot
- task: PowerShell@2
inputs:
targetType: inline
script: |
# Compress Bot Source Code
cd $(System.DefaultWorkingDirectory)/testing/browser-functional/browser-echo-bot/dist
$DirToCompress = "$(System.DefaultWorkingDirectory)/testing/browser-functional/browser-echo-bot/dist"
$files = Get-ChildItem -Path $DirToCompress
$ZipFileResult="$(System.DefaultWorkingDirectory)/testing/browser-functional/browser-echo-bot/browser-echo-bot.zip"
Compress-Archive -Path $files -DestinationPath $ZipFileResult
displayName: 'Compress Bot Source Code'
- task: AzureCLI@1
displayName: 'Deploy browser bot'
inputs:
azureSubscription: '$(AzureSubscription)'
scriptLocation: inlineScript
inlineScript: |
echo "# Create resource group"
call az group create -l westus -n "$(TestResourceGroup)" --tags buildName="$(Build.DefinitionName)" cause=automation date="$(DateTimeTag)" product="$(Build.Repository.Name)" sourceBranch="$(Build.SourceBranch)"
echo "# Create app service plan"
call az appservice plan create -g "$(TestResourceGroup)" -n "$(TestAppServicePlan)" --number-of-workers 4 --sku S1
echo "# Create web app"
call az webapp create -g "$(TestResourceGroup)" -p "$(TestAppServicePlan)" -n "$(TestWebApp)"
echo "# Deploy source code"
call az webapp deployment source config-zip --resource-group "$(TestResourceGroup)" --name "$(TestWebApp)" --src "$(System.DefaultWorkingDirectory)/testing/browser-functional/browser-echo-bot/browser-echo-bot.zip"
- script: yarn
displayName: yarn install
- script: yarn browser-functional-test chrome
displayName: run chrome tests
- script: yarn browser-functional-test firefox
displayName: run firefox tests
- task: AzureCLI@1
displayName: 'Delete Resource Group'
inputs:
azureSubscription: '$(AzureSubscription)'
scriptLocation: inlineScript
inlineScript: 'call az group delete -n $(TestResourceGroup) --yes'
condition: succeededOrFailed()