Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix validateWorkersVersions.ps1 script #4245

Merged
merged 3 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions src/Azure.Functions.Cli/Azure.Functions.Cli.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk" InitialTargets="ExcludeWorkersFromReadyToRun">
<Project Sdk="Microsoft.NET.Sdk" InitialTargets="ExcludeWorkersFromReadyToRun">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net8.0</TargetFrameworks>
Expand Down Expand Up @@ -58,9 +58,9 @@
<EmbeddedResource Include="StaticResources\Dockerfile.dotnet8Isolated">
<LogicalName>$(AssemblyName).Dockerfile.dotnet8Isolated</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="StaticResources\Dockerfile.dotnet9Isolated">
<EmbeddedResource Include="StaticResources\Dockerfile.dotnet9Isolated">
<LogicalName>$(AssemblyName).Dockerfile.dotnet9Isolated</LogicalName>
</EmbeddedResource>
</EmbeddedResource>
<EmbeddedResource Include="StaticResources\ExtensionsProj.csproj.template">
<LogicalName>$(AssemblyName).ExtensionsProj.csproj</LogicalName>
</EmbeddedResource>
Expand Down Expand Up @@ -279,7 +279,7 @@
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.22.0" />
<PackageReference Include="Microsoft.AspNetCore.DataProtection" Version="2.2.0" />
<PackageReference Include="Microsoft.Azure.DurableTask.AzureStorage.Internal" Version="1.4.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Script.WebHost" Version="4.1036.1" />
<PackageReference Include="Microsoft.Azure.WebJobs.Script.WebHost" Version="4.1037.0" />
<PackageReference Include="Microsoft.Build" Version="17.0.0" />
<PackageReference Include="Microsoft.Identity.Client" Version="4.61.3" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
Expand All @@ -288,17 +288,16 @@
<PackageReference Include="System.Text.Json" Version="8.0.5" />
<PackageReference Include="WindowsAzure.Storage" Version="9.3.1" />
<PackageReference Include="YamlDotNet" Version="6.0.0" />

<!-- Transitive dependency -->
<PackageReference Include="System.Text.Json" Version="8.0.5" />
</ItemGroup>
<ItemGroup Condition="'$(NoWorkers)' != 'true'">
<PackageReference Include="Microsoft.Azure.Functions.JavaWorker" Version="2.16.0" />
<PackageReference Include="Microsoft.Azure.Functions.NodeJsWorker" Version="3.10.0" />
<PackageReference Include="Microsoft.Azure.Functions.JavaWorker" Version="2.17.0" />
<PackageReference Include="Microsoft.Azure.Functions.NodeJsWorker" Version="3.10.1" />
<PackageReference Include="Microsoft.Azure.Functions.PowerShellWorker.PS7.0" Version="4.0.3148" />
<PackageReference Include="Microsoft.Azure.Functions.PowerShellWorker.PS7.2" Version="4.0.4020" />
<PackageReference Include="Microsoft.Azure.Functions.PowerShellWorker.PS7.4" Version="4.0.4021" />
<PackageReference Include="Microsoft.Azure.Functions.PythonWorker" Version="4.31.0" />
<PackageReference Include="Microsoft.Azure.Functions.PowerShellWorker.PS7.2" Version="4.0.4025" />
<PackageReference Include="Microsoft.Azure.Functions.PowerShellWorker.PS7.4" Version="4.0.4026" />
<PackageReference Include="Microsoft.Azure.Functions.PythonWorker" Version="4.34.0" />
</ItemGroup>
<Target Name="ExcludeWorkersFromReadyToRun">
<CreateItem Include="%(None.Filename)%(None.Extension)" Condition="$([System.String]::new('%(None.TargetPath)').StartsWith('workers'))" PreserveExistingMetadata="false">
Expand Down
2 changes: 1 addition & 1 deletion test/Azure.Functions.Cli.Tests/E2E/InitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public Task init_with_worker_runtime(string workerRuntime)

return CliTester.Run(new RunConfiguration
{
Commands = new[] { $"init . --worker-runtime {workerRuntime}" },
Commands = new[] { $"init . --worker-runtime {workerRuntime} --skip-npm-install" },
CheckFiles = files.ToArray(),
OutputContains = new[]
{
Expand Down
45 changes: 27 additions & 18 deletions validateWorkerVersions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -57,31 +57,40 @@ if (-Not $hostVersion) {
setCliPackageVersion $hostPackageName $hostVersion
}

function getHostFileContent([string]$filePath) {
function getWorkerPropsFile([string]$filePath) {
$uri = "https://raw.githubusercontent.com/Azure/azure-functions-host/v$hostVersion/$filePath"
return removeBomIfExists((Invoke-WebRequest -Uri $uri -MaximumRetryCount 5 -RetryIntervalSec 2).Content)
return removeBomIfExists((Invoke-WebRequest -Uri $uri).Content)
}
$hostCsprojContent = getHostFileContent "src/WebJobs.Script/WebJobs.Script.csproj"
$pythonPropsContent = getHostFileContent "build/python.props"

$workers = "JavaWorker", "NodeJsWorker", "PowerShellWorker.PS7.0", "PowerShellWorker.PS7.2", "PowerShellWorker.PS7.4", "PythonWorker"
$workerPropstoWorkerName = @{}
$workerPropsToWorkerName["eng/build/Workers.Node.props"] = @("NodeJsWorker")
$workerPropsToWorkerName["eng/build/Workers.Java.props"] = @("JavaWorker")
$workerPropsToWorkerName["eng/build/Workers.Python.props"] = @("PythonWorker")
$workerPropsToWorkerName["eng/build/Workers.Powershell.props"] = @("PowerShellWorker.PS7.0", "PowerShellWorker.PS7.2", "PowerShellWorker.PS7.4")

$failedValidation = $false
foreach($worker in $workers) {
$packageName = "Microsoft.Azure.Functions.$worker"
if ($worker -eq "PythonWorker") {
$hostWorkerVersion = getPackageVersion $packageName $pythonPropsContent
} else {
$hostWorkerVersion = getPackageVersion $packageName $hostCsprojContent
}
$cliWorkerVersion = getPackageVersion $packageName $cliCsprojContent

if ($Update) {
setCliPackageVersion $packageName $hostWorkerVersion
} elseif ($hostWorkerVersion -ne $cliWorkerVersion) {
Write-Output "Reference to $worker in the host ($hostWorkerVersion) does not match version in the cli ($cliWorkerVersion)"
$failedValidation = $true

# Iterate through each key-value pair
foreach ($key in $workerPropsToWorkerName.Keys) {
$workerPropsContent = getWorkerPropsFile $key
# Get the list associated with the key
$workerList = $workerPropsToWorkerName[$key]

# Iterate through the list
foreach ($worker in $workerList) {
$packageName = "Microsoft.Azure.Functions.$worker"
$hostWorkerVersion = getPackageVersion $packageName $workerPropsContent
$cliWorkerVersion = getPackageVersion $packageName $workerPropsContent

if ($Update) {
setCliPackageVersion $packageName $hostWorkerVersion
} elseif ($hostWorkerVersion -ne $cliWorkerVersion) {
Write-Output "Reference to $worker in the host ($hostWorkerVersion) does not match version in the cli ($cliWorkerVersion)"
$failedValidation = $true
}
}

}

if ($Update) {
Expand Down