Skip to content

Skipped pipeline should not be selected as base_pipeline for MR for Coverage approval check to work

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Summary

There are workflows where users are automatically pushing code with ci.skip push option. When this happens, a pipeline is created with skipped status. If we create a merge request to this branch at this point, our Code Coverage approval rule will show as always requiring approval because the skiped pipeline is selected as our MR base_pipeline. The following error is generated when comparing the coverage values of MR pipeline with base_pipeline:

irb(main):026:0>  pipe = Ci::Pipeline.find(16)
=> #<Ci::Pipeline id: 16, ref: "kate-master-patch-49034", sha: "49301d913a1db5c7434eefc501b95ca366bdbe10", before_sha: "0000000000000000000000000000000000000000", created_at: "2023-06-27 09:51:34....
irb(main):027:0> pipe.update_builds_coverage
=> []
irb(main):028:1* merge_requests_approved_coverage = pipe.merge_requests_as_head_pipeline.reject do |mr|  bp = mr.base_pipeline
irb(main):029:1*   pp bp.id
irb(main):030:1*   pp pipe.coverage
irb(main):031:1*   pipe.coverage < bp.coverage
irb(main):032:0> end 
15
80.0
Traceback (most recent call last):
        4: from (irb):28
        3: from (irb):28:in `reject'
        2: from (irb):31:in `block in irb_binding'
        1: from (irb):31:in `<'
ArgumentError (comparison of Float with nil failed)

Steps to reproduce

  1. Configure Coverage check approval rule on a project.
  2. Configure Coverage pipeline to run on branches.
  3. Run pipeline with Coverage job on default branch (pipeline #1), make sure that it is picked up in the job view.
  4. Commit to default branch again and push the new commit with --push-option=ci.skip parameter. This will create a skipped pipeline (pipeline #2).
  5. Create a new branch and a Merge Request that improves Cove Coverage. The Pipeline for this MR (pipeline #3) runs and shows a greater coverage. The expectation here is that Coverage check approval rule will not require approval, but it does.

Example Project

What is the current bug behavior?

MR is incorrectly requiring approval

What is the expected correct behavior?

MR should not be requiring approval as the last coverage job on master has lower coverage number.

Relevant logs and/or screenshots

Output of checks

This bug happens on GitLab.com

Workaround

Run pipeline that includes coverage job for the same ref as skipped pipeline on target branch

Possible fixes

Edited by 🤖 GitLab Bot 🤖