-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathpackage-validation.yml
284 lines (235 loc) · 9.51 KB
/
package-validation.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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
parameters:
- name: arguments
type: string
default: ''
- name: unocheckArguments
type: string
default: ''
- name: xCodeRoot
type: string
default: ''
steps:
- checkout: self
clean: 'true'
- bash: |
# This list is based on what the base image contains and
# may need to be adjusted as new software gets installed.
# Use the `du` command below to determine what can be
# uninstalled.
rm -fR ~/.cargo
rm -fR ~/.rustup
rm -fR ~/.dotnet
sudo rm -fR /usr/share/swift
sudo rm -fR /opt/microsoft/msedge
sudo rm -fR /usr/local/.ghcup
sudo rm -fR /usr/lib/mono
sudo snap remove lxd
sudo snap remove core20
sudo apt remove snapd
df -h
# du -h -d 3 /
displayName: 'Cleanup unused image dependencies (Linux)'
condition: eq(variables['Agent.OS'], 'Linux')
- powershell: |
$templateArgs = '${{ parameters.arguments }}'
echo "TemplateArgs = '$templateArgs'"
$dotnetVersion = $env:TargetDotNetVersion
$ValidationUnoCheckVersion = $env:ValidationUnoCheckVersionNet8
if ($templateArgs -match 'net9.0')
{
$dotnetVersion = '9.0.100'
$ValidationUnoCheckVersion = $env:ValidationUnoCheckVersionNet9
}
echo "##vso[task.setvariable variable=DotNetVersion]$dotnetVersion"
echo "##vso[task.setvariable variable=ValidationUnoCheckVersion]$ValidationUnoCheckVersion"
displayName: Evaluate Template Args
env:
TargetDotNetVersion: $(ValidationDotNetVersion)
# Install android 34 as we're running on macos-15, early so that
# the JDK override does not break the installer
- bash: |
echo "y" | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --sdk_root=$ANDROID_HOME --install 'tools'| tr '\r' '\n' | uniq
echo "y" | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --sdk_root=$ANDROID_HOME --install 'platform-tools' | tr '\r' '\n' | uniq
echo "y" | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --sdk_root=$ANDROID_HOME --install 'platforms;android-34' | tr '\r' '\n' | uniq
echo "y" | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --sdk_root=$ANDROID_HOME --install 'build-tools;35.0.0' | tr '\r' '\n' | uniq
echo "y" | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --sdk_root=$ANDROID_HOME --install 'build-tools;34.0.0' | tr '\r' '\n' | uniq
displayName: Install Android 34
condition: eq(variables['Agent.OS'], 'Darwin')
- template: dotnet-install-windows.yml
parameters:
DotNetVersion: $(DotNetVersion)
- task: DownloadBuildArtifacts@0
inputs:
artifactName: $(Build.DefinitionName)
- pwsh: |
md $(Build.SourcesDirectory)/src/PackageCache
copy "$(System.ArtifactsDirectory)/$(Build.DefinitionName)/*.nupkg" $(Build.SourcesDirectory)/src/PackageCache
displayName: Copy Artifacts to PackageCache
- template: canary-updater.yml
parameters:
MergeBranch: false
- bash: |
sudo rm -fR /usr/lib/jvm
ubuntu_release=`lsb_release -rs`
wget https://packages.microsoft.com/config/ubuntu/${ubuntu_release}/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo apt-get install apt-transport-https
sudo apt-get update
sudo apt-get install -y msopenjdk-11
displayName: OpenJDK (Linux)
condition: eq(variables['Agent.OS'], 'Linux')
- powershell: |
& dotnet tool install --global Uno.Check --version $env:ValidationUnoCheckVersion
uno-check -v --ci --non-interactive --fix --skip androidemulator --skip dotnetnewunotemplates ${{ parameters.unocheckArguments }}
displayName: Uno Check (Linux)
condition: eq(variables['Agent.OS'], 'Linux')
env:
ValidationUnoCheckVersion: $(ValidationUnoCheckVersion)
JAVA_HOME: $(JAVA_HOME)
- powershell: |
& dotnet tool install --global Uno.Check --version $env:ValidationUnoCheckVersion
uno-check -v --ci --non-interactive --fix --skip androidemulator --skip androidsdk --skip gtk3 --skip xcode --skip vswin --skip vsmac --skip dotnetnewunotemplates ${{ parameters.unocheckArguments }}
displayName: Uno Check (macOS)
condition: eq(variables['Agent.OS'], 'Darwin')
env:
ValidationUnoCheckVersion: $(ValidationUnoCheckVersion)
JAVA_HOME: $(JAVA_HOME)
- bash: |
echo 'xCode Root to ${{parameters.xCodeRoot}}'
echo '##vso[task.setvariable variable=MD_APPLE_SDK_ROOT;]'${{parameters.xCodeRoot}}
sudo xcode-select --switch ${{parameters.xCodeRoot}}/Contents/Developer
condition: eq(variables['Agent.OS'], 'Darwin')
displayName: Select Xcode
- bash: |
brew install ninja
condition: eq(variables['Agent.OS'], 'Darwin')
displayName: Install ninja
- powershell: |
& dotnet tool install --global Uno.Check --version $env:ValidationUnoCheckVersion
uno-check -v --ci --non-interactive --fix --skip xcode --skip gtk3 --skip vswin --skip openjdk --skip androidemulator --skip androidsdk --skip vsmac --skip dotnetnewunotemplates ${{ parameters.unocheckArguments }}
displayName: Uno Check (Windows)
condition: eq(variables['Agent.OS'], 'Windows_NT')
env:
ValidationUnoCheckVersion: $(ValidationUnoCheckVersion)
- script: dotnet new install "$(System.ArtifactsDirectory)/$(Build.DefinitionName)/Uno.Templates*.nupkg"
displayName: Install Project Templates
- bash: |
find ~/.nuget -type f -name "*.nupkg" -exec rm {} \;
df -h
displayName: Cleanup nupkg from package cache
condition: eq(variables['Agent.OS'], 'Linux')
- pwsh: |
dotnet nuget add source -n nuget_local $(Build.SourcesDirectory)/src/PackageCache
dotnet nuget add source -n uno_dev "https://pkgs.dev.azure.com/uno-platform/1dd81cbd-cb35-41de-a570-b0df3571a196/_packaging/unoplatformdev/nuget/v3/index.json"
dotnet nuget add source -n net8 "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8/nuget/v3/index.json"
displayName: Setup nuget sources
- pwsh: |
#Set-PSDebug -Trace 1
$ErrorActionPreference = 'Stop'
# Escape quotes properly
$validationsArray = ('${{ replace(parameters.arguments, '""', '`""') }}' -split '\r?\n').Trim()
# write currently running dotnet version in a variable
$dotnetVersion = dotnet --version
echo "Running validations for:"
$validations=@{}
$buildFailures=@()
foreach($validation in $validationsArray)
{
# Skip commented out tests
if($validation.StartsWith('#'))
{
continue
}
$fields = ($validation -split ';').Trim()
if($fields[0])
{
$validations.Add($fields[0], @($fields[2],$fields[1]))
echo "- $($fields[0]), $($fields[2]) (Filter: $($fields[1]))"
}
}
$currentTest=0;
foreach($validation in $validations.Keys)
{
$testName = $validation;
$testParams = $validations[$validation][0];
$environmentFilter = $validations[$validation][1];
# Skip testing for the wrong environment
if($environmentFilter -eq "Windows" -and !$IsWindows)
{
echo "Skipping $testName ($testParams) because it's only for Windows"
continue
}
if($environmentFilter -eq "Linux" -and !$IsLinux)
{
echo "Skipping $testName ($testParams) because it's only for Linux"
continue
}
if ($testParams.Contains('net9.0') -and $IsWindows)
{
if($testName -eq "MauiBlank" -or $testName -eq "MauiRecommended" -or $testName -eq "Issue396")
{
echo "Skipping $testName ($testParams) on net9.0 Windows because of https://github.com/unoplatform/uno.csharpmarkup/issues/787"
continue
}
}
echo "Testing $testName ($testParams)"
# Set the progress to report on azdo UI
$progress = ($currentTest / $validations.Keys.Count) * 100;
echo "Progress: {$progress}"
echo "##vso[task.setprogress value=$progress;]$testName"
# Split the string containing parameters with respect for quotes, so parameters can be
# passed properly to the dotnet new command. (the string would be interpreted as a single parameter otherwise)
if($testParams)
{
$dotnetNewParams = ($testParams -replace "`n"," " -replace "`r"," ") -split ' (?=(?:[^"]|"[^"]*")*$)' | ForEach-Object { $_ -replace '"', '' } | Where-Object { -not [string]::IsNullOrWhiteSpace($_) }
}
else
{
# avoid passing an empty array
Remove-Variable -name dotnetNewParams -ErrorAction SilentlyContinue
}
# Create the app solution
& dotnet new unoapp -skip -o $testName $dotnetNewParams
if ($LASTEXITCODE -ne 0)
{
echo "Template creation failed for $testName"
$buildFailures += , "$testName";
}
else
{
# Build the app
pushd $testName
& dotnet build $testName.sln "/bl:$(System.ArtifactsDirectory)/$testName.$(Agent.OS).$dotnetVersion.binlog"
if ($LASTEXITCODE -ne 0)
{
echo "Build failed for $testName"
$buildFailures += , "$testName";
}
popd
# Clean the folder to continue testing with limited disk space
Remove-Item -Recurse -Force $testName -ErrorAction Continue
if ($IsLinux)
{
echo "Show disk usage"
& df -h
}
}
$currentTest = $currentTest + 1;
}
if($buildFailures.Length -gt 0)
{
echo "Validation failed for :"
foreach($buildFailure in $buildFailures)
{
echo "- $buildFailure"
}
throw "Exit code must be zero."
}
displayName: Test all scenarios
- task: PublishBuildArtifacts@1
condition: always()
retryCountOnTaskFailure: 3
inputs:
PathtoPublish: $(build.artifactstagingdirectory)
ArtifactName: logs
ArtifactType: Container