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

Upgrade tests and CLI to .NET 8, fix benchmark formatting issue #930

Merged
merged 24 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
743aea0
Upgrade tests and CLI to .NET 8, fix benchmark formatting issue
paulirwin Mar 13, 2024
813ecd0
Upgrade GitHub actions tests to net8.0
paulirwin Mar 13, 2024
f511c09
Update ADO build scripts/files for net8 test run
paulirwin Mar 13, 2024
a01c0f4
Remove net7.0 comment from TestTargetFramework.props
paulirwin Mar 13, 2024
0d2c711
Only disable EOL SDK warning on net5.0; sort features
paulirwin Mar 13, 2024
72a7ab0
Add notes about .NET roll-forward strategy to cli docs
paulirwin Mar 28, 2024
51eb651
Move net5.0 warning suppression to combined group
paulirwin Mar 28, 2024
1222bd1
Remove duplicate .NET 8 SDK install
paulirwin Mar 29, 2024
358fc12
Regenerate GitHub build scripts
paulirwin Mar 30, 2024
0e9a400
Lower .NET 8 min SDK version to 8.0.101 for testing purposes
paulirwin Apr 27, 2024
6be0440
Remove git hash from informational version
paulirwin Apr 27, 2024
36db76a
Directory.Build.props: Moved IncludeSourceRevisionInInformationalVers…
NightOwl888 Apr 30, 2024
8a89fdd
publish-test-results.yml: Added additional error messages to fail the…
NightOwl888 Apr 30, 2024
10bfe12
azure-pipelines.yml: Changed DotNetSDKVersion to 8.0.204 (8.0.202 isn…
NightOwl888 Apr 30, 2024
c46c883
install-dotnet-sdk.yml: Added parameter validation and displayName fo…
NightOwl888 Apr 30, 2024
dd16dce
.build/dependencies.props: Upgraded Microsoft.NET.Test.Sdk from 16.6.…
NightOwl888 Apr 30, 2024
dfe4f0e
run-tests-on-os.yml: Added special cases for installing x86 SDKs, sin…
NightOwl888 Apr 30, 2024
170c60d
.github/workflows/Generate-TestWorkflows.ps1: Use the latest version …
NightOwl888 Apr 30, 2024
a1b3c5d
SWEEP: Upgraded .NET Standard 2.0 test target from net461 to net472. …
NightOwl888 Apr 30, 2024
59b7966
.build/runbuild.ps1: Changed minimum supported version to 8.0.100. We…
NightOwl888 Apr 30, 2024
64e0e80
README.md: Updated prerequisites for build instructions
NightOwl888 Apr 30, 2024
e6a18c5
Deleted backup files that were accidentally committed
NightOwl888 Apr 30, 2024
54cae62
run-tests-on-os.yml: Removed unused $framework variable
NightOwl888 Apr 30, 2024
8d553ed
.github/workflows/Generate-TestWorkflows.ps1: Updated documentation f…
NightOwl888 Apr 30, 2024
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
4 changes: 3 additions & 1 deletion .build/azure-templates/install-dotnet-sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,17 @@ steps:
}
}
EnsureNotNullOrEmpty('${{ parameters.sdkVersion }}', 'sdkVersion')
EnsureNotNullOrEmpty('${{ parameters.performMultiLevelLookup }}', 'performMultiLevelLookup')
displayName: 'Validate Template Parameters'

- bash: |
echo "##vso[task.setvariable variable=DOTNET_NOLOGO;]1"
echo "##vso[task.setvariable variable=DOTNET_CLI_TELEMETRY_OPTOUT;]1"
displayName: Disable Telemetry

- task: UseDotNet@2
displayName: 'Use .NET SDK ${{ parameters.sdkVersion }}'
inputs:
packageType: 'sdk'
version: '${{ parameters.sdkVersion }}'
performMultiLevelLookup: '${{ parameters.performMultiLevelLookup }}'
performMultiLevelLookup: '${{ parameters.performMultiLevelLookup }}'
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing,-with-title
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
Expand Down Expand Up @@ -81,11 +81,11 @@ steps:
testResultsArtifactName: '${{ parameters.testResultsArtifactName }}'
testResultsFileName: '${{ parameters.testResultsFileName }}'

