@@ -34,339 +34,30 @@ resources:
3434 name : nanoframework/nf-tools
3535 endpoint : nanoframework
3636
37- jobs :
38-
39- # #############################
40- - job : Check_Build_Options
41- pool :
42- vmImage : ' windows-latest'
43-
44- steps :
45-
46- - checkout : self
47-
48- # check what changed
49- - powershell : |
50- git config --global user.email "nfbot"
51- git config --global user.name "[email protected] " 52-
53-
54- $auth = "basic $([System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes(":$(GitHubToken)"))))"
55-
56- if($env:System_PullRequest_PullRequestId -ne $null)
57- {
58- # get files changed in PR, if this is a PR
59- $commit = Invoke-RestMethod -Uri "https://api.github.com/repos/$env:Build_Repository_Name/pulls/$env:System_PullRequest_PullRequestNumber/files" -Header @{"Authorization"="$auth"} -ContentType "application/json" -Method GET
60-
61- # filter removed files
62- $files = $commit.where{$_.status -ne 'removed'}
63- }
64- else
65- {
66- # get files changed in the commit, if this is NOT a PR
67- $commit = Invoke-RestMethod -Uri "https://api.github.com/repos/$env:Build_Repository_Name/commits/$(Build.SourceVersion)" -Header @{"Authorization"="$auth"} -ContentType "application/json" -Method GET
68-
69- # filter removed files
70- $files = $commit.files.where{$_.status -ne 'removed'}
71- }
72-
73- # get file names only
74- $files = $files | % {$_.filename}
75-
76- Write-host "Files changed:"
77- $files | % { Write-host $_ }
78- Write-host ""
79-
80- # set default values
81- echo "##vso[task.setvariable variable=BUILD_NANO_LIB;isOutput=true]false"
82- echo "##vso[task.setvariable variable=BUILD_HELPER;isOutput=true]false"
83-
84- if( (($files.where{$_.Contains('nanoFramework.Serialization.Helper')}).Count -gt 0) -or (($files.where{$_.Contains('Serialization.Shared')}).Count -gt 0) -or (($files.where{$_.Contains('Tests/HelperTests')}).Count -gt 0) -or (($files.where{$_.Contains('Tests/UnitTests.Shared')}).Count -gt 0))
85- {
86- # files at nanoFramework.Serialization.Helper or shared folder
87- echo "##vso[task.setvariable variable=BUILD_HELPER;isOutput=true]true"
88-
89- Write-host "Building Helper Library "
90- }
91-
92- if( (($files.where{$_.Contains('nanoFramework.System.Runtime.Serialization')}).Count -gt 0) -or (($files.where{$_.Contains('Serialization.Shared')}).Count -gt 0) -or (($files.where{$_.Contains('Tests/SerializationTests')}).Count -gt 0) -or (($files.where{$_.Contains('Tests/UnitTests.Shared')}).Count -gt 0))
93- {
94- # files at class lib or shared folder
95- echo "##vso[task.setvariable variable=BUILD_NANO_LIB;isOutput=true]true"
96-
97- Write-host "Building nano Library"
98- }
99- name: TargetsToBuild
100- displayName: Check what to build
101- condition: >-
102- and(
103- eq(variables['BUILD_HELPER__'], 'false'),
104- eq(variables['BUILD_NANO_LIB__'], 'false')
105- )
106-
107- # #############
108- - job : Build_Helper
109- condition : >-
110- or(
111- eq(dependencies.Check_Build_Options.outputs['TargetsToBuild.BUILD_HELPER'], true),
112- eq(variables['BUILD_HELPER__'], 'true')
113- )
114- dependsOn :
115- Check_Build_Options
116-
117- pool :
118- vmImage : ' windows-latest'
119-
120- variables :
121- DOTNET_NOLOGO : true
122- BuildPlatform : ' Any CPU'
123- BuildConfiguration : ' Release'
124-
125- steps :
126-
127- - checkout : self
128-
129- - task : DotNetCoreCLI@2
130- displayName : Restore NuGet packages
131- condition : >-
132- and(
133- succeeded(),
134- not(startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))
135- )
136- inputs :
137- command : restore
138- verbosityRestore : minimal
139- projects : $(System.DefaultWorkingDirectory)/nanoFramework.Serialization.Helper.sln
140- feedsToUse : ' select'
141-
142- - task : SonarCloudPrepare@1
143- condition : >-
144- and(
145- succeeded(),
146- not(startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))
147- )
148- displayName : ' Prepare analysis on SonarCloud'
149- inputs :
150- SonarCloud : ' sonarcloud-$(System.TeamProject)'
151- organization : ' nanoframework'
152- scannerMode : ' MSBuild'
153- projectKey : ' nanoframework_System.Runtime.Serialization.Helper'
154- extraProperties : |
155- sonar.exclusions=**/obj/**,**/*.dll
156- sonar.cs.vscoveragexml.reportsPaths=$(Agent.TempDirectory)/**/**.coverage
157- sonar.cs.vstest.reportsPaths=$(Agent.TempDirectory)/**/**.trx
158-
159- - task : VSBuild@1
160- displayName : Build solution
161- condition : >-
162- and(
163- succeeded(),
164- not(startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))
165- )
166- inputs :
167- solution : $(System.DefaultWorkingDirectory)/nanoFramework.Serialization.Helper.sln
168- platform : ' $(BuildPlatform)'
169- configuration : ' $(BuildConfiguration)'
170- msbuildArgs : ' /p:PublicRelease=true'
171- maximumCpuCount : true
172-
173- - task : CopyFiles@1
174- condition : >-
175- and(
176- succeeded(),
177- not(startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))
178- )
179- displayName : Collecting deployable artifacts
180- inputs :
181- sourceFolder : $(System.DefaultWorkingDirectory)/nanoFramework.Serialization.Helper/bin/Release
182- Contents : |
183- *.nupkg
184- *.snupkg
185- TargetFolder : ' $(Build.ArtifactStagingDirectory)'
186- flattenFolders : true
187-
188- - task : VisualStudioTestPlatformInstaller@1
189- condition : >-
190- and(
191- succeeded(),
192- not(startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))
193- )
194- displayName : ' Visual Studio Test Platform Installer'
195- inputs :
196- versionSelector : latestStable
197-
198- - task : VSTest@2
199- condition : >-
200- and(
201- succeeded(),
202- not(startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))
203- )
204- displayName : ' Running Unit Tests'
205- continueOnError : false
206- inputs :
207- testSelector : ' testAssemblies'
208- testAssemblyVer2 : |
209- **\*Tests*.dll
210- !**\obj\**
211- searchFolder : ' $(System.DefaultWorkingDirectory)/Tests/HelperTests'
212- platform : ' $(BuildPlatform)'
213- configuration : ' $(BuildConfiguration)'
214- diagnosticsEnabled : true
215- vsTestVersion : toolsInstaller
216- codeCoverageEnabled : true
217- runSettingsFile : ' $(System.DefaultWorkingDirectory)/helper.runsettings'
218-
219- - task : SonarCloudAnalyze@1
220- condition : >-
221- and(
222- succeeded(),
223- not(startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))
224- )
225- displayName : ' Run Code Analysis'
226- continueOnError : true
227-
228- - task : SonarCloudPublish@1
229- condition : >-
230- and(
231- succeeded(),
232- not(startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))
233- )
234- displayName : ' Publish Quality Gate Result'
235- continueOnError : true
236-
237- - task : DotNetCoreCLI@2
238- displayName : Install SignTool tool
239- condition : >-
240- and(
241- succeeded(),
242- not(startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))
243- )
244- inputs :
245- command : custom
246- custom : tool
247- arguments : install --tool-path . SignClient
248-
249- - pwsh : |
250- .\SignClient "Sign" `
251- --baseDirectory "$(Build.ArtifactStagingDirectory)" `
252- --input "**/*.nupkg" `
253- --config "$(Build.Repository.LocalPath)\config\SignClient.json" `
254- --filelist "$(Build.Repository.LocalPath)\config\filelist.txt" `
255- --user "$(SignClientUser)" `
256- --secret '$(SignClientSecret)' `
257- --name "Binary Formatter Helper" `
258- --description "Binary Formatter Helper" `
259- --descriptionUrl "https://github.com/$env:Build_Repository_Name"
260- displayName: Sign packages
261- continueOnError: true
262- condition: >-
263- and(
264- succeeded(),
265- eq(variables['System.PullRequest.PullRequestId'], ''),
266- not(startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))
267- )
268-
269- - task : PublishBuildArtifacts@1
270- displayName : Publish deployables artifacts
271- condition : >-
272- and(
273- succeeded(),
274- eq(variables['System.PullRequest.PullRequestId'], ''),
275- not(startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))
276- )
277- inputs :
278- PathtoPublish : ' $(Build.ArtifactStagingDirectory)'
279- ArtifactName : deployables
280- ArtifactType : Container
281-
282- - task : NuGetCommand@2
283- condition : >-
284- and(
285- succeeded(),
286- eq(variables['System.PullRequest.PullRequestId'], ''),
287- not(startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))
288- )
289- continueOnError : true
290- displayName : Push NuGet packages to NuGet
291- inputs :
292- command : push
293- nuGetFeedType : external
294- allowPackageConflicts : true
295- packagesToPush : ' $(Build.ArtifactStagingDirectory)/*.nupkg'
296- includeSymbols : true
297- publishFeedCredentials : ' NuGet-$(System.TeamProject)'
298-
299- - task : GithubRelease@1
300- condition : >-
301- and(
302- succeeded(),
303- eq(variables['System.PullRequest.PullRequestId'], ''),
304- startsWith(variables['Build.SourceBranch'], 'refs/heads/main'),
305- not(contains(variables['Build.SourceBranch'], 'preview'))
306- )
307- displayName : Create/Update GitHub release
308- inputs :
309- action : edit
310- gitHubConnection : ' github.com_nano-$(System.TeamProject)'
311- tagSource : userSpecifiedTag
312- tag : v$(NBGV_NUGETPACKAGEVERSION)
313- title : ' .NET nanoFramework Binary Formatter Helper v$(NBGV_NUGETPACKAGEVERSION)'
314- assets : ' $(Build.ArtifactStagingDirectory)/*.nupkg'
315- isPreRelease : false
316- addChangeLog : true
317-
318- # #############
319- - job : Build_ClassLib
320- condition : >-
321- or(
322- eq(dependencies.Check_Build_Options.outputs['TargetsToBuild.BUILD_NANO_LIB'], true),
323- eq(variables['BUILD_NANO_LIB__'], 'true')
324- )
325- dependsOn :
326- Check_Build_Options
327-
328- pool :
329- vmImage : ' windows-latest'
330-
331- variables :
332- DOTNET_NOLOGO : true
333- solution : ' nanoFramework.System.Runtime.Serialization.sln'
334- buildPlatform : ' Any CPU'
335- buildConfiguration : ' Release'
336- nugetPackageName : ' nanoFramework.System.Runtime.Serialization'
337- nugetConfigPath : ' $(System.DefaultWorkingDirectory)/NuGet.Config'
338-
339- steps :
340-
341- # step from template @ nf-tools repo
342- # all build, update and publish steps
343- - template : azure-pipelines-templates/class-lib-build.yml@templates
344- parameters :
345- sonarCloudProject : ' nanoframework_System.Runtime.Serialization'
346-
347- # #################################
348- # report build failure to Discord
349- - job : Report_Build_Failure
350- dependsOn :
351- - Build_Helper
352- - Build_ClassLib
353- condition : >-
354- or(
355- failed('Build_Helper'),
356- failed('Build_ClassLib')
357- )
358-
359- pool :
360- vmImage : ' windows-latest'
361-
362- steps :
363-
364- - checkout : self
365- fetchDepth : 1
366-
367- # step from template @ nf-tools repo
368- - template : azure-pipelines-templates/discord-webhook.yml@templates
369- parameters :
370- status : ' failure'
371- webhookUrl : ' $(DiscordWebhook)'
372- message : ' '
37+ pool :
38+ vmImage : ' windows-latest'
39+
40+ variables :
41+ DOTNET_NOLOGO : true
42+ solution : ' nanoFramework.System.Runtime.Serialization.sln'
43+ buildPlatform : ' Any CPU'
44+ buildConfiguration : ' Release'
45+ nugetPackageName : ' nanoFramework.System.Runtime.Serialization'
46+
47+ steps :
48+
49+ # step from template @ nf-tools repo
50+ # all build, update and publish steps
51+ - template : azure-pipelines-templates/class-lib-build.yml@templates
52+ parameters :
53+ sonarCloudProject : ' nanoframework_System.Runtime.Serialization'
54+ runUnitTests : true
55+ unitTestRunsettings : ' $(System.DefaultWorkingDirectory)\.runsettings'
56+
57+ # step from template @ nf-tools repo
58+ # report error
59+ - template : azure-pipelines-templates/discord-webhook-task.yml@templates
60+ parameters :
61+ status : ' failure'
62+ webhookUrl : ' $(DiscordWebhook)'
63+ message : ' '
0 commit comments