]> git.proxmox.com Git - mirror_edk2.git/commitdiff
.azurepipelines: Install code coverage tool
authorGua Guo <gua.guo@intel.com>
Tue, 8 Nov 2022 08:38:49 +0000 (16:38 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Wed, 4 Jan 2023 02:06:01 +0000 (02:06 +0000)
For Windows add below tool for code coverage
1. OpenCppCoverage: parsing pdb file to generate coverage
data
2. pycobertura: show up html format data for coverage data

For Linux add below tool for code coverage
1. lcov: parsing gcda gcno file to generate coverage data
2. lcov-cobertura: convert coverage data to cobertura format
3. pycobertura: show up html format data for coverage data

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Michael Kubacki <michael.kubacki@microsoft.com>
Signed-off-by: Gua Guo <gua.guo@intel.com>
.azurepipelines/Ubuntu-GCC5.yml
.azurepipelines/Windows-VS2019.yml
.azurepipelines/templates/pr-gate-build-job.yml
.azurepipelines/templates/pr-gate-steps.yml
pip-requirements.txt

index 1acd8d2a46a736b692e8bb1c8201a54956a49e4e..f83951eeaf8614ea2b9a86b1c7d08190bcc5b4bf 100644 (file)
@@ -19,4 +19,7 @@ jobs:
     tool_chain_tag: 'GCC5'\r
     vm_image: 'ubuntu-latest'\r
     arch_list: "IA32,X64,ARM,AARCH64,RISCV64,LOONGARCH64"\r
-\r
+    extra_install_step:\r
+    - bash: sudo apt-get install -y lcov\r
+      displayName: Install Code Coverage Tools\r
+      condition: and(gt(variables.pkg_count, 0), succeeded())\r
index e4bd4b1d22839c39979ad91562f80473143eb38b..c07e5bb43424997602573361674dff74b58e753a 100644 (file)
@@ -18,3 +18,8 @@ jobs:
     tool_chain_tag: 'VS2019'\r
     vm_image: 'windows-2019'\r
     arch_list: "IA32,X64"\r
+    extra_install_step:\r
+    - powershell: choco install opencppcoverage; Write-Host "##vso[task.prependpath]C:\Program Files\OpenCppCoverage"\r
+      displayName: Install Code Coverage Tool\r
+      condition: and(gt(variables.pkg_count, 0), succeeded())\r
+\r
index 7f88b41dc8d3e2147431ed6b04d5d1e0ae4f0fb3..840852b606746ad894cc7edb73303868efd33dcb 100644 (file)
@@ -12,6 +12,7 @@ parameters:
   tool_chain_tag: ''\r
   vm_image: ''\r
   arch_list: ''\r
+  extra_install_step: []\r
 \r
 # Build step\r
 jobs:\r
@@ -77,3 +78,38 @@ jobs:
       build_pkgs: $(Build.Pkgs)\r
       build_targets: $(Build.Targets)\r
       build_archs: ${{ parameters.arch_list }}\r
+      extra_install_step: ${{ parameters.extra_install_step }}\r
+\r
+- job: Build_${{ parameters.tool_chain_tag }}_TARGET_CODE_COVERAGE\r
+  dependsOn: Build_${{ parameters.tool_chain_tag }}\r
+  workspace:\r
+    clean: all\r
+\r
+  pool:\r
+    vmImage: 'windows-2019'\r
+\r
+  steps:\r
+    - checkout: self\r
+      clean: true\r
+      fetchDepth: 1\r
+      submodules: true\r
+\r
+    - task: DownloadPipelineArtifact@2\r
+      displayName: 'Download Build Artifacts'\r
+      inputs:\r
+        buildType: 'current'\r
+        targetPath: '$(Build.ArtifactStagingDirectory)'\r
+\r
+    - task: CmdLine@2\r
+      displayName: Create code coverage report\r
+      inputs:\r
+        script: |\r
+          dotnet tool install -g dotnet-reportgenerator-globaltool\r
+          reportgenerator -reports:$(Build.ArtifactStagingDirectory)/**/coverage.xml -targetdir:$(Build.ArtifactStagingDirectory)/Coverage -reporttypes:Cobertura -filefilters:-*Build*;-*UnitTest*;-*Mock*;-*usr*\r
+\r
+    - task: PublishCodeCoverageResults@1\r
+      displayName: 'Publish code coverage'\r
+      inputs:\r
+        codeCoverageTool: Cobertura\r
+        summaryFileLocation: '$(Build.ArtifactStagingDirectory)/Coverage/Cobertura.xml'\r
+\r
index cb431e53fcd10b8088f41585f1d9e738b4b96654..080f60aea6ab949fb0b883542b14a6600730dfc4 100644 (file)
@@ -12,6 +12,7 @@ parameters:
   build_pkgs: ''\r
   build_targets: ''\r
   build_archs: ''\r
+  extra_install_step: []\r
 \r
 steps:\r
 - checkout: self\r
@@ -37,6 +38,8 @@ steps:
   displayName: fetch target branch\r
   condition: eq(variables['Build.Reason'], 'PullRequest')\r
 \r
+- ${{ parameters.extra_install_step }}\r
+\r
 # trim the package list if this is a PR\r
 - task: CmdLine@1\r
   displayName: Check if ${{ parameters.build_pkgs }} need testing\r
@@ -125,6 +128,7 @@ steps:
       TestSuites.xml\r
       **/BUILD_TOOLS_REPORT.html\r
       **/OVERRIDELOG.TXT\r
+      coverage.xml\r
     flattenFolders: true\r
   condition: succeededOrFailed()\r
 \r
index be8c7a1c37e68f235c2cb2b9444200bd529c2e6e..4ffcadddd8cf42c3b03d04e1a712c93005d4fa9e 100644 (file)
@@ -16,3 +16,5 @@ edk2-pytool-library==0.12.1
 edk2-pytool-extensions~=0.20.0\r
 edk2-basetools==0.1.39\r
 antlr4-python3-runtime==4.7.1\r
+lcov-cobertura==2.0.2\r
+\r