Skip to content

Commit

Permalink
Run tests on .NET 9, #1019 (#1052)
Browse files Browse the repository at this point in the history
* Run tests on .NET 9; add polyfill for Stream.ReadExactly, #1019

* Add net9.0 to Tests.Analysis.OpenNLP

* Regenerate github test workflows

* Fix assertion issue with .NET 9 x64 returning different results for long conversion overflow, #1019

* Add net9.0 to Tests.Cli

* Regenerate github workflow for cli

* Include net9.0 in x86 install hack; add LUCENENET comments to ReadExactly use

* Regenerate github workflow for CodeAnalysis

* Add .NET 8 SDK conditionally for ADO build

* Fix typos in publish-test-binaries.yml

* Only target net9.0 for Tests.CodeAnalysis

* Remove ReadExactly usage

* Use windows-latest in ADO pipeline

* Update CodeAnalysis GitHub workflow

* Remove case to install .NET 9 x86 SDK on .NET 8 x86 test run
  • Loading branch information
paulirwin authored Dec 12, 2024
1 parent d597a5f commit 9c88340
Show file tree
Hide file tree
Showing 53 changed files with 419 additions and 101 deletions.
12 changes: 6 additions & 6 deletions .build/azure-templates/publish-test-binaries.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 @@ -19,28 +19,28 @@
# to the binary publish subdirectory for the provided target
# framework, and then publishes to an pipeline artifact.

# NOTE: Depends on environment varable $(RunTests)
# NOTE: Depends on environment variable $(RunTests)

parameters:
publishDirectory: '' # The path of the root publish staging directory where the binaries can be found $(PublishTempDirectory)
framework: '' # The target framework
binaryArtifactName: '' # The prefix of the binary artifact to publish $(BinaryArtifactName)
testSettingsFilePath: '$(Build.ArtifactStagingDirectory)/lucene.testsettings.json' #The name of the lucene test settings file
solution: '$(Build.SourcesDirectory)/Lucene.Net.sln'
configration: '$(BuildConfiguration)' # The build configuration
configuration: '$(BuildConfiguration)' # The build configuration
platform: '$(BuildPlatform)' # The build platform

steps:
- pwsh: |
$solution = "${{ parameters.solution }}"
$configuration = "${{ parameters.configration }}"
$configuration = "${{ parameters.configuration }}"
$framework = "${{ parameters.framework }}"
$publishDirectory = "${{ parameters.publishDirectory }}"
Write-Host "solution: $solution"
Write-Host "configuration: $configuration"
Write-Host "framework: $framework"
Write-Host "publishDirectory: $publishDirectory"
&dotnet publish "${{ parameters.solution }}" --configuration "${{ parameters.configration }}" --framework: "${{ parameters.framework }}" --no-build --no-restore --verbosity normal /p:TestFrameworks=true /p:Platform="${{ parameters.platform }}" /p:AlternatePublishRootDirectory="${{ parameters.publishDirectory }}"
&dotnet publish "${{ parameters.solution }}" --configuration "${{ parameters.configuration }}" --framework: "${{ parameters.framework }}" --no-build --no-restore --verbosity normal /p:TestFrameworks=true /p:Platform="${{ parameters.platform }}" /p:AlternatePublishRootDirectory="${{ parameters.publishDirectory }}"
displayName: 'Publish Projects for ${{ parameters.framework }}'
condition: and(succeeded(), ne(variables['RunTests'], 'false'))

Expand Down
30 changes: 28 additions & 2 deletions .build/azure-templates/run-tests-on-os.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ steps:
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
# 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.
Expand All @@ -105,8 +105,34 @@ steps:
& $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 }}', 'net9.'), eq('${{ parameters.vsTestPlatform }}', 'x86'))

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

# 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 = '8.0.404'
$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 8.0.404 (x86)'
condition: and(succeeded(), contains('${{ parameters.framework }}', 'net8.'), eq('${{ parameters.vsTestPlatform }}', 'x86'))