# Special case: Only supports net7.0 and net6.0
# Special case: Only supports net8.0 and net6.0
- template: publish-test-results.yml
parameters:
testProjectName: 'Lucene.Net.Tests.Cli'
framework: 'net7.0' # Since condtions are not supported for templates, we check for the file existence within publish-test-results.yml
framework: 'net8.0' # Since condtions are not supported for templates, we check for the file existence within publish-test-results.yml
vsTestPlatform: '${{ parameters.vsTestPlatform }}'
osName: '${{ parameters.osName }}'
testResultsFormat: '${{ parameters.testResultsFormat }}'
Expand All @@ -102,12 +102,12 @@ steps:
testResultsArtifactName: '${{ parameters.testResultsArtifactName }}'
testResultsFileName: '${{ parameters.testResultsFileName }}'

# Special case: Only supports net7.0, net6.0 and net48
# Special case: Only supports net8.0, net6.0 and net48

- template: publish-test-results.yml
parameters:
testProjectName: 'Lucene.Net.Tests.Analysis.OpenNLP'
framework: 'net7.0' # Since condtions are not supported for templates, we check for the file existence within publish-test-results.yml
framework: 'net8.0' # Since condtions are not supported for templates, we check for the file existence within publish-test-results.yml
vsTestPlatform: '${{ parameters.vsTestPlatform }}'
osName: '${{ parameters.osName }}'
testResultsFormat: '${{ parameters.testResultsFormat }}'
Expand Down
8 changes: 6 additions & 2 deletions .build/azure-templates/publish-test-results.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ steps:
if ($inRunInfos -and !$crashed -and $reader.Name -eq 'Text') {
$innerXml = $reader.ReadInnerXml()
# Test for specific error messages - we may need to adjust this, as needed
if ($innerXml -and ($innerXml.Contains('Test host process crashed') -or $innerXml.Contains('Could not load file or assembly'))) {
if ($innerXml -and ($innerXml.Contains('Test host process crashed') `
-or $innerXml.Contains('Could not load file or assembly') `
-or $innerXml.Contains("Could not find `'dotnet.exe`' host") `
-or $innerXml.Contains('No test is available') `
-or $innerXml.Contains('exited with error'))) {
Write-Host "##vso[task.setvariable variable=HostCrashed;]true"
# Report all of the test projects that crashed
$crashedRuns = "$env:CRASHEDRUNS,$testProjectName".TrimStart(',')
Expand Down Expand Up @@ -104,4 +108,4 @@ steps:
testResultsFormat: ${{ parameters.testResultsFormat }}
testResultsFiles: '$(Build.ArtifactStagingDirectory)/${{ parameters.testResultsArtifactName }}/${{ parameters.osName }}/${{ parameters.framework }}/${{ parameters.vsTestPlatform }}/${{ parameters.testProjectName }}/${{ parameters.testResultsFileName }}'
testRunTitle: '${{ parameters.testProjectName }} - ${{ parameters.framework }} - ${{ parameters.vsTestPlatform }} - ${{ parameters.osName }} | $(TestResults)'
condition: and(succeeded(), eq(variables['TestResultsFileExists'], 'true'))
condition: and(succeeded(), eq(variables['TestResultsFileExists'], 'true'))
105 changes: 75 additions & 30 deletions .build/azure-templates/run-tests-on-os.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
Expand All @@ -34,7 +34,7 @@ parameters:
maximumAllowedFailures: 0
where: '' # A test filter expression, as defined by dotnet test
dotNetSdkVersion: '' # The .NET SDK version to install

steps:
- checkout: none # self represents the repo where the initial Pipelines YAML file was found

Expand Down Expand Up @@ -83,34 +83,79 @@ steps:
$performMulitLevelLookup = if ($IsWindows -and $testPlatform.Equals('x86')) { 'true' } else { 'false' }
Write-Host "##vso[task.setvariable variable=PerformMultiLevelLookup;]$performMulitLevelLookup"

#- template: 'show-all-environment-variables.yml' # Uncomment for debugging

- template: 'install-dotnet-sdk.yml'
parameters:
sdkVersion: '${{ parameters.dotNetSdkVersion }}'
performMultiLevelLookup: '${{ variables.PerformMultiLevelLookup }}'

# Hack: .NET 8 no longer installs the x86 bits and they must be installed separately. However, it is not
# trivial to get it into the path and to get it to pass the minimum SDK version check in runbuild.ps1.
# So, we install it afterward and set the environment variable so the above SDK can delegate to it.
# This code only works on Windows.
- pwsh: |
$sdkVersion = '${{ parameters.dotNetSdkVersion }}'
$architecture = '${{ parameters.vsTestPlatform }}'
$installScriptPath = "${env:AGENT_TEMPDIRECTORY}/dotnet-install.ps1"
$installScriptUrl = "https://raw.githubusercontent.com/dotnet/install-scripts/main/src/dotnet-install.ps1"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Invoke-WebRequest $installScriptUrl -OutFile $installScriptPath -TimeoutSec 60
$installPath = "${env:ProgramFiles(x86)}/dotnet"
& $installScriptPath -Version $sdkVersion -Architecture $architecture -InstallDir $installPath
Write-Host "##vso[task.setvariable variable=DOTNET_ROOT_X86;]$installPath"
displayName: 'Use .NET SDK ${{ parameters.dotNetSdkVersion }} (x86)'
condition: and(succeeded(), contains('${{ parameters.framework }}', 'net8.'), eq('${{ parameters.vsTestPlatform }}', 'x86'))

- task: UseDotNet@2
displayName: 'Use .NET Core sdk 3.1.412'
displayName: 'Use .NET SDK 6.0.421'
inputs:
packageType: 'sdk'
version: '3.1.412'
version: '6.0.421'
performMultiLevelLookup: '${{ variables.PerformMultiLevelLookup }}'
condition: and(succeeded(), contains('${{ parameters.framework }}', 'netcoreapp3.'))
condition: and(succeeded(), contains('${{ parameters.framework }}', 'net6.'))

# Hack: .NET 8 no longer installs the x86 bits and they must be installed separately. However, it is not
# trivial to get it into the path and to get it to pass the minimum SDK version check in runbuild.ps1.
# So, we install it afterward and set the environment variable so the above SDK can delegate to it.
# This code only works on Windows.
- pwsh: |
$sdkVersion = '6.0.421'
$architecture = '${{ parameters.vsTestPlatform }}'
$installScriptPath = "${env:AGENT_TEMPDIRECTORY}/dotnet-install.ps1"
$installScriptUrl = "https://raw.githubusercontent.com/dotnet/install-scripts/main/src/dotnet-install.ps1"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Invoke-WebRequest $installScriptUrl -OutFile $installScriptPath -TimeoutSec 60
$installPath = "${env:ProgramFiles(x86)}/dotnet"
& $installScriptPath -Version $sdkVersion -Architecture $architecture -InstallDir $installPath
Write-Host "##vso[task.setvariable variable=DOTNET_ROOT_X86;]$installPath"
displayName: 'Use .NET SDK 6.0.421 (x86)'
condition: and(succeeded(), contains('${{ parameters.framework }}', 'net6.'), eq('${{ parameters.vsTestPlatform }}', 'x86'))

- task: UseDotNet@2
NightOwl888 marked this conversation as resolved.
Show resolved Hide resolved
displayName: 'Use .NET sdk 5.0.400'
displayName: 'Use .NET SDK 5.0.408'
inputs:
packageType: 'sdk'
version: '5.0.400'
version: '5.0.408'
performMultiLevelLookup: '${{ variables.PerformMultiLevelLookup }}'
condition: and(succeeded(), contains('${{ parameters.framework }}', 'net5.'))

- task: UseDotNet@2
displayName: 'Use .NET sdk 6.0.403'
inputs:
packageType: 'sdk'
version: '5.0.403'
performMultiLevelLookup: '${{ variables.PerformMultiLevelLookup }}'
condition: and(succeeded(), contains('${{ parameters.framework }}', 'net6.'))
# Hack: .NET 8 no longer installs the x86 bits and they must be installed separately. However, it is not
# trivial to get it into the path and to get it to pass the minimum SDK version check in runbuild.ps1.
# So, we install it afterward and set the environment variable so the above SDK can delegate to it.
# This code only works on Windows.
- pwsh: |
$sdkVersion = '5.0.408'
$architecture = '${{ parameters.vsTestPlatform }}'
$installScriptPath = "${env:AGENT_TEMPDIRECTORY}/dotnet-install.ps1"
$installScriptUrl = "https://raw.githubusercontent.com/dotnet/install-scripts/main/src/dotnet-install.ps1"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Invoke-WebRequest $installScriptUrl -OutFile $installScriptPath -TimeoutSec 60
$installPath = "${env:ProgramFiles(x86)}/dotnet"
& $installScriptPath -Version $sdkVersion -Architecture $architecture -InstallDir $installPath
Write-Host "##vso[task.setvariable variable=DOTNET_ROOT_X86;]$installPath"
displayName: 'Use .NET SDK 5.0.408 (x86)'
condition: and(succeeded(), contains('${{ parameters.framework }}', 'net5.'), eq('${{ parameters.vsTestPlatform }}', 'x86'))

#- template: 'show-all-files.yml' # Uncomment for debugging
- pwsh: |
Expand All @@ -126,7 +171,7 @@ steps:
$tempDirectory = "$(Agent.TempDirectory)"
$isNightly = if ($env:ISNIGHTLY -eq 'true') { 'true' } else { 'false' }
$isWeekly = if ($env:ISWEEKLY -eq 'true') { 'true' } else { 'false' }

function IsSupportedFramework([string]$framework) {
if ($IsWindows -eq $null) {
$IsWindows = $env:OS.StartsWith('Win')
Expand All @@ -136,15 +181,15 @@ steps:
}
return $true
}

function RunTests([string]$framework, [string]$fileRegexPattern) {
if (!(IsSupportedFramework($framework))) { continue }

$testBinaries = Get-ChildItem -Path "$testBinaryRootDirectory" -File -Recurse | Where-Object {$_.FullName -match "$framework" -and $_.FullName -match "$fileRegexPattern" -and !$_.Name.EndsWith('.resources.dll') } | Sort-Object -Property FullName
Write-Host $testBinaries
foreach ($testBinary in $testBinaries) {
$testName = [System.IO.Path]::GetFileNameWithoutExtension($testBinary.FullName)

if ($maximumParalellJobs -gt 1) {
# Pause if we have queued too many parallel jobs
$running = @(Get-Job | Where-Object { $_.State -eq 'Running' })
Expand All @@ -155,7 +200,7 @@ steps:
$running | Wait-Job -Any | Out-Null
}
}

$testResultDirectory = "$testResultsArtifactDirectory/$testOSName/$framework/$testPlatform/$testName"
if (!(Test-Path "$testResultDirectory")) {
New-Item "$testResultDirectory" -ItemType Directory -Force
Expand Down Expand Up @@ -186,32 +231,32 @@ steps:
if (![string]::IsNullOrEmpty($where)) {
$testExpression = "$testExpression --filter ""$where"""
}

$testExpression = "$testExpression -- RunConfiguration.TargetPlatform=$testPlatform"

Write-Host "Testing '$($testBinary.FullName)' on framework '$framework' and outputting test results to '$testResultDirectory/$testResultsFileName'..."
Write-Host $testExpression -ForegroundColor Magenta
if ($maximumParalellJobs -le 1) {
Invoke-Expression $testExpression # For running in the foreground
} else {

$testExpression += " > ""$testResultDirectory/dotnet-test.log"" 2> ""$testResultDirectory/dotnet-test-error.log"""
$scriptBlock = {
param([string]$testExpression)
Invoke-Expression $testExpression
}

# Avoid dotnet test collisions by delaying for 500ms
Start-Sleep -Milliseconds 500

# Execute the jobs in parallel
Start-Job -Name "$testName,$framework,$testPlatform" -ScriptBlock $scriptBlock -ArgumentList $testExpression
}
}
}

RunTests -Framework "$framework" -FileRegexPattern "$testBinaryFilesPattern"

if ($maximumParalellJobs -gt 1) {
# Wait for it all to complete
do {
Expand All @@ -229,7 +274,7 @@ steps:
}
} until ($running.Count -eq 0)
}

$global:LASTEXITCODE = 0 # Force the script to continue on error
displayName: 'dotnet test ${{ parameters.framework }},${{ parameters.vsTestPlatform }}'
ignoreLASTEXITCODE: true
Expand All @@ -247,7 +292,7 @@ steps:
# it would be a ton of work to make a replacement for the
# Publish Test Results task or the (deprecated) TfsPublisher
# our only other option is to make a task for every supported
# platform and project and update it whenever a new platform
# platform and project and update it whenever a new platform
# is targeted or test project is created in Lucene.Net.

- template: 'publish-test-results-for-test-projects.yml'
Expand All @@ -270,4 +315,4 @@ steps:
}
if ($failed) {
Write-Host "##vso[task.complete result=Failed;]"
}
}
8 changes: 4 additions & 4 deletions .build/dependencies.props
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@
<MicrosoftExtensionsDependencyInjectionPackageVersion>$(MicrosoftExtensionsDependencyInjectionAbstractionsPackageVersion)</MicrosoftExtensionsDependencyInjectionPackageVersion>
<MicrosoftExtensionsOptionsPackageVersion>2.0.0</MicrosoftExtensionsOptionsPackageVersion>
<MicrosoftNETFrameworkReferenceAssembliesPackageReferenceVersion>1.0.2</MicrosoftNETFrameworkReferenceAssembliesPackageReferenceVersion>
<MicrosoftNETTestSdkPackageVersion>16.6.1</MicrosoftNETTestSdkPackageVersion>
<MicrosoftNETTestSdkPackageVersion>17.9.0</MicrosoftNETTestSdkPackageVersion>
<MicrosoftSourceLinkAzureReposGitPackageReferenceVersion>1.1.1</MicrosoftSourceLinkAzureReposGitPackageReferenceVersion>
<MicrosoftSourceLinkGitHubPackageReferenceVersion>$(MicrosoftSourceLinkAzureReposGitPackageReferenceVersion)</MicrosoftSourceLinkGitHubPackageReferenceVersion>
<MorfologikFsaPackageVersion>2.1.7</MorfologikFsaPackageVersion>
<MorfologikPolishPackageVersion>$(MorfologikFsaPackageVersion)</MorfologikPolishPackageVersion>
<MorfologikStemmingPackageVersion>$(MorfologikFsaPackageVersion)</MorfologikStemmingPackageVersion>
<NETStandardLibrary20PackageVersion>2.0.3</NETStandardLibrary20PackageVersion>
<NewtonsoftJsonPackageVersion>13.0.1</NewtonsoftJsonPackageVersion>
<NUnit3TestAdapterPackageVersion>3.17.0</NUnit3TestAdapterPackageVersion>
<NUnit3TestAdapterPackageVersion>4.5.0</NUnit3TestAdapterPackageVersion>
<NUnitPackageVersion>3.13.1</NUnitPackageVersion>
<RandomizedTestingGeneratorsPackageVersion>2.7.8</RandomizedTestingGeneratorsPackageVersion>
<SharpZipLibPackageVersion>1.4.2</SharpZipLibPackageVersion>
Expand All @@ -81,12 +81,12 @@
<SystemRuntimeInteropServicesRuntimeInformationPackageVersion>4.3.0</SystemRuntimeInteropServicesRuntimeInformationPackageVersion>
<SystemSecurityCryptographyXmlPackageVersion>6.0.1</SystemSecurityCryptographyXmlPackageVersion>
<SystemTextEncodingCodePagesPackageVersion>4.3.0</SystemTextEncodingCodePagesPackageVersion>
<SystemTextEncodingCodePagesPackageVersion Condition=" '$(TargetFramework)' == 'net461' ">5.0.0</SystemTextEncodingCodePagesPackageVersion>
<SystemTextEncodingCodePagesPackageVersion Condition=" '$(TargetFramework)' == 'net472' ">5.0.0</SystemTextEncodingCodePagesPackageVersion>
<SystemTextJsonPackageVersion>6.0.6</SystemTextJsonPackageVersion>
<TimeZoneConverterPackageVersion>6.1.0</TimeZoneConverterPackageVersion>
</PropertyGroup>
<PropertyGroup Label="Maven Package Reference Versions">
<OpenNLPToolsMavenReferenceVersion>1.9.1</OpenNLPToolsMavenReferenceVersion>
<OSGICoreMavenReferenceVersion>4.2.0</OSGICoreMavenReferenceVersion>
</PropertyGroup>
</Project>
</Project>
Loading
Loading