forked from Azure/azure-functions-dotnet-worker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-e2e-tests.ps1
108 lines (94 loc) · 2.69 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
param(
[Parameter(Mandatory=$false)]
[Switch]
$SkipEmulators,
[Parameter(Mandatory=$false)]
[Switch]
$SkipCoreTools
)
# A function that checks exit codes and fails script if an error is found
function StopOnFailedExecution {
if ($LastExitCode)
{
exit $LastExitCode
}
}
$currDir = Get-Location
$output = "$currDir/Azure.Functions.Cli.zip"
if($SkipCoreTools)
{
Write-Host
Write-Host "---Skipping Core Tools download---"
}
else
{
Write-Host
Write-Host "---Core Tools download---"
Write-Host "Deleting Functions Core Tools if exists...."
Remove-Item -Force ./Azure.Functions.Cli.zip -ErrorAction Ignore
Remove-Item -Recurse -Force ./Azure.Functions.Cli -ErrorAction Ignore
if (!$IsWindows -and !$IsLinux)
{
# For pre-PS6
Write-Host "Could not resolve OS. Assuming Windows."
$IsWindows = $true
}
$coreToolsURL = ""
if ($IsWindows)
{
$coreToolsURL = $env:CORE_TOOLS_URL
if (!$coreToolsURL)
{
$coreToolsURL = "https://functionsclibuilds.blob.core.windows.net/builds/3/latest/Azure.Functions.Cli.min.win-x86.zip"
Write-Host "Using default url for Core Tools Windows: $coreToolsURL"
Invoke-RestMethod -Uri 'https://functionsclibuilds.blob.core.windows.net/builds/3/latest/version.txt' -OutFile version.txt
}
}
elseif ($IsLinux)
{
$coreToolsURL = $env:CORE_TOOLS_URL_LINUX
if (!$coreToolsURL)
{
$coreToolsURL = "https://functionsclibuilds.blob.core.windows.net/builds/3/latest/Azure.Functions.Cli.linux-x64.zip"
Write-Host "Using default url for Core Tools Linux: $coreToolsURL"
Invoke-RestMethod -Uri 'https://functionsclibuilds.blob.core.windows.net/builds/3/latest/version.txt' -OutFile version.txt
}
}
else
{
Write-Host "Could not determine the core tools URL."
exit 1
}
Write-Host "Downloading Core Tools from $coreToolsURL"
if (Test-Path version.txt)
{
Write-Host "Using Functions Core Tools version: $(Get-Content -Raw version.txt)"
Remove-Item version.txt
}
$wc = New-Object System.Net.WebClient
$wc.DownloadFile($coreToolsURL, $output)
$destinationPath = "./Azure.Functions.Cli"
Write-Host "Extracting Functions Core Tools to $destinationPath"
Expand-Archive "./Azure.Functions.Cli.zip" -DestinationPath $destinationPath
if ($IsLinux)
{
& "chmod" "a+x" "$destinationPath/func"
}
Write-Host "------"
}
if (Test-Path $output)
{
Remove-Item $output
}
.\tools\devpack.ps1 -E2E -AdditionalPackArgs @("-c","Release") -SkipBuildOnPack
if (!$SkipEmulators)
{
.\tools\start-emulators.ps1
}
else
{
Write-Host
Write-Host "---Skipping emulator startup---"
Write-Host
}
StopOnFailedExecution