CI: Add x86_64 Clang Coverage pipeline in Azure

Add a job to the Azure pipelines to run tests with coverage enabled, and
aggregate the test results in a folder of html pages showing the
coverage results overall, and per-file.

Future work is needed to take the published pipeline artifact for the
coverage results and display them somewhere interesting.
This commit is contained in:
Andrew Kaster 2022-03-19 16:42:54 -06:00 committed by Andreas Kling
parent 3e32fb911e
commit 44bcd7c7aa
3 changed files with 50 additions and 3 deletions

View file

@ -2,6 +2,7 @@ parameters:
os: 'Linux'
arch: 'i686'
toolchain: 'gcc'
coverage: 'OFF'
build_directory: ''
ccache_version: 1 # Increment this number if CI has trouble with ccache.
serenity_ccache_path: ''
@ -45,9 +46,9 @@ steps:
- ${{ if ne(parameters.serenity_ccache_path, '') }}:
- task: Cache@2
inputs:
key: '"ccache" | "${{ parameters.os }}" | "${{ parameters.arch }}" | "${{ parameters.toolchain }}" | "${{ parameters.ccache_version }}" | "$(timestamp)"'
key: '"ccache" | "${{ parameters.os }}" | "${{ parameters.arch }}" | "${{ parameters.toolchain }}" | "${{ parameters.coverage }}" | "${{ parameters.ccache_version }}" | "$(timestamp)"'
restoreKeys: |
"ccache" | "${{ parameters.os }}" | "${{ parameters.arch }}" | "${{ parameters.toolchain }}" | "${{ parameters.ccache_version }}"
"ccache" | "${{ parameters.os }}" | "${{ parameters.arch }}" | "${{ parameters.toolchain }}" | "${{ parameters.coverage }}" | "${{ parameters.ccache_version }}"
path: ${{ parameters.serenity_ccache_path }}
displayName: 'Serenity Compiler Cache'

View file

@ -1,8 +1,9 @@
parameters:
arch: 'i686'
coverage: 'OFF'
jobs:
- job: 'Serenity_Clang_${{ parameters.arch }}'
- job: 'Serenity_Clang_${{ parameters.arch }}_Coverage_${{ parameters.coverage }}'
timeoutInMinutes: 0 # Setting to 0 means the maximum allowed timeout is used.
variables:
@ -24,6 +25,7 @@ jobs:
- template: Caches.yml
parameters:
arch: '${{ parameters.arch }}'
coverage: '${{ parameters.coverage }}'
toolchain: 'clang'
build_directory: 'Build/${{ parameters.arch }}clang'
toolchain_ccache_path: '$(LLVM_CCACHE_DIR)'
@ -44,6 +46,7 @@ jobs:
-DSERENITY_ARCH=${{ parameters.arch }} \
-DSERENITY_TOOLCHAIN=Clang \
-DENABLE_UNDEFINED_SANITIZER=ON \
-DENABLE_USERSPACE_COVERAGE_COLLECTION=${{ parameters.coverage }} \
-DENABLE_PCI_IDS_DOWNLOAD=OFF \
-DENABLE_USB_IDS_DOWNLOAD=OFF \
-DCMAKE_C_COMPILER=gcc-11 \
@ -81,6 +84,7 @@ jobs:
echo "##[error]:^( Tests failed, failing job"
exit 1
fi
sudo umount fsmount
displayName: 'Test'
workingDirectory: $(Build.SourcesDirectory)/Build/${{ parameters.arch }}clang
timeoutInMinutes: 60
@ -95,6 +99,27 @@ jobs:
workingDirectory: $(Build.SourcesDirectory)/Build/${{ parameters.arch }}clang
condition: failed()
- ${{ if eq(parameters.coverage, 'ON') }}:
- script: |
./Meta/analyze-qemu-coverage.sh
displayName: 'Aggregate Coverage Results'
workingDirectory: $(Build.SourcesDirectory)
env:
SERENITY_TOOLCHAIN: Clang
SERENITY_ARCH: ${{ parameters.arch }}
# FIXME: Deploy the static html pages somewhere
# FIXME: Alter script to also (instead?) produce a raw coverage.txt file for ingestion into sonar cloud
# Note: tmp_profile_data/Coverage.profdata has the entire combined profile data, but creating the raw txt requires
# all of the instrumented binaries and the profdata file.
- ${{ if eq(parameters.coverage, 'ON') }}:
- task: PublishPipelineArtifact@1
inputs:
targetPath: $(Build.SourcesDirectory)/Build/${{ parameters.arch }}clang/reports
artifactType: 'pipeline'
artifactName: 'Coverage'
- script: |
echo "##[section]Toolchain Cache"
CCACHE_DIR='$(LLVM_CCACHE_DIR)' ccache -s

View file

@ -0,0 +1,21 @@
# Pipeline definition for nightly or other scheduled jobs we don't want to run on every PR in Azure
schedules:
- cron: "0 0 * * *"
displayName: Daily midnight build
branches:
include:
- master
stages:
- stage: Toolchain
dependsOn: []
jobs:
- template: Meta/Azure/Toolchain.yml
- stage: SerenityOS (Coverage)
dependsOn: Toolchain
jobs:
- template: Meta/Azure/Serenity.yml
parameters:
arch: 'x86_64'
coverage: 'ON'