-
-
Notifications
You must be signed in to change notification settings - Fork 136
/
azure-pipelines.yml
217 lines (188 loc) · 7.49 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
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
variables:
NET_VERSION: "9.0.x"
PathToSolution: "GitTrends.sln"
PathToGitTrendsCsproj: "GitTrends/GitTrends.csproj"
PathToUITestsCsproj: "GitTrends.UITests/GitTrends.UITests.csproj"
PathToUnitTestsCsproj: "GitTrends.UnitTests/GitTrends.UnitTests.csproj"
PathToAzureFunctionsCsproj: "GitTrends.Functions/GitTrends.Functions.csproj"
XcodeVersion: "16.2"
trigger:
branches:
include:
- main
tags:
include:
- "*"
paths:
exclude:
- README.md
pr:
autoCancel: "true"
branches:
include:
- main
paths:
exclude:
- README.md
jobs:
- job: Build_AzureFunctions
displayName: Build Azure Functions
strategy:
matrix:
'Windows':
image: 'windows-latest'
'macOS':
image: 'macos-15'
pool:
vmImage: $(image)
steps:
- task: UseDotNet@2
displayName: "Install Latest .NET SDK"
inputs:
packageType: "sdk"
version: "$(NET_VERSION)"
- task: CmdLine@2
displayName: "Build GitTrends"
inputs:
script: "dotnet build $(PathToAzureFunctionsCsproj) -c Release"
- job: Build_MAUI_App
displayName: Build .NET MAUI App
strategy:
matrix:
'Windows':
image: 'windows-latest'
'macOS':
image: 'macos-15'
pool:
vmImage: $(image)
steps:
- script: |
echo Installed Xcode Versions:
ls -al /Applications | grep Xcode
echo '##vso[task.setvariable variable=MD_APPLE_SDK_ROOT;]'/Applications/Xcode_$(XcodeVersion).app;sudo xcode-select --switch /Applications/Xcode_$(XcodeVersion).app/Contents/Developer
displayName: 'Set Xcode v$(XcodeVersion)'
condition: eq(variables['Agent.OS'], 'Darwin') # Only run this step on macOS
- task: InstallAppleCertificate@2
displayName: "Set Xcode Signing Certificate"
condition: eq(variables['Agent.OS'], 'Darwin') # Only run this step on macOS
inputs:
certSecureFile: 'Certificate.p12'
certPwd: '$(APPLECERTIFICATEPASSWORD)'
- task: InstallAppleProvisioningProfile@1
displayName: "Set Xcode Provisioning Profile"
condition: eq(variables['Agent.OS'], 'Darwin') # Only run this step on macOS
inputs:
provisioningProfileLocation: 'secureFiles'
provProfileSecureFile: 'GitTrends_Development_Profile.mobileprovision'
- task: UseDotNet@2
displayName: "Install Latest .NET SDK"
inputs:
packageType: "sdk"
version: "$(NET_VERSION)"
- task: CmdLine@2
displayName: "Install Latest .NET MAUI Workload"
inputs:
script: "dotnet workload install maui"
- task: JavaToolInstaller@0
displayName: "Install Java"
inputs:
versionSpec: "17"
jdkArchitectureOption: "x64"
jdkSourceOption: "PreInstalled"
- task: CmdLine@2
displayName: "Build GitTrends"
inputs:
script: "dotnet build $(PathToGitTrendsCsproj) -c Release"
- job: Build_UnitTests
displayName: Build Unit Tests
strategy:
matrix:
'Windows':
image: 'windows-latest'
'macOS':
image: 'macos-15'
pool:
vmImage: $(image)
steps:
- script: |
echo Installed Xcode Versions:
ls -al /Applications | grep Xcode
echo '##vso[task.setvariable variable=MD_APPLE_SDK_ROOT;]'/Applications/Xcode_$(XcodeVersion).app;sudo xcode-select --switch /Applications/Xcode_$(XcodeVersion).app/Contents/Developer
displayName: 'Set Xcode v$(XcodeVersion)'
condition: eq(variables['Agent.OS'], 'Darwin') # Only run this step on macOS
- task: InstallAppleCertificate@2
displayName: "Set Xcode Signing Certificate"
condition: eq(variables['Agent.OS'], 'Darwin') # Only run this step on macOS
inputs:
certSecureFile: 'Certificate.p12'
certPwd: '$(APPLECERTIFICATEPASSWORD)'
- task: InstallAppleProvisioningProfile@1
displayName: "Set Xcode Provisioning Profile"
condition: eq(variables['Agent.OS'], 'Darwin') # Only run this step on macOS
inputs:
provisioningProfileLocation: 'secureFiles'
provProfileSecureFile: 'GitTrends_Development_Profile.mobileprovision'
- task: UseDotNet@2
displayName: "Install Latest .NET SDK"
inputs:
packageType: "sdk"
version: "$(NET_VERSION)"
- task: CmdLine@2
displayName: "Install Latest .NET MAUI Workload"
inputs:
script: "dotnet workload install maui"
- task: CmdLine@2
displayName: "Build Unit Tests"
inputs:
script: "dotnet build $(PathToUnitTestsCsproj)"
- job: Run_UnitTests
displayName: Run Unit Tests
dependsOn: [Build_UnitTests, Build_MAUI_App]
pool:
vmImage: macos-15
steps:
- script: |
echo Installed Xcode Versions:
ls -al /Applications | grep Xcode
echo '##vso[task.setvariable variable=MD_APPLE_SDK_ROOT;]'/Applications/Xcode_$(XcodeVersion).app;sudo xcode-select --switch /Applications/Xcode_$(XcodeVersion).app/Contents/Developer
displayName: 'Set Xcode v$(XcodeVersion)'
condition: eq(variables['Agent.OS'], 'Darwin') # Only run this step on macOS
- task: InstallAppleCertificate@2
displayName: "Set Xcode Signing Certificate"
condition: eq(variables['Agent.OS'], 'Darwin') # Only run this step on macOS
inputs:
certSecureFile: 'Certificate.p12'
certPwd: '$(APPLECERTIFICATEPASSWORD)'
- task: InstallAppleProvisioningProfile@1
displayName: "Set Xcode Provisioning Profile"
condition: eq(variables['Agent.OS'], 'Darwin') # Only run this step on macOS
inputs:
provisioningProfileLocation: 'secureFiles'
provProfileSecureFile: 'GitTrends_Development_Profile.mobileprovision'
- task: UseDotNet@2
displayName: "Install Latest .NET SDK"
inputs:
packageType: "sdk"
version: "$(NET_VERSION)"
- task: CmdLine@2
displayName: "Install Latest .NET MAUI Workload"
inputs:
script: "dotnet workload install maui"
- task: CmdLine@2
displayName: "Inject API Keys"
inputs:
script: |
set -e
AzureConstantsFile=`find . -name AzureConstants.cs | head -1`
echo AzureConstantsFile = $AzureConstantsFile
sed -i '' "s/GetTestTokenApiKey = \"\"/GetTestTokenApiKey = \"$(GETTESTTOKENAPIKEY)\"/g" "$AzureConstantsFile"
sed -i '' "s/GetAppCenterApiKeysKey = \"\"/GetAppCenterApiKeysKey = \"$(GETAPPCENTERAPIKEYSKEY)\"/g" "$AzureConstantsFile"
sed -i '' "s/GetSyncFusionInformationApiKey = \"\"/GetSyncFusionInformationApiKey = \"$(GETSYNCFUSIONINFORMATIONAPIKEY)\"/g" "$AzureConstantsFile"
sed -i '' "s/GetNotificationHubInformationApiKey = \"\"/GetNotificationHubInformationApiKey = \"$(GETNOTIFICATIONHUBINFORMATIONAPIKEY)\"/g" "$AzureConstantsFile"
sed -i '' "s/#error Missing API Keys/\/\/#error Missing API Keys/g" "$AzureConstantsFile"
- task: CmdLine@2
displayName: "Run Unit Tests"
env:
VSTEST_TESTHOST_SHUTDOWN_TIMEOUT: 1100 # Fixes "The active test run was aborted. Reason: Test host process crashed" (source: https://github.com/microsoft/vstest/issues/2952#issuecomment-2234253765)
inputs:
script: "dotnet test $(PathToUnitTestsCsproj) -c Release -d detailed"