Skip to content

Commit

Permalink
PrGate.yml: Add support for publishing code coverage results (#16)
Browse files Browse the repository at this point in the history
Introduces a new parameter called "extra_build_args" that can be used
to specify additional flags to pass to build commands.

This is used to pass flags needed to generate code coverage results
in this change.

The coverage.xml and coverage.html files added to the log copy step
will not have an impact if code coverage is not enabled.

For now, the code coverage publication step depends on the platform
setting "CODE_COVERAGE=TRUE" in the "extra_build_args" parameter.

This can be refactored/generalized as needed in the future.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
  • Loading branch information
makubacki authored Oct 21, 2022
1 parent 91d42b2 commit 8a29ea6
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions Steps/PrGate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ parameters:
displayName: Perform Stuart PR Evaluation
type: boolean
default: true
- name: extra_build_args
displayName: Extra Build Command Arguments
type: string
default: ''
- name: extra_install_step
displayName: Extra Install Steps
type: stepList
Expand Down Expand Up @@ -117,15 +121,15 @@ steps:
displayName: Build and Test ${{ parameters.build_pkgs }} ${{ parameters.build_archs}}
inputs:
filename: stuart_build
arguments: -c ${{ parameters.build_file }} -p $(pkgs_to_build) -t ${{ parameters.build_targets}} -a ${{ parameters.build_archs}} TOOL_CHAIN_TAG=${{ parameters.tool_chain_tag}}
arguments: -c ${{ parameters.build_file }} -p $(pkgs_to_build) -t ${{ parameters.build_targets}} -a ${{ parameters.build_archs}} TOOL_CHAIN_TAG=${{ parameters.tool_chain_tag}} ${{ parameters.extra_build_args}}
condition: and(gt(variables.pkg_count, 0), succeeded())

- ${{ if eq(parameters.do_ci_build, true) }}:
- task: CmdLine@1
displayName: CI Build and Test ${{ parameters.build_pkgs }} ${{ parameters.build_archs}}
inputs:
filename: stuart_ci_build
arguments: -c ${{ parameters.build_file }} -p $(pkgs_to_build) -t ${{ parameters.build_targets}} -a ${{ parameters.build_archs}} TOOL_CHAIN_TAG=${{ parameters.tool_chain_tag}}
arguments: -c ${{ parameters.build_file }} -p $(pkgs_to_build) -t ${{ parameters.build_targets}} -a ${{ parameters.build_archs}} TOOL_CHAIN_TAG=${{ parameters.tool_chain_tag}} ${{ parameters.extra_build_args}}
condition: and(gt(variables.pkg_count, 0), succeeded())

# Publish Test Results to Azure Pipelines/TFS
Expand Down Expand Up @@ -170,6 +174,8 @@ steps:
TestSuites.xml
**/BUILD_TOOLS_REPORT.html
**/OVERRIDELOG.TXT
coverage.xml
coverage.html
flattenFolders: true
condition: succeededOrFailed()

Expand All @@ -181,3 +187,11 @@ steps:
pathtoPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: 'Build Logs $(System.JobName)'
condition: succeededOrFailed()

- task: PublishCodeCoverageResults@1
displayName: Publish Code Coverage Results
inputs:
codeCoverageTool: 'Cobertura'
summaryFileLocation: 'Build/coverage.xml'
pathToSources: '$(Build.SourcesDirectory)'
condition: and(succeededOrFailed(), and(gt(variables.pkg_count, 0), contains('${{ parameters.extra_build_args }}', 'CODE_COVERAGE=TRUE')))

0 comments on commit 8a29ea6

Please # to comment.