- task: UseDotNet@2
displayName: 'Use .NET SDK 6.0.421'
inputs:
Expand All @@ -115,7 +141,7 @@ steps:
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
# 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.
Expand Down
2 changes: 1 addition & 1 deletion .build/runbuild.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ properties {
[string]$testResultsDirectory = "$artifactsDirectory/TestResults"
[string]$publishDirectory = "$artifactsDirectory/Publish"
[string]$solutionFile = "$baseDirectory/Lucene.Net.sln"
[string]$minimumSdkVersion = "8.0.100"
[string]$minimumSdkVersion = "9.0.100"
[string]$globalJsonFile = "$baseDirectory/global.json"
[string]$versionPropsFile = "$baseDirectory/version.props"
[string]$luceneReadmeFile = "$baseDirectory/src/Lucene.Net/readme-nuget.md"
Expand Down
16 changes: 14 additions & 2 deletions .github/workflows/Generate-TestWorkflows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
.PARAMETER TestFrameworks
A string array of Dotnet target framework monikers to run the tests on. The default is
@('net8.0','net6.0','net472','net48').
@('net9.0','net8.0','net6.0','net472','net48').
.PARAMETER OperatingSystems
A string array of Github Actions operating system monikers to run the tests on.
Expand All @@ -51,6 +51,10 @@
.PARAMETER Configurations
A string array of build configurations to run the tests on. The default is @('Release').
.PARAMETER DotNet9SDKVersion
The SDK version of .NET 9.x to install on the build agent to be used for building and
testing. This SDK is always installed on the build agent. The default is 9.0.x.
.PARAMETER DotNet8SDKVersion
The SDK version of .NET 8.x to install on the build agent to be used for building and
testing. This SDK is always installed on the build agent. The default is 8.0.x.
Expand All @@ -64,14 +68,16 @@ param(

[string]$RepoRoot = (Split-Path (Split-Path $PSScriptRoot)),

[string[]]$TestFrameworks = @('net8.0','net6.0','net472','net48'), # targets under test: net8.0, netstandard2.1, netstandard2.0, net462
[string[]]$TestFrameworks = @('net9.0','net8.0','net6.0','net472','net48'), # targets under test: net8.0, net8.0, netstandard2.1, netstandard2.0, net462

[string[]]$OperatingSystems = @('windows-latest', 'ubuntu-latest'),

[string[]]$TestPlatforms = @('x64'),

[string[]]$Configurations = @('Release'),

[string]$DotNet9SDKVersion = '9.0.x',

[string]$DotNet8SDKVersion = '8.0.x',

[string]$DotNet6SDKVersion = '6.0.x'
Expand Down Expand Up @@ -154,6 +160,7 @@ function Write-TestWorkflow(
[string[]]$TestFrameworks = @('net6.0', 'net48'),
[string[]]$TestPlatforms = @('x64'),
[string[]]$OperatingSystems = @('windows-latest', 'ubuntu-latest', 'macos-latest'),
[string]$DotNet9SDKVersion = $DotNet9SDKVersion,
[string]$DotNet8SDKVersion = $DotNet8SDKVersion,
[string]$DotNet6SDKVersion = $DotNet6SDKVersion) {

Expand Down Expand Up @@ -286,6 +293,11 @@ jobs:
with:
dotnet-version: '$DotNet8SDKVersion'
- name: Setup .NET 9 SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: '$DotNet9SDKVersion'
- name: Setup Environment Variables
run: |
`$project_name = [System.IO.Path]::GetFileNameWithoutExtension(`$env:project_path)
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/Lucene-Net-Tests-AllProjects.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest]
framework: [net8.0, net6.0, net48, net472]
framework: [net9.0, net8.0, net6.0, net48, net472]
platform: [x64]
configuration: [Release]
exclude:
Expand Down Expand Up @@ -111,6 +111,11 @@ jobs:
with:
dotnet-version: '8.0.x'

- name: Setup .NET 9 SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: '9.0.x'

- name: Setup Environment Variables
run: |
$project_name = [System.IO.Path]::GetFileNameWithoutExtension($env:project_path)
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/Lucene-Net-Tests-Analysis-Common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest]
framework: [net8.0, net6.0, net48, net472]
framework: [net9.0, net8.0, net6.0, net48, net472]
platform: [x64]
configuration: [Release]
exclude:
Expand Down Expand Up @@ -95,6 +95,11 @@ jobs:
with:
dotnet-version: '8.0.x'

- name: Setup .NET 9 SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: '9.0.x'

- name: Setup Environment Variables
run: |
$project_name = [System.IO.Path]::GetFileNameWithoutExtension($env:project_path)
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/Lucene-Net-Tests-Analysis-Kuromoji.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest]
framework: [net8.0, net6.0, net48, net472]
framework: [net9.0, net8.0, net6.0, net48, net472]
platform: [x64]
configuration: [Release]
exclude:
Expand Down Expand Up @@ -92,6 +92,11 @@ jobs:
with:
dotnet-version: '8.0.x'

- name: Setup .NET 9 SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: '9.0.x'

