forked from Azure/azure-functions-dotnet-worker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-e2e-tests.ps1
113 lines (95 loc) · 2.97 KB
/
setup-e2e-tests.ps1
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
param(
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[String]
[ValidateSet("3", "4")]
$FunctionsRuntimeVersion,
[Switch]
$SkipStorageEmulator,
[Switch]
$SkipCosmosDBEmulator,
[Switch]
$SkipCoreTools,
[Switch]
$UseCoreToolsBuildFromIntegrationTests
)
# A function that checks exit codes and fails script if an error is found
function StopOnFailedExecution {
if ($LastExitCode)
{
exit $LastExitCode
}
}
if($SkipCoreTools)
{
Write-Host
Write-Host "---Skipping Core Tools download---"
}
else
{
$arch = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture.ToString().ToLowerInvariant()
if ($IsWindows) {
$os = "win"
$coreToolsURL = $env:CORE_TOOLS_URL
}
else {
if ($IsMacOS) {
$os = "osx"
} else {
$os = "linux"
$coreToolsURL = $env:CORE_TOOLS_URL_LINUX
}
}
if ($UseCoreToolsBuildFromIntegrationTests.IsPresent)
{
Write-Host ""
Write-Host "Install the Core Tools for Integration Tests..."
$coreToolsURL = "https://functionsintegclibuilds.blob.core.windows.net/builds/$FunctionsRuntimeVersion/latest/Azure.Functions.Cli.$os-$arch.zip"
$versionUrl = "https://functionsintegclibuilds.blob.core.windows.net/builds/$FunctionsRuntimeVersion/latest/version.txt"
}
else
{
if ([string]::IsNullOrWhiteSpace($coreToolsURL))
{
$coreToolsURL = "https://functionsclibuilds.blob.core.windows.net/builds/$FunctionsRuntimeVersion/latest/Azure.Functions.Cli.$os-$arch.zip"
$versionUrl = "https://functionsclibuilds.blob.core.windows.net/builds/$FunctionsRuntimeVersion/latest/version.txt"
}
}
Write-Host ""
Write-Host "---Downloading the Core Tools for Functions V$FunctionsRuntimeVersion---"
Write-Host "Core Tools download url: $coreToolsURL"
$FUNC_CLI_DIRECTORY = Join-Path $PSScriptRoot 'Azure.Functions.Cli'
Write-Host 'Deleting Functions Core Tools if exists...'
Remove-Item -Force "$FUNC_CLI_DIRECTORY.zip" -ErrorAction Ignore
Remove-Item -Recurse -Force $FUNC_CLI_DIRECTORY -ErrorAction Ignore
if ($versionUrl)
{
$version = Invoke-RestMethod -Uri $versionUrl
Write-Host "Downloading Functions Core Tools (Version: $version)..."
}
$output = "$FUNC_CLI_DIRECTORY.zip"
Invoke-RestMethod -Uri $coreToolsURL -OutFile $output
Write-Host 'Extracting Functions Core Tools...'
Expand-Archive $output -DestinationPath $FUNC_CLI_DIRECTORY
if ($IsMacOS -or $IsLinux)
{
& "chmod" "a+x" "$FUNC_CLI_DIRECTORY/func"
}
Write-Host "------"
}
if (Test-Path $output)
{
Remove-Item $output -Recurse -Force -ErrorAction Ignore
}
.\tools\devpack.ps1 -E2E -AdditionalPackArgs @("-c","Release") -SkipBuildOnPack
if ($SkipStorageEmulator -And $SkipCosmosDBEmulator)
{
Write-Host
Write-Host "---Skipping emulator startup---"
Write-Host
}
else
{
.\tools\start-emulators.ps1 -SkipStorageEmulator:$SkipStorageEmulator -SkipCosmosDBEmulator:$SkipCosmosDBEmulator
}
StopOnFailedExecution