Last active
November 2, 2023 11:02
-
-
Save jamesmcroft/cc2411a08fb041c942dccde6ca3e4656 to your computer and use it in GitHub Desktop.
Example complete Azure DevOps CI pipeline with test projects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: $(Major).$(Minor).$(Year:yy)$(DayOfYear).$(Rev:r) | |
trigger: | |
branches: | |
include: | |
- main | |
paths: | |
include: | |
- src/* | |
- build/* | |
- tests/* | |
variables: | |
- name: vmImageName | |
value: 'ubuntu-latest' | |
stages: | |
- stage: 'Build' | |
variables: | |
Solution: '**/*.sln' | |
BuildConfiguration: 'Release' | |
jobs: | |
- job: | |
pool: | |
vmImage: $(vmImageName) | |
workspace: | |
clean: all | |
- task: NuGetToolInstaller@1 | |
displayName: 'Install NuGet' | |
inputs: | |
versionSpec: '5.4.0' | |
- task: NuGetCommand@2 | |
displayName: 'Restore NuGet packages' | |
inputs: | |
command: 'restore' | |
restoreSolution: '$(Solution)' | |
- task: DotNetCoreCLI@2 | |
displayName: 'Build solution' | |
inputs: | |
command: 'build' | |
projects: '$(Solution)' | |
arguments: '--configuration $(BuildConfiguration) -p:Version=$(Build.BuildNumber)' | |
- task: DotNetCoreCLI@2 | |
displayName: 'Run unit tests' | |
inputs: | |
command: 'test' | |
arguments: '/p:CollectCoverage=true /p:CoverletOutputFormat=cobertura' | |
projects: '**/*UnitTests*.csproj' | |
testRunTitle: 'Unit Tests' | |
- task: DotNetCoreCLI@2 | |
displayName: 'Run functional tests' | |
inputs: | |
command: 'test' | |
arguments: '/p:CollectCoverage=true /p:CoverletOutputFormat=cobertura' | |
projects: '**/*FunctionalTests*.csproj' | |
testRunTitle: 'Functional Tests' | |
- task: reportgenerator@4 | |
displayName: 'Generate code coverage report' | |
inputs: | |
reports: '$(Build.SourcesDirectory)/**/*.cobertura.xml' | |
targetdir: '$(Build.SourcesDirectory)/CoverageResults' | |
- task: PublishCodeCoverageResults@1 | |
displayName: 'Publish code coverage' | |
inputs: | |
codeCoverageTool: Cobertura | |
summaryFileLocation: '$(Build.SourcesDirectory)/CoverageResults/Cobertura.xml' | |
- task: DotNetCoreCLI@2 | |
displayName: 'Publish projects' | |
inputs: | |
command: publish | |
publishWebProjects: True | |
arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)/artifacts' | |
zipAfterPublish: True | |
- publish: '$(Build.ArtifactStagingDirectory)/artifacts' | |
artifact: 'artifacts' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment