diff --git a/.github/actions/spelling/expect.txt b/.github/actions/spelling/expect.txt index c65b3b7778..1ded03803c 100644 --- a/.github/actions/spelling/expect.txt +++ b/.github/actions/spelling/expect.txt @@ -34,6 +34,7 @@ Atest ATL AUrl Authenticode +azcopy azurewebsites bcp BEFACEF @@ -66,6 +67,7 @@ CLOSEAPP cloudapp clsctx clsid +cobertura CODEOWNERS COINIT COMGLB @@ -388,6 +390,7 @@ runtimeclass ryfu rzkzqaqjwj SARL +SASURL schematab sddl SECUREFILEPATH diff --git a/azure-pipelines.coverage.yml b/azure-pipelines.coverage.yml new file mode 100644 index 0000000000..8d94e1a4f3 --- /dev/null +++ b/azure-pipelines.coverage.yml @@ -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 \ No newline at end of file diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 2ec5faaded..9523f7376b 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -592,3 +592,4 @@ jobs: onefuzzDropDirectory: '$(buildOutDir)\WinGetYamlFuzzing' onefuzzDropPAT: $(onefuzzDropPAT) onefuzzFilingBugPAT: $(onefuzzBugFilingPAT) + onefuzzCodeCoveragePAT: $(onefuzzCodeCoveragePAT) diff --git a/src/WinGetYamlFuzzing/OneFuzzConfig.json b/src/WinGetYamlFuzzing/OneFuzzConfig.json index 6f45ba3ccf..a9f3c90f44 100644 --- a/src/WinGetYamlFuzzing/OneFuzzConfig.json +++ b/src/WinGetYamlFuzzing/OneFuzzConfig.json @@ -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" } } ]