I’m setting up test coverage on a monorepo.
To do so, I’ve set up test coverage percentage with the
coverage property in all test-related jobs in gitlab-ci.yml.
I’ve also used the
coverage_report property to upload cobertura reports in order to show coverage visualization in the diff.
verify:serviceA: extends: - .verify script: - cd packages/serviceA - yarn test --coverage --coverageReporters cobertura text coverage: /All files[^|]*\|[^|]*\s+([\d\.]+)/ artifacts: reports: coverage_report: coverage_format: cobertura path: packages/serviceA/coverage/unit/cobertura-coverage.xml
As I am in a monorepo, there are multiple similar jobs like
Test jobs from service A are only triggered if changes were made on service A.
I can see the test coverage percentage in the MR but I’m encountering a few issues.
This is ok but I want to add a coverage check approval rule to ask for one more approver in MR if code coverage decreases.
Let’s say I have serviceA with 100% coverage and serviceB with 50% coverage.
If I make changes to both services, I’ll have 75% of coverage. But if in next pipeline I only make changes to serviceB, Gitlab will detect only a 50% coverage and will display a red -25% in the MR.
I’d rather test coverage to be compared to the same previous job because serviceA and serviceB are 2 different apps.
Are there any workarounds (without running every test job every time)?
There is no coverage history, I’m not sure if this is a bug or a misuse on my end but
coverageproperty is properly set and test jobs are also run on master.
We have manual jobs in MR pipelines that trigger other pipelines from other repositories to launch a dynamic environment.
And, because from what I understand, cobertura reports are parsed only when the pipeline is complete (and manual jobs aren’t always run), coverage visualization isn’t working. Is there any workaround?
We are on premium Gitlab.com plan with
Thank you for your help!