From cf38d4d8bcb97815eaf6c9782221381593ac37ff Mon Sep 17 00:00:00 2001 From: Fabio Cavalcante Date: Fri, 31 Jul 2026 11:26:34 -0700 Subject: [PATCH] Route package restores through CFS Configure npm global installs and the detached E2E NuGet restore to use azfunc/public/upstream-public with explicit Azure Pipelines authentication. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .npmrc | 11 ++++++++ NuGet.config | 13 +++++++++ build.ps1 | 20 +++++++++++++- eng/ci/templates/jobs/build.yml | 10 ++++++- .../official/jobs/build-and-test.yml | 27 ++++++++++++++++--- 5 files changed, 75 insertions(+), 6 deletions(-) create mode 100644 .npmrc create mode 100644 NuGet.config diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..98636b7 --- /dev/null +++ b/.npmrc @@ -0,0 +1,11 @@ +registry=https://pkgs.dev.azure.com/azfunc/public/_packaging/upstream-public/npm/registry/ +@azure:registry=https://pkgs.dev.azure.com/azfunc/public/_packaging/upstream-public/npm/registry/ +@azure-rest:registry=https://pkgs.dev.azure.com/azfunc/public/_packaging/upstream-public/npm/registry/ +@colors:registry=https://pkgs.dev.azure.com/azfunc/public/_packaging/upstream-public/npm/registry/ +@dabh:registry=https://pkgs.dev.azure.com/azfunc/public/_packaging/upstream-public/npm/registry/ +@js-joda:registry=https://pkgs.dev.azure.com/azfunc/public/_packaging/upstream-public/npm/registry/ +@microsoft:registry=https://pkgs.dev.azure.com/azfunc/public/_packaging/upstream-public/npm/registry/ +@opentelemetry:registry=https://pkgs.dev.azure.com/azfunc/public/_packaging/upstream-public/npm/registry/ +@so-ric:registry=https://pkgs.dev.azure.com/azfunc/public/_packaging/upstream-public/npm/registry/ +@types:registry=https://pkgs.dev.azure.com/azfunc/public/_packaging/upstream-public/npm/registry/ +@typespec:registry=https://pkgs.dev.azure.com/azfunc/public/_packaging/upstream-public/npm/registry/ diff --git a/NuGet.config b/NuGet.config new file mode 100644 index 0000000..80f24c7 --- /dev/null +++ b/NuGet.config @@ -0,0 +1,13 @@ + + + + + + + + + + + + diff --git a/build.ps1 b/build.ps1 index a7f200e..6f098bd 100644 --- a/build.ps1 +++ b/build.ps1 @@ -68,6 +68,13 @@ $FUNC_RUNTIME_VERSION = 'latest' Write-Host "Installing Core Tools globlally using npm, version: $FUNC_RUNTIME_VERSION ..." $FUNC_CLI_DIRECTORY = Join-Path $currDir 'Azure.Functions.Cli' +$repoNpmConfig = Join-Path $PSScriptRoot '.npmrc' +if ([string]::IsNullOrWhiteSpace($Env:NPM_CONFIG_USERCONFIG)) { + $Env:NPM_CONFIG_USERCONFIG = $repoNpmConfig +} +if (-not (Test-Path -LiteralPath $Env:NPM_CONFIG_USERCONFIG -PathType Leaf)) { + throw "NPM_CONFIG_USERCONFIG does not point to a file: $Env:NPM_CONFIG_USERCONFIG" +} # 1. Clean previous install Remove-Item -Recurse -Force $FUNC_CLI_DIRECTORY -ErrorAction Ignore @@ -78,7 +85,18 @@ $globalNode = (npm root -g | Out-String).Trim() # e.g. /usr/local/li $moduleRoot = Join-Path $globalNode 'azure-functions-core-tools' # 3. npm install → temp folder -npm install -g azure-functions-core-tools@$FUNC_RUNTIME_VERSION --unsafe-perm true --foreground-scripts --loglevel verbose +$npmInstallArguments = @( + 'install' + '--global' + "azure-functions-core-tools@$FUNC_RUNTIME_VERSION" + '--unsafe-perm' + 'true' + '--foreground-scripts' + '--loglevel' + 'verbose' +) +& npm @npmInstallArguments +StopOnFailedExecution # 4. Copy CLI payload into the layout required tests Copy-Item "$moduleRoot\bin\*" $FUNC_CLI_DIRECTORY -Recurse -Force diff --git a/eng/ci/templates/jobs/build.yml b/eng/ci/templates/jobs/build.yml index 865841f..8ec1b2d 100644 --- a/eng/ci/templates/jobs/build.yml +++ b/eng/ci/templates/jobs/build.yml @@ -8,9 +8,17 @@ jobs: os: windows steps: + - task: npmAuthenticate@0 + displayName: 'Authenticate npm to CFS' + inputs: + workingFile: .npmrc + - pwsh: | Write-Host "Java_HOME: $JAVA_HOME" Get-Command mvn displayName: 'Check Maven is installed' + - pwsh: '& .\build.ps1' - displayName: 'Build project with java library' \ No newline at end of file + displayName: 'Build project with java library' + env: + NPM_CONFIG_USERCONFIG: $(Build.SourcesDirectory)/.npmrc diff --git a/eng/ci/templates/official/jobs/build-and-test.yml b/eng/ci/templates/official/jobs/build-and-test.yml index e304eec..294e8f4 100644 --- a/eng/ci/templates/official/jobs/build-and-test.yml +++ b/eng/ci/templates/official/jobs/build-and-test.yml @@ -16,10 +16,13 @@ jobs: ApplicationInsightAgentVersion: 3.5.2 steps: - - task: NuGetToolInstaller@1 + - task: npmAuthenticate@0 + displayName: 'Authenticate npm to CFS' inputs: - checkLatest: true - displayName: 'Install NuGet Tool' + workingFile: .npmrc + + - task: NuGetAuthenticate@1 + displayName: 'Authenticate NuGet to CFS' - pwsh: | Write-Host "Java_HOME: $env:JAVA_HOME" @@ -30,9 +33,11 @@ jobs: displayName: 'Install .NET 6' inputs: version: 6.0.x - + - pwsh: '& .\build.ps1' displayName: 'Build project with java library' + env: + NPM_CONFIG_USERCONFIG: $(Build.SourcesDirectory)/.npmrc - pwsh: | $currDir = Get-Location @@ -45,12 +50,25 @@ jobs: displayName: 'Package Java for E2E' condition: eq(${{ parameters.runEndToEndTests }}, true) + - task: DotNetCoreCLI@2 + retryCountOnTaskFailure: 3 + inputs: + command: 'restore' + projects: | + azure-functions-java-worker/emulatedtests/Azure.Functions.Java.Tests.E2E/Azure.Functions.Java.Tests.E2E/Azure.Functions.Java.Tests.E2E.csproj + feedsToUse: 'config' + nugetConfigPath: 'NuGet.config' + displayName: 'Restore E2E tests from CFS' + condition: eq(${{ parameters.runEndToEndTests }}, true) + - bash: | npm install -g azurite mkdir azurite azurite --silent --location azurite --debug azurite\debug.log & displayName: 'Install and Run Azurite' condition: eq(${{ parameters.runEndToEndTests }}, true) + env: + NPM_CONFIG_USERCONFIG: $(Build.SourcesDirectory)/.npmrc - task: DotNetCoreCLI@2 retryCountOnTaskFailure: 3 @@ -58,6 +76,7 @@ jobs: command: 'test' projects: | azure-functions-java-worker/emulatedtests/Azure.Functions.Java.Tests.E2E/Azure.Functions.Java.Tests.E2E/Azure.Functions.Java.Tests.E2E.csproj + arguments: '--no-restore' env: AzureWebJobsStorage: "UseDevelopmentStorage=true" JAVA_HOME: $(JAVA_HOME_8_X64)