eriwen / lcov-to-cobertura-xml

Converts lcov output to Cobertura-compatible XML for CI
https://eriwen.github.io/lcov-to-cobertura-xml/
Apache License 2.0
188 stars 73 forks source link

gitlab-ci can't read .xml file, which is conversion by lcov-to-cobertura-xml #43

Open EAHITechnology opened 2 years ago

EAHITechnology commented 2 years ago

I have a .lcov file generated by llvm-cov.

/usr/lib/llvm-8/bin/llvm-cov export -format=lcov -Xdemangler c++filt -Xdemangler -n -instr-profile=xxx.profdata -object=build/bin/xxx > worker_ut.lcov

python3 /usr/local/lib/python3.9/dist-packages/lcov_cobertura/lcov_cobertura.py xxxx.lcov

When i use it in gitlab-ci:

coverage: /^\s*lines:\s*\d+.\d+\%/
  artifacts:
    expire_in: 1 days
    reports:
      cobertura: xxx.xml
      junit: xxxx.xml

But it doesn't work, Test is always 0

egfx-notifications commented 2 years ago

Are you sure that is the right CI configuration for your GitLab version? A while ago they changed that from what you have to this: https://docs.gitlab.com/ee/ci/yaml/artifacts_reports.html#artifactsreportscoverage_report

The coverage with regex feature is completely removed in current versions.

betaboon commented 2 years ago

@egfx-notifications the regex feature is still there: https://docs.gitlab.com/ee/ci/yaml/#coverage (I'm using it in gitlab-cloud as we speak)

@EAHITechnology this is the gitlab-ci-config (snippet) that i currently use which works:

test:
  script:
    - myscript
  coverage: '/Code coverage: \d+\.\d+/'
  artifacts:
    reports:
      coverage_report:
        coverage_format: cobertura
        path: .reports/coverage.xml
egfx-notifications commented 2 years ago

Please forgive my faulty memory, the coverage regex in the CI configuration is indeed the replacement for the removed coverage regex in project settings. Somehow got that mixed up. Thank you for correcting me @betaboon