-
Notifications
You must be signed in to change notification settings - Fork 862
Expand file tree
/
Copy pathBuildAndTest.yml
More file actions
179 lines (160 loc) · 7.57 KB
/
BuildAndTest.yml
File metadata and controls
179 lines (160 loc) · 7.57 KB
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
parameters:
- name: buildScript
type: string
- name: buildConfig
type: string
- name: repoLogPath
type: string
- name: repoTestResultsPath
type: string
- name: isWindows
type: string
- name: skipTests
type: boolean
default: false
- name: skipQualityGates
type: boolean
default: false
- name: warnAsError
type: number
default: 1
- name: runAsPublic
type: boolean
default: false
steps:
- task: NodeTool@0
displayName: Add NodeJS/npm
inputs:
versionSpec: "20.x"
checkLatest: true
- script: ${{ parameters.buildScript }}
-restore
/bl:${{ parameters.repoLogPath }}/restore.binlog
displayName: Restore
- pwsh: |
$(Build.SourcesDirectory)/scripts/Slngen.ps1 -All -NoLaunch
displayName: Create solution
- script: ${{ parameters.buildScript }}
-restore
/bl:${{ parameters.repoLogPath }}/restore2.binlog
displayName: Restore solution
- script: ${{ parameters.buildScript }}
-build
-configuration ${{ parameters.buildConfig }}
-warnAsError ${{ parameters.warnAsError }}
/bl:${{ parameters.repoLogPath }}/build.binlog
$(_OfficialBuildIdArgs)
displayName: Build
- ${{ if ne(parameters.skipTests, 'true') }}:
- script: $(Build.SourcesDirectory)/.dotnet/dotnet dotnet-coverage collect
--settings $(Build.SourcesDirectory)/eng/CodeCoverage.config
--output ${{ parameters.repoTestResultsPath }}/$(Agent.JobName)_CodeCoverageResults/$(Agent.JobName)_cobertura.xml
"${{ parameters.buildScript }} -test -configuration ${{ parameters.buildConfig }} /bl:${{ parameters.repoLogPath }}/tests.binlog $(_OfficialBuildIdArgs)"
displayName: Run unit tests
- script: ${{ parameters.buildScript }}
-pack
-configuration ${{ parameters.buildConfig }}
-warnAsError 1
/bl:${{ parameters.repoLogPath }}/pack.binlog
/p:Restore=false /p:Build=false
$(_OfficialBuildIdArgs)
displayName: Pack
- ${{ if ne(parameters.skipTests, 'true') }}:
- script: ${{ parameters.buildScript }}
-integrationTest
-configuration ${{ parameters.buildConfig }}
-warnAsError 1
/bl:${{ parameters.repoLogPath }}/integration_tests.binlog
$(_OfficialBuildIdArgs)
displayName: Run integration tests
- pwsh: |
$SourcesDirectory = '$(Build.SourcesDirectory)';
$destinationPath = "${{ parameters.repoLogPath }}/FailedAssertions"
if (-not (Test-Path -Path $destinationPath)) {
New-Item -Path $destinationPath -ItemType Directory -Force | Out-Null
}
Get-ChildItem $SourcesDirectory -Filter "*.received.*" -Recurse | `
ForEach-Object {
# Exclude files that are already in the test results path
if ($_.FullName -like "*FailedAssertions*") {
return
}
if ($_.PSIsContainer) {
# Delete the folder if it exists
$dest = Join-Path -Path $destinationPath -ChildPath $_.Name
if (Test-Path -Path $dest) {
Remove-Item -Path $dest -Recurse -Force
}
# Copy folder to logs
Copy-Item -Path $_.FullName -Destination $destinationPath -Recurse -Force
}
else {
# Calculates the relative path of the file with respect to `$SourcesDirectory`.
$relativePath = [System.IO.Path]::GetRelativePath($SourcesDirectory, $_.FullName)
# Constructs the full destination path for the file, preserving the relative directory structure.
$destinationFile = Join-Path -Path $destinationPath -ChildPath $relativePath
$destinationDirectory = [System.IO.Path]::GetDirectoryName($destinationFile)
# Ensures the destination directory exists (creates it if necessary).
if (-not (Test-Path -Path $destinationDirectory)) {
New-Item -Path $destinationDirectory -ItemType Directory -Force | Out-Null
}
# Copies the file to the destination path.
Copy-Item -Path $_.FullName -Destination $destinationFile -Force
}
}
displayName: Copy failed assertions results to logs
condition: always()
continueOnError: true
- pwsh: |
Get-ChildItem ${{ parameters.repoTestResultsPath }} -Include "*_hangdump.dmp","Sequence_*.xml" -Recurse | `
ForEach-Object {
$sourceFolder = $_.Directory.Name;
# The folder must be a GUID, see https://learn.microsoft.com/dotnet/core/tools/dotnet-test#options
$not_used = [System.Guid]::Empty;
if ([System.Guid]::TryParse($sourceFolder, [System.Management.Automation.PSReference]$not_used)) {
$destinationFolder = $(New-Item -Path ${{ parameters.repoLogPath }} -Name $sourceFolder -ItemType "Directory" -Force).FullName;
$destination = "$destinationFolder\$($_.Name)";
Copy-Item -Path $_.FullName -Destination $destination -Force;
}
}
displayName: Copy crash results to logs
condition: always()
continueOnError: true
- script: $(Build.SourcesDirectory)/.dotnet/dotnet publish
workingDirectory: $(Build.SourcesDirectory)/test/Libraries/Microsoft.Extensions.AotCompatibility.TestApp
displayName: Publish AOT Test
- ${{ if ne(parameters.skipQualityGates, 'true') }}:
- ${{ if eq(parameters.runAsPublic, 'true') }}:
- task: PublishPipelineArtifact@1
displayName: Publish coverage results (cobertura.xml)
inputs:
targetPath: '${{ parameters.repoTestResultsPath }}/$(Agent.JobName)_CodeCoverageResults'
artifactName: "$(Agent.JobName)_CodeCoverageResults"
publishLocation: 'pipeline'
- ${{ if ne(parameters.runAsPublic, 'true') }}:
- task: 1ES.PublishPipelineArtifact@1
displayName: Publish coverage results (cobertura.xml)
inputs:
targetPath: '${{ parameters.repoTestResultsPath }}/$(Agent.JobName)_CodeCoverageResults'
artifactName: "$(Agent.JobName)_CodeCoverageResults"
- ${{ if eq(parameters.isWindows, 'true') }}:
# Publishing will happen in a subsequent step
- script: ${{ parameters.buildScript }}
-projects $(Build.SourcesDirectory)/src/Packages/Microsoft.Internal.Extensions.DotNetApiDocs.Transport/Microsoft.Internal.Extensions.DotNetApiDocs.Transport.proj
-pack
-configuration ${{ parameters.buildConfig }}
/bl:${{ parameters.repoLogPath }}/transport.binlog
$(_OfficialBuildIdArgs)
displayName: Pack docs transport package
- pwsh: |
$(Build.SourcesDirectory)/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/TypeScript/azure-devops-report/build.ps1 -OutputPath $(Build.Arcade.VSIXOutputPath)
displayName: Build Azure DevOps plugin
- script: ${{ parameters.buildScript }}
-sign $(_SignArgs)
-publish $(_PublishArgs)
-configuration ${{ parameters.buildConfig }}
-warnAsError 1
/bl:${{ parameters.repoLogPath }}/publish.binlog
/p:Restore=false /p:Build=false
$(_OfficialBuildIdArgs)
displayName: Sign and publish