blob: c06d1a1b121eaebdfdb3b08ed4231263475f6bf4 [file] [log] [blame]
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# 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
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
name: 'vNext$(rev:.r)' # Format for build number (will be overridden)
# DevOps Setup: Define the following pipeline level variables in Azure DevOps build pipeline
# ArtifactFeedID: (Optional - set to your Azure DevOps Artifact (NuGet) feed. If not provided, publish job will be skipped.)
# BuildConfiguration: (Optional. Defaults to 'Release')
# BuildPlatform: (Optional. Defaults to 'Any CPU')
# GenerateDocs: (Optional. Only builds documentation website if set to 'true'.)
# GenerateWebsite: (Optional. Only builds lucene.net website if set to 'true'.)
# IsRelease: (Optional. By default the Release job is disabled, setting this to 'true' will enable it)
# Versioning Variables
# BuildCounterSeed: (Optional - Set in conjunction with VersionSuffix, will cause the build counter to begin at this value. Note that it is set once, to reset is an API call.)
# PackageVersion: (Optional - This can be used to explicitly set the whole version number to a specific version, i.e. 4.8.0-beta00005. It overrides all other version settings.)
# PreReleaseCounterPattern: (Optional. Set to '0000000000' in ci pipeline or '00000' in release pipeline. The default is '0000000000'. This setting has no effect if VersionSuffix is ''.)
# VersionSuffix: (Optional. Defaults to 'ci'. Set to 'beta' or 'rc' or '' in production pipeline.)
# Testing variables
# RunTests: 'true' (Optional - set to 'false' to disable test jobs - useful for debugging. If not provided, tests will be run.)
# IsNightly: 'false' (Optional - set to 'true' to run additional tests for the nightly build)
# IsWeekly: 'false' (Optional - set to 'true' to run additional tests for the weekly build)
# RunSlowTests: 'true' (Optional - set to 'false' to skip slow tests to make testing time shorter)
# RunAwaitsFixTests: 'false' (Optional - set to 'true' to run flakey tests)
# Codec: 'random' (Optional - set to a specific codec to test the same codec throughout all tests)
# DocValuesFormat: 'random' (Optional - set to a specific doc values format to test the same codec throughout all tests)
# PostingsFormat: 'random' (Optional - set to a specific postings format to test the same codec throughout all tests)
# Directory: 'random' (Optional - set to a specific directory implementation to test the same codec throughout all tests)
# Verbose: 'false' (Optional - set to true for verbose logging output)
# Multiplier: '1' (Optional - the number of iterations to multiply applicable tests by)
variables:
- name: BuildCounter
value: $[counter(variables['VersionSuffix'],coalesce(variables['BuildCounterSeed'], 1250))]
- name: DocumentationArtifactName
value: 'docs'
- name: DocumentationArtifactZipFileName
value: 'documentation.zip'
- name: WebsiteArtifactName
value: 'website'
- name: WebsiteArtifactZipFileName
value: 'website.zip'
- name: BinaryArtifactName
value: 'testbinaries'
- name: NuGetArtifactName
value: 'nuget'
- name: DebugArtifactName # For .pdb symbols
value: 'debug'
- name: ReleaseArtifactName
value: 'release'
- name: TestResultsArtifactName
value: 'testresults'
- name: VersionArtifactName
value: 'version'
- name: BuildNumberFileName
value: 'buildNumber.txt'
- name: PackageVersionFileName
value: 'packageVersion.txt'
- name: FileVersionFileName
value: 'fileVersion.txt'
- name: TestSettingsFileName
value: 'lucene.testsettings.json'
- name: BuildDirectory # Where the build scripts and configs are
value: '$(System.DefaultWorkingDirectory)/build'
- name: PublishDirectory # Test binaries directory
value: '$(Build.ArtifactStagingDirectory)/$(BinaryArtifactName)'
- name: NuGetArtifactDirectory # NuGet binaries directory
value: '$(Build.ArtifactStagingDirectory)/$(NuGetArtifactName)'
stages:
- stage: Build_Stage
displayName: 'Build Stage:'
jobs:
- job: Build
pool:
vmImage: 'windows-2019'
variables:
PublishTempDirectory: '$(Build.BinariesDirectory)/publish'
steps:
- checkout: self # self represents the repo where the initial Pipelines YAML file was found
fetchDepth: 1 # the depth of commits to ask Git to fetch
- powershell: |
$configuration = if ($env:BUILDCONFIGURATION) { $env:BUILDCONFIGURATION } else { "Release" }
Write-Host "##vso[task.setvariable variable=BuildConfiguration;]$configuration"
displayName: 'Setup Default Variable Values'
- task: UseDotNet@2
displayName: 'Use .NET Core sdk 3.1.301'
inputs:
version: 3.1.301
- powershell: |
Import-Module "$(BuildDirectory)/psake.psm1"
$generateBuildBat = if ($Env:ISRELEASE -eq 'true') { 'true' } else { 'false' }
$parameters = @{}
$properties = @{
backup_files='false';
publish_directory='$(PublishTempDirectory)';
nuget_package_directory='$(NuGetArtifactDirectory)'
# Lock the build.bat so it only builds this version in the release distribution
generateBuildBat=$generateBuildBat
}
[string[]]$tasks = 'Pack'
if ($Env:RunTests -ne 'false') {
[string[]]$tasks = 'Pack','Publish'
}
Invoke-psake $(BuildDirectory)/build.ps1 -Task $tasks -properties $properties -parameters $parameters
exit !($psake.build_success)
displayName: 'PSake Build, Pack, and Publish'
- template: 'build/azure-templates/show-all-environment-variables.yml'
- pwsh: |
$dir = '$(Build.ArtifactStagingDirectory)/$(VersionArtifactName)'
if (!(Test-Path $dir)) { New-Item -ItemType Directory -Path "$dir" -Force }
'$(PackageVersion)' | Out-File -FilePath "$dir/$(PackageVersionFileName)" -Force
'$(FileVersion)' | Out-File -FilePath "$dir/$(FileVersionFileName)" -Force
'$(Build.BuildNumber)' | Out-File -FilePath "$dir/$(BuildNumberFileName)" -Force
displayName: 'Persist Versions to Files'
- pwsh: |
# Generate a lucene.testsettings.json file for use with the test framework
$nightly = if ($Env:IsNightly -eq 'true') { 'true' } else { 'false' }
$weekly = if ($Env:IsWeekly -eq 'true') { 'true' } else { 'false' }
$slow = if ($Env:RunSlowTests -ne 'false') { 'true' } else { 'false' }
$awaitsFix = if ($Env:RunAwaitsFixTests -eq 'true') { 'true' } else { 'false' }
$codec = if ($Env:Codec -eq $null) { 'random' } else { $Env:Codec }
$docValuesFormat = if ($Env:DocValuesFormat -eq $null) { 'random' } else { $Env:DocValuesFormat }
$postingsFormat = if ($Env:PostingsFormat -eq $null) { 'random' } else { $Env:PostingsFormat }
$directory = if ($Env:Directory -eq $null) { 'random' } else { $Env:Directory }
$verbose = if ($Env:Verbose -eq 'true') { 'true' } else { 'false' }
$multiplier = if ($Env:Multiplier -eq $null) { '1' } else { $Env:Multiplier }
$fileText = "{`n`t""tests"":`n`t{`n`t`t" +
"""nightly"": ""$nightly"",`n`t`t" +
"""weekly"": ""$weekly"",`n`t`t" +
"""slow"": ""$slow"",`n`t`t" +
"""awaitsfix"": ""$awaitsFix"",`n`t`t" +
"""codec"": ""$codec"",`n`t`t" +
"""docvaluesformat"": ""$docValuesFormat"",`n`t`t" +
"""postingsformat"": ""$postingsFormat"",`n`t`t" +
"""directory"": ""$directory"",`n`t`t" +
"""verbose"": ""$verbose"",`n`t`t" +
"""multiplier"": ""$multiplier""`n`t" +
"}`n}"
Out-File -filePath "$(Build.ArtifactStagingDirectory)/$(TestSettingsFileName)" -encoding UTF8 -inputObject $fileText
displayName: 'Persist Test Settings to lucene.testsettings.json'
condition: and(succeeded(), ne(variables['RunTests'], 'false'))
# If this is a release pipeline, copy the build.bat and Version.props files as version artifacts, which will
# overwrite the build.bat and Version.props files of the release.
- task: CopyFiles@2
displayName: 'Copy build.bat and Version.props Files to: /$(VersionArtifactName)'
inputs:
SourceFolder: '$(System.DefaultWorkingDirectory)'
Contents: |
build.bat
Version.props
TargetFolder: '$(Build.ArtifactStagingDirectory)/$(VersionArtifactName)'
condition: and(succeeded(), eq(variables['IsRelease'], 'true'))
- task: PublishPipelineArtifact@1
displayName: 'Publish Artifact: $(VersionArtifactName)'
inputs:
targetPath: '$(Build.ArtifactStagingDirectory)/$(VersionArtifactName)'
artifact: '$(VersionArtifactName)'
publishLocation: 'pipeline'
# Copy the .pdb files as build artifacts, which will
# later be used to push to the Azure Artifacts symbol server.
- task: CopyFiles@2
displayName: 'Copy .pdb Files to: /$(DebugArtifactName)'
inputs:
SourceFolder: '$(System.DefaultWorkingDirectory)'
Contents: '**/bin/$(BuildConfiguration)/**/*.pdb'
TargetFolder: '$(Build.ArtifactStagingDirectory)/$(DebugArtifactName)'
- template: 'build/azure-templates/publish-test-binaries.yml'
parameters:
publishDirectory: $(PublishTempDirectory)
framework: 'netcoreapp3.1'
binaryArtifactName: '$(BinaryArtifactName)'
testSettingsFilePath: '$(Build.ArtifactStagingDirectory)/$(TestSettingsFileName)'
- template: 'build/azure-templates/publish-test-binaries.yml'
parameters:
publishDirectory: $(PublishTempDirectory)
framework: 'netcoreapp2.1'
binaryArtifactName: '$(BinaryArtifactName)'
testSettingsFilePath: '$(Build.ArtifactStagingDirectory)/$(TestSettingsFileName)'
- template: 'build/azure-templates/publish-test-binaries.yml'
parameters:
publishDirectory: $(PublishTempDirectory)
framework: 'net48'
binaryArtifactName: '$(BinaryArtifactName)'
testSettingsFilePath: '$(Build.ArtifactStagingDirectory)/$(TestSettingsFileName)'
- task: PublishPipelineArtifact@1
displayName: 'Publish Artifact: $(NuGetArtifactName)'
inputs:
targetPath: '$(Build.ArtifactStagingDirectory)/$(NuGetArtifactName)'
artifact: '$(NuGetArtifactName)'
publishLocation: 'pipeline'
- task: PublishPipelineArtifact@1
displayName: 'Publish Artifact: $(DebugArtifactName)'
inputs:
targetPath: '$(Build.ArtifactStagingDirectory)/$(DebugArtifactName)'
artifact: '$(DebugArtifactName)'
publishLocation: 'pipeline'
- job: Docs
condition: and(succeeded(), eq(variables['GenerateDocs'], 'true'))
pool:
vmImage: 'vs2017-win2016'
steps:
- powershell: |
$(Build.SourcesDirectory)/websites/apidocs/docs.ps1 -LuceneNetVersion $(PackageVersion) -Clean -BaseUrl https://lucenenet.apache.org/docs/
errorActionPreference: 'continue'
ignoreLASTEXITCODE: true
failOnStderr: false
displayName: 'Generate Documentation'
- task: ArchiveFiles@2
displayName: 'Zip Documenation Files'
inputs:
rootFolderOrFile: '$(Build.SourcesDirectory)/websites/apidocs/_site'
includeRootFolder: false
archiveFile: '$(Build.ArtifactStagingDirectory)/$(DocumentationArtifactName)/$(DocumentationArtifactZipFileName)'
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: $(DocumentationArtifactName)'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)/$(DocumentationArtifactName)'
ArtifactName: '$(DocumentationArtifactName)'
- job: Website
condition: and(succeeded(), eq(variables['GenerateWebsite'], 'true'))
pool:
vmImage: 'vs2017-win2016'
steps:
- powershell: |
$(Build.SourcesDirectory)/websites/site/site.ps1 0 1
errorActionPreference: 'continue'
ignoreLASTEXITCODE: true
failOnStderr: false
displayName: 'Generate Website'
- task: ArchiveFiles@2
displayName: 'Zip Website Files'
inputs:
rootFolderOrFile: '$(Build.SourcesDirectory)/websites/site/_site'
includeRootFolder: false
archiveFile: '$(Build.ArtifactStagingDirectory)/$(WebsiteArtifactName)/$(WebsiteArtifactZipFileName)'
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: $(WebsiteArtifactName)'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)/$(WebsiteArtifactName)'
ArtifactName: '$(WebsiteArtifactName)'
- stage: Test_Stage
displayName: 'Test Stage:'
jobs:
- job: Test_netcoreapp3_1
condition: and(succeeded(), ne(variables['RunTests'], 'false'))
strategy:
matrix:
Windows:
osName: 'Windows'
imageName: 'windows-2019'
maximumParallelJobs: 7
maximumAllowedFailures: 4 # Maximum allowed failures for a successful build
Linux:
osName: 'Linux'
imageName: 'ubuntu-16.04'
maximumParallelJobs: 6
maximumAllowedFailures: 4 # Maximum allowed failures for a successful build
macOS:
osName: 'macOS'
imageName: 'macOS-10.14'
maximumParallelJobs: 6
maximumAllowedFailures: 4 # Maximum allowed failures for a successful build
displayName: 'Test netcoreapp3.1 on'
pool:
vmImage: $(imageName)
steps:
- template: 'build/azure-templates/run-tests-on-os.yml'
parameters:
osName: $(osName)
framework: 'netcoreapp3.1'
testResultsArtifactName: '$(TestResultsArtifactName)'
maximumParallelJobs: $(maximumParallelJobs)
maximumAllowedFailures: $(maximumAllowedFailures)
- job: Test_netcoreapp2_2
condition: and(succeeded(), ne(variables['RunTests'], 'false'))
strategy:
matrix:
Windows:
osName: 'Windows'
imageName: 'windows-2019'
maximumParallelJobs: 7
maximumAllowedFailures: 4 # Maximum allowed failures for a successful build
Linux:
osName: 'Linux'
imageName: 'ubuntu-16.04'
maximumParallelJobs: 6
maximumAllowedFailures: 4 # Maximum allowed failures for a successful build
macOS:
osName: 'macOS'
imageName: 'macOS-10.14'
maximumParallelJobs: 6
maximumAllowedFailures: 4 # Maximum allowed failures for a successful build
displayName: 'Test netcoreapp2.1 on'
pool:
vmImage: $(imageName)
steps:
- template: 'build/azure-templates/run-tests-on-os.yml'
parameters:
osName: $(osName)
framework: 'netcoreapp2.1'
testResultsArtifactName: '$(TestResultsArtifactName)'
maximumParallelJobs: $(maximumParallelJobs)
maximumAllowedFailures: $(maximumAllowedFailures)
- job: Test_net48_Windows
condition: and(succeeded(), ne(variables['RunTests'], 'false'))
displayName: 'Test net48 on Windows'
pool:
vmImage: 'windows-2019'
steps:
- template: 'build/azure-templates/run-tests-on-os.yml'
parameters:
osName: 'Windows'
framework: 'net48'
testResultsArtifactName: '$(TestResultsArtifactName)'
maximumParallelJobs: 7
maximumAllowedFailures: 4 # Maximum allowed failures for a successful build
- stage: Publish_Stage
displayName: 'Publish Stage:'
jobs:
# Optional job to push to Azure Artifact feed. Just pass in
# the GUID of the artifact feed as ArtifactFeedID to enable.
- job: Publish_Azure_Artifacts
condition: and(succeeded(), ne(variables['ArtifactFeedID'], ''))
pool:
vmImage: 'windows-2019'
steps:
# We checkout here because we need to publish the source code along with the symbols for debugging
- checkout: self # self represents the repo where the initial Pipelines YAML file was found
fetchDepth: 1 # the depth of commits to ask Git to fetch
- template: 'build/azure-templates/show-all-environment-variables.yml'
- task: DownloadPipelineArtifact@0
displayName: 'Download Build Artifacts: $(VersionArtifactName)'
inputs:
artifactName: '$(VersionArtifactName)'
targetPath: '$(System.DefaultWorkingDirectory)/$(VersionArtifactName)'
# For debugging this pipeline
- powershell: |
Get-ChildItem -Path $(System.DefaultWorkingDirectory)
- powershell: |
Get-ChildItem -Path '$(VersionArtifactName)'
# NOTE: We are setting Build.BuildNumber here to the NuGet package version to work around the limitation that
# the version cannot be passed to the Index Sources & Publish Symbols task.
- powershell: |
$version = Get-Content '$(VersionArtifactName)/$(PackageVersionFileName)' -Raw
Write-Host "##vso[task.setvariable variable=PackageVersion;]$version"
Write-Host "##vso[build.updatebuildnumber]$version"
displayName: 'Read PackageVersion from File to Build.BuildNumber'
- template: 'build/azure-templates/show-all-environment-variables.yml'
- template: 'build/azure-templates/publish-nuget-packages.yml'
parameters:
artifactFeedID: '$(ArtifactFeedID)'
nugetArtifactName: '$(NuGetArtifactName)'
debugArtifactName: '$(DebugArtifactName)'
- stage: Release_Stage
displayName: 'Release Stage:'
jobs:
- job: Release
condition: and(succeeded(), eq(variables['IsRelease'], 'true'))
displayName: 'Build Release Artifacts for [VOTE]'
pool:
vmImage: 'windows-2019'
steps:
# We checkout here because we need to publish the source code along with the binaries per Apache's releae policy
- checkout: self # self represents the repo where the initial Pipelines YAML file was found
fetchDepth: 1 # the depth of commits to ask Git to fetch
- template: 'build/azure-templates/show-all-environment-variables.yml'
- task: DownloadPipelineArtifact@0
displayName: 'Download Build Artifacts: $(NuGetArtifactName)'
inputs:
artifactName: '$(NuGetArtifactName)'
targetPath: '$(Build.ArtifactStagingDirectory)/$(NuGetArtifactName)'
- task: DownloadPipelineArtifact@0
displayName: 'Download Build Artifacts: $(VersionArtifactName)'
inputs:
artifactName: '$(VersionArtifactName)'
targetPath: '$(Build.ArtifactStagingDirectory)/$(VersionArtifactName)'
- template: 'build/azure-templates/show-all-files.yml' # Uncomment for debugging
# NOTE: We are setting Build.BuildNumber here to the NuGet package version to work around the limitation that
# the version cannot be passed to the Index Sources & Publish Symbols task.
- powershell: |
$version = Get-Content '$(Build.ArtifactStagingDirectory)/$(VersionArtifactName)/$(PackageVersionFileName)' -Raw
$vcsLabel = 'Lucene.Net_' + $version.Replace('.', '_').Replace('-', '_')
Write-Host "##vso[task.setvariable variable=VCSLabel;]$vcsLabel"
Write-Host "##vso[task.setvariable variable=PackageVersion;]$version"
Write-Host "##vso[build.updatebuildnumber]$version"
displayName: 'Build VCS Label and Rehydrate Version Variables'
- powershell: |
$files = 'build.bat','Version.props'
foreach ($file in $files) {
Copy-Item -Path "$(Build.ArtifactStagingDirectory)/$(VersionArtifactName)/$file" -Destination "$(Build.SourcesDirectory)/$file" -Force -ErrorAction Continue
}
displayName: 'Update build.bat and Version.props to build only version $(PackageVersion)'
- template: 'build/azure-templates/show-all-environment-variables.yml'
- task: CopyFiles@2
displayName: 'Copy Source Code Files to: $(Build.ArtifactStagingDirectory)/srctemp'
inputs:
SourceFolder: '$(Build.SourcesDirectory)'
Contents: |
**
!.git/**/*
!branding/**/*
!release/**/*
!src/**/bin/**/*
!src/**/obj/**/*
branding/logo/lucene-net-icon-128x128.png
TargetFolder: '$(Build.ArtifactStagingDirectory)/srctemp'
- task: ArchiveFiles@2
displayName: 'Archive Source Code Files'
inputs:
rootFolderOrFile: '$(Build.ArtifactStagingDirectory)/srctemp'
includeRootFolder: false
archiveFile: '$(Build.ArtifactStagingDirectory)/$(ReleaseArtifactName)/Apache-Lucene.Net-$(PackageVersion).src.zip'
- task: CopyFiles@2
displayName: 'Copy License/Notice Files to: $(NuGetArtifactName)'
inputs:
SourceFolder: '$(Build.SourcesDirectory)'
Contents: |
LICENSE.txt
NOTICE.txt
TargetFolder: '$(Build.ArtifactStagingDirectory)/$(NuGetArtifactName)'
- task: ArchiveFiles@2
displayName: 'Archive Binary Files'
inputs:
rootFolderOrFile: '$(Build.ArtifactStagingDirectory)/$(NuGetArtifactName)'
includeRootFolder: false
archiveFile: '$(Build.ArtifactStagingDirectory)/$(ReleaseArtifactName)/Apache-Lucene.Net-$(PackageVersion).bin.zip'
- powershell: |
$dir = '$(Build.ArtifactStagingDirectory)/$(ReleaseArtifactName)'
if (!(Test-Path $dir)) { New-Item -ItemType Directory -Path "$dir" -Force }
$nl = [Environment]::NewLine
"TODO: Review: http://www.apache.org/legal/release-policy.html" + $nl + `
"TODO: Tag Repository" + $nl + `
" commit: $(Build.SourceVersion)" + $nl + `
" tag: $(VCSLabel)" + $nl + `
"TODO: Sign release artifacts (see https://www.apache.org/dev/release-signing.html)" + $nl + `
"TODO: Push release artifacts to dev (https://dist.apache.org/repos/dist/dev/lucenenet/)" + $nl + `
"TODO: Start release [VOTE] (see https://www.apache.org/foundation/voting.html)" + $nl | Out-File -FilePath "$dir/RELEASE-TODO.txt" -Force
displayName: 'Write RELEASE-TODO.txt'
- task: PublishPipelineArtifact@1
displayName: 'Publish Artifact: $(ReleaseArtifactName)'
inputs:
targetPath: '$(Build.ArtifactStagingDirectory)/$(ReleaseArtifactName)'
artifact: '$(ReleaseArtifactName)'
publishLocation: 'pipeline'
# LUCENENET TODO: Write VCS Label (git tag) automatically