Azure-pipelines-tasks: Publish Code Coverage Results task need access to source

Created on 16 Oct 2019  路  5Comments  路  Source: microsoft/azure-pipelines-tasks

See
image

Type: Unknown (see below)
Task Name: PublishCodeCoverageResults@1
## Environment

  • Server - Azure Pipelines
  • Agent - Hosted

Issue Description

We build our code, run tests and generate coverage with coverlet, in a Docker container.
So Cobertura files are generated inside Docker container, then taken out, and finally content is passed to PublishCodeCoverageResults@1.
This means that at the time Cobertura coverage xml file is used by PublishCodeCoverageResults@1 task, source code location has changed. See the warnings in task screenshot "File XXX does not exist (any more)."
In the Docker container it was /app/src/ while outside it is app/src.
The task doesn't seem to be able to relink to these paths even though we provide 'pathToSources'.
See task configuration:

- task: PublishCodeCoverageResults@1
  inputs:
    codeCoverageTool: Cobertura
    summaryFileLocation: 'app/testout/Cobertura.xml'
    reportDirectory: 'app/testout/'
    failIfCoverageEmpty: true
    pathToSources: 'app/src'

This means code coverage will get uploaded to ADO but we cannot browse files, which is really not the best. See:
image

Is there anything we can do? Right now it's really not the best.

Test triage

Most helpful comment

@molinch we have made the fix. It should be available in 2-3 days once it is deployed.

All 5 comments

@molinch - Just wanted to confirm if path is app/src or app/testout . In the description , you mentioned it to be app/src and in the task configuration , path to sources is app/testout.

@Anshi92 initial path in Docker was /app/src, outside path is app/src.
There was a typo in the yaml I pasted here, I changed accordingly:
```yaml
pathToSources: 'app/src'
````

I've been running a bash script to convert the paths from docker absolute paths (eg /src/file.cs) to relative (eg ./file.cs) and then it works:

# convert absolute docker paths to relative paths
find -name "coverage.cobertura.xml" -print | xargs sed -i 's/\/src/\./g'
find -name "TestResults.xml" -print | xargs sed -i 's/\/src/\./g'

@molinch we have made the fix. It should be available in 2-3 days once it is deployed.

Thanks @anshii03 it works as a charm now

Was this page helpful?
0 / 5 - 0 ratings

Related issues

timfish picture timfish  路  3Comments

divyesh-parikh picture divyesh-parikh  路  3Comments

alexszilagyi picture alexszilagyi  路  3Comments

gregpakes picture gregpakes  路  3Comments

ThomasBarnekow picture ThomasBarnekow  路  3Comments