From 6b342337cff736d18b7d2b473e9ecda6e14ec9aa Mon Sep 17 00:00:00 2001 From: Doug Bunting <6431421+dougbu@users.noreply.github.com> Date: Mon, 21 Nov 2022 16:23:13 -0800 Subject: [PATCH] !fixup! Update pipeline configuration - run tests only in Release job by default - do component governance work only in Release job - do not inject CodeQL3000 tasks (when building main) - shorten artifact names (remove 'Build ') - publish test results - clean workspace when checking out the repo --- azure-pipelines.yml | 52 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 11 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 60bdde75e..907eb0cfc 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -1,16 +1,22 @@ parameters: -- name: BuildTarget - displayName: Build which target? + # 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: - # Build variables -- name: _BuildConfig - value: Release - 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: ['*'] @@ -20,7 +26,7 @@ jobs: displayName: Build pool: ${{ if eq(variables['System.TeamProject'], 'public') }}: - name: NetCore-Svc-Public + name: NetCore-Public demands: ImageOverride -equals windows.vs2017.amd64.open ${{ else }}: name: NetCore1ESPool-Internal @@ -30,34 +36,58 @@ jobs: 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 ${{ parameters.BuildTarget }} /p:Desktop=false /p:BuildPortable=true ^ + - 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 displayName: Windows Build - - ${{ if ne(parameters.BuildTarget, 'Build') }}: + - ${{ if ne('$(_BuildTarget)', 'Build') }}: - publish: ./bin/$(_Configuration)/Test/TestResults/ - artifact: $(Agent.JobName) Test Results + artifact: $(_Configuration) Test Results condition: always() continueOnError: true displayName: Upload test results + - task: PublishTestResults@2 + condition: always() + continueOnError: true + displayName: Publish test results + inputs: + configuration: $(_Configuration) + mergeTestResults: true + searchFolder: ./bin/$(_Configuration)/Test/TestResults/ + testResultsFiles: '*.xml' + testRunner: xUnit + - publish: ./artifacts/ - artifact: $(Agent.JobName) Logs + artifact: $(_Configuration) Logs condition: always() displayName: Upload logs