Add feature to map source code - coverage - owner
Resolves: https://gitlab.com/gitlab-org/quality/feature-readiness/team/-/issues/7
What does this MR do and why?
Adds an executable, to be run in scheduled CI pipelines of GitLab's monolith, that:
- Maps categories to teams (i.e., groups, stages, and/or sections) by
- Fetching GitLab's stages.yml file
- Parsing it and creating the mapping
- Maps teams to the source code (i.e., Ruby classes) they own by
- Fetching all
rspec-*.jsonartifacts created by collector jobs for unit tests, i.e.:rspec:artifact-collector unitrspec:artifact-collector unit single-redisrspec:artifact-collector ee unit single-redisrspec:artifact-collector ee unit
- Parsing the fetched artifacts
- Getting the
feature_categoryfor each class (each class could have multiple) from the parsed fetched artifacts - Using the
feature_categoryto class mapping from point 2.3 to map teams to classes with the category to teams mapping from point 1
- Fetching all
- Maps classes to their unit test coverage by
- Fetching the .lcov file produced by the
rspec:coveragejob that runs in the same pipeline out executable runs in - Parsing the .lcov file and getting the needed info from there
- Fetching the .lcov file produced by the
- Maps classes to all test files testing it (this include also non-unit tests) by
- Fetching the test map created by jobs running before in the same pipeline
- Parsing it and creating the mapping
With the above steps it's possible to create and keep up-to-date these 2 tables in ClickHouse:
| category | group | stage | section |
|---|---|---|---|
job_artifacts |
pipeline_execution |
verify |
ci |
| timestamp | file | coverage | category | ci_project_id | ci_project_path | ci_job_name | ci_job_id | ci_pipeline_id | ci_merge_request_iid | ci_branch | ci_target_branch |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 2025-10-15 15:50:49.000000 | spec/feature/foo.rb | 53% | job_artifacts | ||||||||
| 2025-10-15 15:50:49.000000 | spec/feature/bar.rb | 87% | source_code_management |
Screenshots or screen recordings
Contact me via Slack to get access to the ClickHouse instance with the data I pushed with this MR.
How to set up and validate locally
-
Run these commands to fetch a bunch of files locally, and store them in
<project-root>/working_dir/:curl -o gitlab.lcov https://gitlab.com/gitlab-org/gitlab/-/jobs/11380416469/artifacts/raw/coverage/lcov/gitlab.lcov curl -o rspec-11380416038.json https://gitlab.com/gitlab-org/gitlab/-/jobs/11380416038/artifacts/raw/rspec/rspec-11380416038.json curl -o rspec-11380416056.json https://gitlab.com/gitlab-org/gitlab/-/jobs/11380416056/artifacts/raw/rspec/rspec-11380416056.json curl https://gitlab-org.gitlab.io/gitlab/crystalball/packed-mapping.json.gz | gzip -d > mapping.json -
Set the
CLICKHOUSE_URL,CLICKHOUSE_DATABASE,CLICKHOUSE_USERNAME,CLICKHOUSE_PASSWORDwith the values you got from asking me in Slack :) -
Run
ruby exe/test-coverage \ --working_dir '/local/path/to/gitlab_quality-test_tooling/working_dir/' \ --rspec-reports-jobs 'rspec_artifact_collector_unit,rspec_artifact-collector_unit_single-redis,rspec:artifact-collector_ee_unit_single-redis,rspec_artifact-collector_ee_unit' \ --rspec-reports-glob 'rspec/rspec-*.json' \ --coverage-report-path '/local/path/to/gitlab_quality-test_tooling/working_dir/rspec_coverage/coverage/lcov/gitlab.lcov' \ --test-map-url 'https://gitlab-org.gitlab.io/gitlab/crystalball/packed-mapping.json.gz' -
Check that the functionality works as expected
-
Check in ClickHouse that the pushed data is what is expected
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.