Skip to content

Commit

Permalink
CodeCoverage pipeline for submission to onefuzz. (#4177)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryfu-msft authored Feb 21, 2024
1 parent ecc2314 commit d82566e
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/actions/spelling/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Atest
ATL
AUrl
Authenticode
azcopy
azurewebsites
bcp
BEFACEF
Expand Down Expand Up @@ -66,6 +67,7 @@ CLOSEAPP
cloudapp
clsctx
clsid
cobertura
CODEOWNERS
COINIT
COMGLB
Expand Down Expand Up @@ -388,6 +390,7 @@ runtimeclass
ryfu
rzkzqaqjwj
SARL
SASURL
schematab
sddl
SECUREFILEPATH
Expand Down
70 changes: 70 additions & 0 deletions azure-pipelines.coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Code coverage pipeline required by OneFuzz
pr: none
trigger: none

pool:
vmImage: windows-latest

parameters:
- name: sasUrl
type: string
displayName: SAS URL
- name: branch
type: string
displayName: Branch
- name: jobID
type: string
displayName: OneFuzz Job ID
- name: buildDate
type: string
displayName: Build Date
- name: commitID
type: string
displayName: Commit ID

variables:
- name: coverage-file
value: cobertura-coverage.xml
- name: job-ID
value: ${{ parameters.jobID }}
- name: build-date
value: ${{ parameters.buildDate }}
- name: branch
value: ${{ parameters.branch }}
- name: sas-url
value: ${{ parameters.sasUrl }}
- name: commit-ID
value: ${{ parameters.commitID }}

jobs:
- job: prod
displayName: Prod Task
steps:
# Get source code
- script: |
git clone https://github.com/microsoft/winget-cli.git
git checkout $(commit-ID)
displayName: 'Clone winget-cli'
# Get code coverage from OneFuzz for the job
- powershell: |
Write-Host "Job ID: $(job-ID), Build Date: $(build-date), Branch: $(branch)"
$SASUrl = [System.Uri]::new("$(sas-url)")
azcopy cp $SASUrl.AbsoluteUri ./ --recursive
$ContainerName = $SASURL.LocalPath.Split("/")[1]
Write-Host "##vso[task.setvariable variable=container-name;]$ContainerName"
cd $ContainerName
$size = ((Get-Item .\$(coverage-file)).length)
if ($size -eq 0) {
Write-Host "Cobertura coverage XML is empty."
exit 1
}
displayName: PowerShell script to get coverage
# Use Cobertura report generator
- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: 'Cobertura'
summaryFileLocation: ./$(container-name)\$(coverage-file)
pathToSources: $(System.DefaultWorkingDirectory)
displayName: Built in ADO Task that uses ReportGenerator
1 change: 1 addition & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -592,3 +592,4 @@ jobs:
onefuzzDropDirectory: '$(buildOutDir)\WinGetYamlFuzzing'
onefuzzDropPAT: $(onefuzzDropPAT)
onefuzzFilingBugPAT: $(onefuzzBugFilingPAT)
onefuzzCodeCoveragePAT: $(onefuzzCodeCoveragePAT)
5 changes: 5 additions & 0 deletions src/WinGetYamlFuzzing/OneFuzzConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
"AssignedTo": "ryfu@microsoft.com",
"AreaPath": "OS\\Windows Client and Services\\ADEPT\\E4D-Engineered for Developers\\InstaDev",
"IterationPath": "OS"
},
"codeCoverage": {
"org": "ms",
"project": "winget-cli",
"pipelineId": "Pipeline ID"
}
}
]
Expand Down

0 comments on commit d82566e

Please sign in to comment.