Skip to content

Commit 20cb4e2

Browse files
committed
update core tools installation process and remove test stage
dependencies to increase pipeline efficiency
1 parent 537d678 commit 20cb4e2

File tree

2 files changed

+18
-31
lines changed

2 files changed

+18
-31
lines changed

eng/ci/official-build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ extends:
5151
- template: /eng/ci/templates/official/jobs/build-artifacts.yml@self
5252

5353
- stage: TestWindows
54-
dependsOn: Build
54+
dependsOn: []
5555
jobs:
5656
- template: /eng/ci/templates/jobs/run-emulated-tests-windows.yml@self
5757
parameters:
5858
poolName: 1es-pool-azfunc
5959

6060
- stage: TestLinux
61-
dependsOn: Build
61+
dependsOn: []
6262
jobs:
6363
- template: /eng/ci/templates/jobs/run-emulated-tests-linux.yml@self
6464
parameters:

setup-tests-pipeline.ps1

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,44 +4,31 @@
44
#
55
param
66
(
7-
[Switch]
8-
$UseCoreToolsBuildFromIntegrationTests
7+
[Switch]$UseCoreToolsBuildFromIntegrationTests
98
)
109

11-
$FUNC_RUNTIME_VERSION = '4'
12-
$arch = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture.ToString().ToLowerInvariant()
13-
$os = if ($IsWindows) { "win" } else { if ($IsMacOS) { "osx" } else { "linux" } }
10+
$FUNC_RUNTIME_VERSION = 'latest'
1411

15-
$env:CORE_TOOLS_URL = $null
16-
$coreToolsUrl = $null
17-
if ($UseCoreToolsBuildFromIntegrationTests.IsPresent)
18-
{
19-
Write-Host "Install the Core Tools for Integration Tests..."
20-
$env:CORE_TOOLS_URL = "https://functionsintegclibuilds.blob.core.windows.net/builds/$FUNC_RUNTIME_VERSION/latest/Azure.Functions.Cli.$os-$arch.zip"
21-
$coreToolsUrl = "https://functionsintegclibuilds.blob.core.windows.net/builds/$FUNC_RUNTIME_VERSION/latest"
22-
}
23-
else
24-
{
25-
Write-Host "Install the Core Tools..."
26-
$env:CORE_TOOLS_URL = "https://functionsclibuilds.blob.core.windows.net/builds/$FUNC_RUNTIME_VERSION/latest/Azure.Functions.Cli.$os-$arch.zip"
27-
$coreToolsUrl = "https://functionsclibuilds.blob.core.windows.net/builds/$FUNC_RUNTIME_VERSION/latest"
28-
}
12+
Write-Host "Installing Core Tools globlally using npm, version: $FUNC_RUNTIME_VERSION ..."
2913

3014
$FUNC_CLI_DIRECTORY = Join-Path $PSScriptRoot 'Azure.Functions.Cli'
15+
$InstallDir = $FUNC_CLI_DIRECTORY
16+
17+
# 1. Clean previous install
18+
Remove-Item -Recurse -Force $InstallDir -ErrorAction Ignore
19+
New-Item -ItemType Directory -Path $InstallDir -ErrorAction Ignore
3120

32-
Write-Host 'Deleting the Core Tools if exists...'
33-
Remove-Item -Force "$FUNC_CLI_DIRECTORY.zip" -ErrorAction Ignore
34-
Remove-Item -Recurse -Force $FUNC_CLI_DIRECTORY -ErrorAction Ignore
21+
# 2. Locate the global prefix and module root that npm just used
22+
$globalPrefix = (npm prefix -g | Out-String).Trim() # e.g. /usr/local or C:\Users\<user>\AppData\Roaming\npm
23+
$globalNode = (npm root -g | Out-String).Trim() # e.g. /usr/local/lib/node_modules
24+
$moduleRoot = Join-Path $globalNode 'azure-functions-core-tools'
3525

36-
$version = Invoke-RestMethod -Uri "$coreToolsUrl/version.txt"
37-
Write-Host "Downloading the Core Tools (Version: $version)..."
26+
# 3. npm install → temp folder
27+
npm install -g azure-functions-core-tools@$FUNC_RUNTIME_VERSION --unsafe-perm true --foreground-scripts --loglevel verbose
3828

39-
$output = "$FUNC_CLI_DIRECTORY.zip"
40-
Write-Host "Downloading the Core Tools from url: $env:CORE_TOOLS_URL"
41-
Invoke-RestMethod -Uri $env:CORE_TOOLS_URL -OutFile $output
29+
# 4. Copy CLI payload into the layout required by your tests
30+
Copy-Item "$moduleRoot\bin\*" $InstallDir -Recurse -Force
4231

43-
Write-Host 'Extracting Core Tools...'
44-
Expand-Archive $output -DestinationPath $FUNC_CLI_DIRECTORY
4532

4633
if (-not $UseCoreToolsBuildFromIntegrationTests.IsPresent)
4734
{

0 commit comments

Comments
 (0)