I have a pipeline to connect with databricks & run the databricks notebooks under databricks github repo for unit testing using pytest library. So, Pytest command should execute the notebooks to generate the test results & code coverage.
My pipeline was running on a self-hosted agent pool where docker containers are working on the execution. I have installed pre necessary software's & libraries with the docker image and deployed on top of containers.
Below are the exact lines written on YML file,
- script: | pip install pytest pytest-azurepipelines pytest-cov opencensus opencensus-ext-azure pip install -U databricks-connect==9.1.* pip install databricks-cli
apt-get update && apt-get install -y junit cobertura export DATABRICKS_HOST=$(Databricks_URL) export DATABRICKS_TOKEN=$(Databricks_Temp_Token) export DATABRICKS_CLUSTER_ID=$(DATABRICKS_CLUSTER_ID) export DATABRICKS_ORG_ID=$(DATABRICKS_ORG_ID) displayName: 'Load Python dependencies' - checkout: self
persistCredentials: true
clean: true
- script: | python -m pytest --junit-xml=$(Build.SourcesDirectory)/logs/TEST-LOCAL.xml --report-dir=$(Build.SourcesDirectory)/logs/ --cov=$(Build.SourcesDirectory)/tests/ --cov-report=html:$(Build.SourcesDirectory)/logs/ $(Build.SourcesDirectory)/tests/test_*.py --no-coverage-upload
- task: PublishCodeCoverageResults@1 inputs: codeCoverageTool: 'Cobertura' summaryFileLocation: '$(Build.SourcesDirectory)/coverage.xml' reportDirectory: '$(Build.SourcesDirectory)/logs/'
- task: PublishTestResults@2 inputs: testResultsFormat: 'JUnit' testResultsFiles: '**/TEST-LOCAL.xml' publishRunAttachments: true failTaskOnFailedTests: true
If I run the Pytest command without --no-coverage-upload option, MS agent doesn't throw any error. It was generated code coverage with proper styling. But with self hosted agent, it throws below error,
##[error]Unable to process command '##vso[codecoverage.publish codecoveragetool=Cobertura;summaryfile=/agent_works/ado_agent_wrk-nYQREz/ado_agent_wrk-nYQuVz/1/s/coverage.xml;reportdirectory=/agent_works/ado_agent_wrk-nYQREz/ado_agent_wrk-nYQREz/1/s/logs;]' successfully. Please reference documentation (http://go.microsoft.com/fwlink/?LinkId=817296)
##[error]File '/agent_works/ado_agent_wrk-nYQREz/ado_agent_wrk-nYQREz/1/s/coverage.xml' does not exist or is not accessible.
So, I have added --no-coverage-upload option to resolve the above issue. But once pytest generated the code coverage report successfully (with index.html, style.css, everything), it is not getting loaded with proper styling even though i pointed correct report directory location while publish code coverage. It looks like below,
I am bit confused what needs to be done from self hosted agent side since it's working fine on MS agents? I hope avoiding --no-coverage-upload will fix this issue. But avoid that will make an issue as i mentioned.
Is Azure blocking the CSS generated by pytest on source repository ? Is --no-coverage-upload required for self-hosted agent to generate code coverage report ? Why CSS is not getting reflected in coverage report even i can able to view the css through yml scripts ? How to overcome this css broken issue ?
@admin