From 36baaa08a6e2040cb459eef4ab5229985d595ea7 Mon Sep 17 00:00:00 2001 From: Doug Bunting <6431421+dougbu@users.noreply.github.com> Date: Mon, 21 Nov 2022 13:24:58 -0800 Subject: [PATCH 1/5] Enable public Azure DevOps builds - add azure-pipelines.yml - clean workspace when checking out the repo - build about the same matrix as we have on TeamCity in Main.Integration builds - run tests only in Release job by default - do component governance work only in Release job - do not inject CodeQL3000 tasks (when building main) - publish test results - change build.cmd to enable overrides of its command line parameters nits: - touch up .codeql.yml to avoid test code and include portable projects --- .codeql.yml | 3 +- azure-pipelines.yml | 92 +++++++++++++++++++++++++++++++++++++++++++++ build.cmd | 2 +- 3 files changed, 94 insertions(+), 3 deletions(-) create mode 100644 azure-pipelines.yml diff --git a/.codeql.yml b/.codeql.yml index 7ad4723f1..462a0be40 100644 --- a/.codeql.yml +++ b/.codeql.yml @@ -6,7 +6,6 @@ parameters: default: true variables: -- template: eng/common/templates/variables/pool-providers.yml # CG is handled in the primary CI pipeline - name: skipComponentGovernanceDetection value: true @@ -59,7 +58,7 @@ jobs: - script: .\build.cmd EnableSkipStrongNames displayName: Windows Build - EnableSkipStrongNames - - script: .\build.cmd + - script: .\build.cmd Build /p:BuildPortable=true /p:Desktop=false displayName: Windows Build - task: CodeQL3000Finalize@0 diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 000000000..07f7deb10 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,92 @@ +parameters: + # Test only the Release build by default. +- name: ReleaseBuildTarget + displayName: 'Build which target for Release?' + type: string + values: [ Build, Integration, UnitTest ] + default: UnitTest +- name: OtherBuildTarget + displayName: 'Build which target for Debug/CodeAnalysis?' + type: string + values: [ Build, Integration, UnitTest ] + default: Build + +variables: +- name: DOTNET_CLI_TELEMETRY_OPTOUT + value: 1 + # Run CodeQL3000 tasks in a separate internal pipeline; not needed here. +- name: Codeql.SkipTaskAutoInjection + value: true + +trigger: [main] +pr: ['*'] + +jobs: +- job: build + displayName: Build + pool: + ${{ if eq(variables['System.TeamProject'], 'public') }}: + name: NetCore-Public + demands: ImageOverride -equals windows.vs2017.amd64.open + ${{ else }}: + name: NetCore1ESPool-Internal + demands: ImageOverride -equals windows.vs2017.amd64 + timeoutInMinutes: 90 + + strategy: + matrix: + Release: + _BuildTarget: ${{ parameters.ReleaseBuildTarget }} + _Configuration: Release + _StyleCopEnabled: true + # Do CG work only in internal pipelines. + skipComponentGovernanceDetection: ${{ eq(variables['System.TeamProject'], 'public') }} + Debug: + _BuildTarget: ${{ parameters.OtherBuildTarget }} + _Configuration: Debug + _StyleCopEnabled: false + # Do not redo CG work. Configuration changes in this part of the matrix are not relevant to CG. + skipComponentGovernanceDetection: true + CodeAnalysis: + _BuildTarget: ${{ parameters.OtherBuildTarget }} + _Configuration: CodeAnalysis + _StyleCopEnabled: false + # Do not redo CG work. Configuration changes in this part of the matrix are not relevant to CG. + skipComponentGovernanceDetection: true + + steps: + - checkout: self + clean: true + displayName: Checkout + - task: UseDotNet@2 + displayName: Get .NET SDK + inputs: + useGlobalJson: true + + - script: .\build.cmd EnableSkipStrongNames + displayName: Windows Build - EnableSkipStrongNames + - script: .\build.cmd $(_BuildTarget) /p:Desktop=false /p:BuildPortable=true ^ + /binaryLogger:artifacts/msbuild.binlog /p:Configuration=$(_Configuration) /p:StyleCopEnabled=$(_StyleCopEnabled) ^ + /flp:LogFile=artifacts/msbuild.log;Verbosity=Normal + displayName: Windows Build + + - publish: ./bin/$(_Configuration)/Test/TestResults/ + artifact: $(_Configuration) Test Results + condition: and(always(), ne('$(_BuildTarget)', 'Build')) + continueOnError: true + displayName: Upload test results + - task: PublishTestResults@2 + condition: and(always(), ne('$(_BuildTarget)', 'Build')) + continueOnError: true + displayName: Publish test results + inputs: + configuration: $(_Configuration) + mergeTestResults: true + searchFolder: ./bin/$(_Configuration)/Test/TestResults/ + testResultsFiles: '*.xml' + testRunner: xUnit + + - publish: ./artifacts/ + artifact: $(_Configuration) Logs + condition: always() + displayName: Upload logs diff --git a/build.cmd b/build.cmd index 270103785..a5ca225d4 100644 --- a/build.cmd +++ b/build.cmd @@ -40,7 +40,7 @@ if exist "%InstallDir%\MSBuild\15.0\Bin\MSBuild.exe" ( if "%1" == "" goto BuildDefaults -%MSBuild% Runtime.msbuild /m /nr:false /t:%* /p:Platform="Any CPU" /p:Desktop=true /v:M /fl /flp:LogFile=bin\msbuild.log;Verbosity=Normal +%MSBuild% Runtime.msbuild /m /nr:false /p:Platform="Any CPU" /p:Desktop=true /v:M /fl /flp:LogFile=bin\msbuild.log;Verbosity=Normal /t:%* if %ERRORLEVEL% neq 0 goto BuildFail goto BuildSuccess From 84c5b4e050bb4ae2efe1a7de55d20f94f26c2801 Mon Sep 17 00:00:00 2001 From: Doug Bunting <6431421+dougbu@users.noreply.github.com> Date: Mon, 21 Nov 2022 17:10:15 -0800 Subject: [PATCH 2/5] !fixup! Correct test result conditions --- azure-pipelines.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 07f7deb10..cb108de3b 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -72,11 +72,11 @@ jobs: - publish: ./bin/$(_Configuration)/Test/TestResults/ artifact: $(_Configuration) Test Results - condition: and(always(), ne('$(_BuildTarget)', 'Build')) + condition: and(always(), ne(variables._BuildTarget, 'Build')) continueOnError: true displayName: Upload test results - task: PublishTestResults@2 - condition: and(always(), ne('$(_BuildTarget)', 'Build')) + condition: and(always(), ne(variables._BuildTarget, 'Build')) continueOnError: true displayName: Publish test results inputs: From b544db03b5b8482fe45da812c4da0c7b0d4e1c17 Mon Sep 17 00:00:00 2001 From: Doug Bunting <6431421+dougbu@users.noreply.github.com> Date: Mon, 21 Nov 2022 17:32:43 -0800 Subject: [PATCH 3/5] !fixup! Final fixes - reduce job timeout; jobs usually take less than 10 minutes - make test run title more readable / useful --- azure-pipelines.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index cb108de3b..afb96310c 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -31,7 +31,7 @@ jobs: ${{ else }}: name: NetCore1ESPool-Internal demands: ImageOverride -equals windows.vs2017.amd64 - timeoutInMinutes: 90 + timeoutInMinutes: 30 strategy: matrix: @@ -80,11 +80,11 @@ jobs: continueOnError: true displayName: Publish test results inputs: - configuration: $(_Configuration) mergeTestResults: true searchFolder: ./bin/$(_Configuration)/Test/TestResults/ testResultsFiles: '*.xml' testRunner: xUnit + testRunTitle: $(_Configuration) - publish: ./artifacts/ artifact: $(_Configuration) Logs From 8c0a384ea8331b4f85f63bf8346fc5a4bc5aa0eb Mon Sep 17 00:00:00 2001 From: Doug Bunting <6431421+dougbu@users.noreply.github.com> Date: Mon, 21 Nov 2022 17:47:55 -0800 Subject: [PATCH 4/5] !fixup! Shorten step names --- azure-pipelines.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index afb96310c..fb0a8791b 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -64,11 +64,11 @@ jobs: useGlobalJson: true - script: .\build.cmd EnableSkipStrongNames - displayName: Windows Build - EnableSkipStrongNames + displayName: Enable SkipStrongNames - script: .\build.cmd $(_BuildTarget) /p:Desktop=false /p:BuildPortable=true ^ /binaryLogger:artifacts/msbuild.binlog /p:Configuration=$(_Configuration) /p:StyleCopEnabled=$(_StyleCopEnabled) ^ /flp:LogFile=artifacts/msbuild.log;Verbosity=Normal - displayName: Windows Build + displayName: Build - publish: ./bin/$(_Configuration)/Test/TestResults/ artifact: $(_Configuration) Test Results From 3182dc90a366160bbf3e3d31403ec60394be26de Mon Sep 17 00:00:00 2001 From: Doug Bunting <6431421+dougbu@users.noreply.github.com> Date: Mon, 21 Nov 2022 18:21:59 -0800 Subject: [PATCH 5/5] !fixup! Reduce file logging verbosity --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index fb0a8791b..fea01ece8 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -67,7 +67,7 @@ jobs: displayName: Enable SkipStrongNames - script: .\build.cmd $(_BuildTarget) /p:Desktop=false /p:BuildPortable=true ^ /binaryLogger:artifacts/msbuild.binlog /p:Configuration=$(_Configuration) /p:StyleCopEnabled=$(_StyleCopEnabled) ^ - /flp:LogFile=artifacts/msbuild.log;Verbosity=Normal + /fileLoggerParameters:LogFile=artifacts/msbuild.log;Summary;Verbosity=minimal displayName: Build - publish: ./bin/$(_Configuration)/Test/TestResults/