-
Notifications
You must be signed in to change notification settings - Fork 159
/
azure-pipelines.yml
134 lines (132 loc) · 4.46 KB
/
azure-pipelines.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
trigger:
paths:
exclude:
- 'docs/'
branches:
include:
- master
tags:
include:
- '*'
variables:
- name: DOTNET_SKIP_FIRST_TIME_EXPERIENCE
value: true
- name: DOTNET_CLI_TELEMETRY_OPTOUT
value: true
stages:
- stage: "Prepare"
displayName: "Build, test and pack"
jobs:
- job: "Build"
strategy:
matrix:
Linux:
imageName: 'ubuntu-latest'
Windows:
imageName: 'windows-latest'
pool:
vmImage: $(imageName)
steps:
- checkout: self
submodules: 'true'
- task: UseDotNet@2
displayName: 'Use .NET Core SDK'
inputs:
packageType: sdk
useGlobalJson: true
installationPath: $(Agent.ToolsDirectory)/dotnet
- task: DotNetCoreCLI@2
displayName: 'Restore Tools'
inputs:
command: 'custom'
custom: 'tool'
arguments: 'restore'
- task: DotNetCoreCLI@2
displayName: 'Fantomas Check'
inputs:
command: 'custom'
custom: 'fantomas'
arguments: 'src --check'
- task: DotNetCoreCLI@2
displayName: 'Restore Packages'
inputs:
command: 'restore'
verbosityRestore: 'Minimal'
- task: DotNetCoreCLI@2
displayName: 'Build'
inputs:
command: 'build'
arguments: '-c release'
- task: AzureCLI@2
displayName: 'Test master'
condition: and(succeeded(), not(eq(variables['build.reason'], 'PullRequest')))
inputs:
azureSubscription: 'Microsoft Azure Sponsorship(6c9e2629-3964-4b24-bc32-97dafc8c90f3)'
scriptType: 'bash'
scriptLocation: 'inlineScript'
inlineScript: 'dotnet test -v n -c release -l trx --collect:"XPlat Code Coverage"'
- task: DotNetCoreCLI@2
displayName: 'Test Pull Request'
condition: and(succeeded(), eq(variables['build.reason'], 'PullRequest'))
inputs:
command: 'test'
arguments: '-v n -c release -l trx --collect:"XPlat Code Coverage"'
- task: PublishTestResults@2
displayName: 'Publish Test Results' # happens automatically on PR builds using @DotNetCoreCLI task
condition: not(eq(variables['build.reason'], 'PullRequest'))
inputs:
testResultsFiles: '**/*.trx'
testResultsFormat: VSTest
- task: PublishCodeCoverageResults@1
displayName: "Publish Code Coverage"
condition: and(succeeded(), not(eq(variables['build.reason'], 'PullRequest')))
inputs:
codeCoverageTool: 'Cobertura'
summaryFileLocation: '$(Build.SourcesDirectory)/src/Tests/TestResults/*/coverage.cobertura.xml'
- task: PublishCodeCoverageResults@1
displayName: "Publish PR Code Coverage"
condition: and(succeeded(), eq(variables['build.reason'], 'PullRequest'))
inputs:
codeCoverageTool: 'Cobertura'
summaryFileLocation: '$(Agent.TempDirectory)/*/coverage.cobertura.xml'
- task: DotNetCoreCLI@2
displayName: 'Package'
condition: and(succeeded(), eq(variables.imageName, 'ubuntu-latest'))
inputs:
command: 'pack'
packagesToPack: 'src/Farmer'
configuration: Release
versioningScheme: 'off'
verbosityPack: 'Minimal'
- task: PublishBuildArtifacts@1
displayName: Store NuGet Package
condition: and(succeeded(), eq(variables.imageName, 'ubuntu-latest'))
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'FarmerPackage-$(imageName)'
publishLocation: 'Container'
- stage: "Release"
displayName: "Release to NuGet"
dependsOn: ["Prepare"]
condition: and(succeeded(), startsWith(variables['build.sourceBranch'], 'refs/tags/')) #optional, only publish nuget pkg for new tags
jobs:
- deployment: "NugetPublish"
displayName: "Publish to NuGet"
environment: "NuGet" #needs to be configured in ADoS - put a manual gate here
pool:
vmImage: 'windows-latest' #task doesn't run on other OS's
strategy:
runOnce:
deploy:
steps:
- task: NuGetToolInstaller@1
displayName: "Install nuget 4.9.x"
inputs:
versionSpec: 4.9.x # Needed to publish symbols (.snupkg)
- task: NuGetCommand@2
displayName: "Push to NuGet"
inputs:
command: 'push'
packagesToPush: '$(Pipeline.Workspace)/**/*.nupkg;' #Path here must match
nuGetFeedType: 'external'
publishFeedCredentials: 'NuGet' #this needs to be established in ADos Servie Connections