-
Notifications
You must be signed in to change notification settings - Fork 114
/
build.yml
161 lines (142 loc) · 6.28 KB
/
build.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
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
# Builds dotnet-monitor for a specific platform and configuration
parameters:
# Job prefix (required)
prefix: ''
# Operating system group (Windows, Linux, MacOS, etc)
osGroup: Windows
# Build configuration (Debug, Release)
configuration: Release
# Build architecture (arm64, x64, x86, etc)
architecture: x64
# Enables cross build from host target libraries and architectures
enableCrossBuild: true
# Docker container in which job steps shall be run (leave empty to choose default build container).
# This should be empty unless exclusively testing on a specific container image.
container: ''
# Additional job variables
variables: []
# Additional steps to execute before build
preBuildSteps: []
# Additional steps to execute after build
postBuildSteps: []
# Job timeout
timeoutInMinutes: 180
# Job dependencies
dependsOn: ''
# Disable Component Governance injection and analysis
disableComponentGovernance: ''
# Disable SBOM generation
disableSbom: false
buildArgs: ''
buildEnv: {}
# Adjust for 1ES pipeline template
is1ESPipeline: true
commonTemplatesFolderName: 'templates-official'
jobs:
- template: /eng/common/${{ parameters.commonTemplatesFolderName }}/job/job.yml@self
parameters:
name: ${{ parameters.prefix }}_${{ parameters.configuration }}_${{ parameters.osGroup }}_${{ parameters.architecture }}
displayName: ${{ format('{0} {1} {2} {3}', parameters.prefix, parameters.osGroup, parameters.architecture, parameters.configuration) }}
timeoutInMinutes: ${{ parameters.timeoutInMinutes }}
enableTelemetry: true
disableComponentGovernance: ${{ parameters.disableComponentGovernance }}
${{ if eq(parameters.disableSbom, 'true') }}:
enableSbom: false
helixRepo: dotnet/dotnet-monitor
artifacts:
publish:
logs:
name: Logs_$(JobName)
# Default build pool is Windows; override for Linux and MacOS
${{ if in(parameters.osGroup, 'Linux', 'Linux_Musl') }}:
# Public Linux Build Pool
${{ if eq(variables['System.TeamProject'], 'public') }}:
pool:
name: $(DncEngPublicBuildPool)
demands: ImageOverride -equals Build.Ubuntu.2204.Amd64.Open
os: linux
# Official Build Linux Pool
${{ if ne(variables['System.TeamProject'], 'public') }}:
pool:
name: $(DncEngInternalBuildPool)
demands: ImageOverride -equals 1es-ubuntu-2204
os: linux
# Build OSX Pool
${{ if in(parameters.osGroup, 'MacOS') }}:
pool:
name: Azure Pipelines
vmImage: macos-15
os: macOS
${{ if ne(parameters.container, '') }}:
container: ${{ parameters.container }}
${{ else }}:
# Fallback to default Linux x64 build container that optionally support cross building
${{ if eq(parameters.osGroup, 'Linux') }}:
${{ if eq(parameters.architecture, 'arm64') }}:
container: build_linux_arm64_cross
${{ else }}:
container: build_linux_amd64_cross
${{ if eq(parameters.osGroup, 'Linux_Musl') }}:
${{ if eq(parameters.architecture, 'arm64') }}:
container: build_linux_musl_arm64_cross
${{ else }}:
container: build_linux_musl_amd64_cross
${{ if ne(parameters.dependsOn, '') }}:
dependsOn: ${{ parameters.dependsOn }}
workspace:
clean: all
variables:
- JobName: ${{ parameters.prefix }}_${{ parameters.configuration }}_${{ parameters.osGroup }}_${{ parameters.architecture }}
- _BuildConfig: ${{ parameters.configuration }}
- _CrossBuildArgs: ''
- _InternalInstallArgs: ''
- _InternalBuildArgs: ''
- ${{ each variable in parameters.variables }}:
- ${{ variable }}
# Cross build for all Linux builds and arm64 non-Windows builds
- ${{ if and(eq(parameters.enableCrossBuild, 'true'), or(in(parameters.osGroup, 'Linux', 'Linux_Musl'), and(eq(parameters.architecture, 'arm64'), ne(parameters.osGroup, 'Windows')))) }}:
- _CrossBuildArgs: '-cross'
- ${{ if eq(variables['System.TeamProject'], 'internal') }}:
- _InternalInstallArgs: >-
-RuntimeSourceFeed https://dotnetbuilds.blob.core.windows.net/internal
-RuntimeSourceFeedKey $(dotnetbuilds-internal-container-read-token-base64)
- ${{ if and(ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}:
- _InternalBuildArgs: >-
/p:TeamName=$(_TeamName)
/p:OfficialBuildId=$(BUILD.BUILDNUMBER)
# Only enable publishing in non-public, non PR scenarios.
- ${{ if and(ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}:
- _HelixSource: official/dotnet/dotnet-monitor/$(Build.SourceBranch)
- ${{ if and(ne(variables['System.TeamProject'], 'public'), in(variables['Build.Reason'], 'PullRequest')) }}:
- _HelixSource: pr-internal/dotnet/dotnet-monitor/$(Build.SourceBranch)
- ${{ if or(eq(variables['System.TeamProject'], 'public'), in(variables['Build.Reason'], 'PullRequest')) }}:
- _HelixSource: pr/dotnet/dotnet-monitor/$(Build.SourceBranch)
- ${{ if eq(parameters.osGroup, 'Windows') }}:
- scriptExt: '.cmd'
- ${{ if ne(parameters.osGroup, 'Windows') }}:
- scriptExt: '.sh'
steps:
- ${{ if ne(variables['System.TeamProject'], 'public') }}:
- template: /eng/pipelines/steps/setup-nuget-sources.yml@self
parameters:
osGroup: ${{ parameters.osGroup }}
- ${{ each step in parameters.preBuildSteps }}:
- ${{ step }}
# Populate internal runtime access variables
- template: /eng/common/templates/steps/enable-internal-runtimes.yml
- script: >-
$(Build.SourcesDirectory)/eng/cibuild$(scriptExt)
-configuration ${{ parameters.configuration }}
-architecture ${{ parameters.architecture }}
${{ parameters.buildArgs }}
$(_CrossBuildArgs)
$(_InternalInstallArgs)
$(_InternalBuildArgs)
displayName: Build
env:
${{ insert }}: ${{ parameters.buildEnv }}
# Set ROOTFS_DIR for Linux cross builds
${{ if and(eq(parameters.enableCrossBuild, 'true'), in(parameters.osGroup, 'Linux', 'Linux_Musl')) }}:
ROOTFS_DIR: '/crossrootfs/${{ parameters.architecture }}'
- ${{ each step in parameters.postBuildSteps }}:
- ${{ step }}