- name: Setup Environment Variables
run: |
$project_name = [System.IO.Path]::GetFileNameWithoutExtension($env:project_path)
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/Lucene-Net-Tests-Analysis-Morfologik.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest]
framework: [net8.0, net6.0, net48, net472]
framework: [net9.0, net8.0, net6.0, net48, net472]
platform: [x64]
configuration: [Release]
exclude:
Expand Down Expand Up @@ -92,6 +92,11 @@ jobs:
with:
dotnet-version: '8.0.x'

- name: Setup .NET 9 SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: '9.0.x'

- name: Setup Environment Variables
run: |
$project_name = [System.IO.Path]::GetFileNameWithoutExtension($env:project_path)
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/Lucene-Net-Tests-Analysis-OpenNLP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest]
framework: [net8.0, net48]
framework: [net9.0, net8.0, net48]
platform: [x64]
configuration: [Release]
exclude:
Expand Down Expand Up @@ -95,6 +95,11 @@ jobs:
with:
dotnet-version: '8.0.x'

- name: Setup .NET 9 SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: '9.0.x'

- name: Setup Environment Variables
run: |
$project_name = [System.IO.Path]::GetFileNameWithoutExtension($env:project_path)
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/Lucene-Net-Tests-Analysis-Phonetic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest]
framework: [net8.0, net6.0, net48, net472]
framework: [net9.0, net8.0, net6.0, net48, net472]
platform: [x64]
configuration: [Release]
exclude:
Expand Down Expand Up @@ -89,6 +89,11 @@ jobs:
with:
dotnet-version: '8.0.x'

- name: Setup .NET 9 SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: '9.0.x'

- name: Setup Environment Variables
run: |
$project_name = [System.IO.Path]::GetFileNameWithoutExtension($env:project_path)
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/Lucene-Net-Tests-Analysis-SmartCn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest]
framework: [net8.0, net6.0, net48, net472]
framework: [net9.0, net8.0, net6.0, net48, net472]
platform: [x64]
configuration: [Release]
exclude:
Expand Down Expand Up @@ -93,6 +93,11 @@ jobs:
with:
dotnet-version: '8.0.x'

- name: Setup .NET 9 SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: '9.0.x'

- name: Setup Environment Variables
run: |
$project_name = [System.IO.Path]::GetFileNameWithoutExtension($env:project_path)
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/Lucene-Net-Tests-Analysis-Stempel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest]
framework: [net8.0, net6.0, net48, net472]
framework: [net9.0, net8.0, net6.0, net48, net472]
platform: [x64]
configuration: [Release]
exclude:
Expand Down Expand Up @@ -90,6 +90,11 @@ jobs:
with:
dotnet-version: '8.0.x'

- name: Setup .NET 9 SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: '9.0.x'

- name: Setup Environment Variables
run: |
$project_name = [System.IO.Path]::GetFileNameWithoutExtension($env:project_path)
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/Lucene-Net-Tests-Benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest]
framework: [net8.0, net6.0, net48, net472]
framework: [net9.0, net8.0, net6.0, net48, net472]
platform: [x64]
configuration: [Release]
exclude:
Expand Down Expand Up @@ -102,6 +102,11 @@ jobs:
with:
dotnet-version: '8.0.x'

- name: Setup .NET 9 SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: '9.0.x'

- name: Setup Environment Variables
run: |
$project_name = [System.IO.Path]::GetFileNameWithoutExtension($env:project_path)
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/Lucene-Net-Tests-Classification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest]
framework: [net8.0, net6.0, net48, net472]
framework: [net9.0, net8.0, net6.0, net48, net472]
platform: [x64]
configuration: [Release]
exclude:
Expand Down Expand Up @@ -90,6 +90,11 @@ jobs:
with:
dotnet-version: '8.0.x'

- name: Setup .NET 9 SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: '9.0.x'

- name: Setup Environment Variables
run: |
$project_name = [System.IO.Path]::GetFileNameWithoutExtension($env:project_path)
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/Lucene-Net-Tests-Cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest]
framework: [net8.0]
framework: [net9.0, net8.0]
platform: [x64]
configuration: [Release]
exclude:
Expand Down Expand Up @@ -110,6 +110,11 @@ jobs:
with:
dotnet-version: '8.0.x'

- name: Setup .NET 9 SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: '9.0.x'

- name: Setup Environment Variables
run: |
$project_name = [System.IO.Path]::GetFileNameWithoutExtension($env:project_path)
Expand Down
Loading

0 comments on commit 9c88340

Please sign in to comment.