Skip to content
Snippets Groups Projects
Unverified Commit 57691c52 authored by Maxime Orefice's avatar Maxime Orefice
Browse files

Remove coverage CI detection at project setting level

This MR removes our coverage detection at the projet setting level.
It is still possible to parse coverage from job log by using the
coverage keyword.

Changelog: deprecated
parent d7b875c5
No related branches found
No related tags found
No related merge requests found
Showing
with 7 additions and 131 deletions
Loading
Loading
@@ -87,7 +87,7 @@ def update_params
def permitted_project_params
[
:runners_token, :builds_enabled, :build_allow_git_fetch,
:build_timeout_human_readable, :build_coverage_regex, :public_builds,
:build_timeout_human_readable, :public_builds,
:auto_cancel_pending_pipelines, :ci_config_path, :auto_rollback_enabled,
auto_devops_attributes: [:id, :domain, :enabled, :deploy_strategy],
ci_cd_settings_attributes: [:default_git_depth, :forward_deployment_enabled]
Loading
Loading
Loading
Loading
@@ -419,7 +419,6 @@ def project_params_attributes
:allow_merge_on_skipped_pipeline,
:avatar,
:build_allow_git_fetch,
:build_coverage_regex,
:build_timeout_human_readable,
:resolve_outdated_diff_discussions,
:container_registry_enabled,
Loading
Loading
Loading
Loading
@@ -884,10 +884,6 @@ def artifacts_file_for_type(type)
job_artifacts.find_by(file_type: file_types_ids)&.file
end
 
def coverage_regex
super || project.try(:build_coverage_regex)
end
def steps
[Gitlab::Ci::Build::Step.from_commands(self),
Gitlab::Ci::Build::Step.from_release(self),
Loading
Loading
Loading
Loading
@@ -52,6 +52,7 @@ class Project < ApplicationRecord
 
ignore_columns :mirror_last_update_at, :mirror_last_successful_update_at, remove_after: '2021-09-22', remove_with: '14.4'
ignore_columns :pull_mirror_branch_prefix, remove_after: '2021-09-22', remove_with: '14.4'
ignore_columns :build_coverage_regex, remove_after: '2022-07-22', remove_with: '15.0'
 
STATISTICS_ATTRIBUTE = 'repositories_count'
UNKNOWN_IMPORT_URL = 'http://unknown.git'
Loading
Loading
Loading
Loading
@@ -77,19 +77,7 @@
= _("The maximum file size in megabytes for individual job artifacts.")
= link_to sprite_icon('question-o'), help_page_path('user/admin_area/settings/continuous_integration', anchor: 'maximum-artifacts-size'), target: '_blank', rel: 'noopener noreferrer'
 
.form-group
= f.label :build_coverage_regex, _("Test coverage parsing"), class: 'label-bold'
.input-group
%span.input-group-prepend
.input-group-text /
= f.text_field :build_coverage_regex, class: 'form-control gl-form-input', placeholder: 'Regular expression', data: { qa_selector: 'build_coverage_regex_field' }
%span.input-group-append
.input-group-text /
%p.form-text.text-muted
= html_escape(_('The regular expression used to find test coverage output in the job log. For example, use %{regex} for Simplecov (Ruby). Leave blank to disable.')) % { regex: '<code>\(\d+.\d+%\)</code>'.html_safe }
= link_to sprite_icon('question-o'), help_page_path('ci/pipelines/settings', anchor: 'add-test-coverage-results-using-project-settings-deprecated'), target: '_blank', rel: 'noopener noreferrer'
= f.submit _('Save changes'), class: "btn gl-button btn-confirm", data: { qa_selector: 'save_general_pipelines_changes_button' }
= f.submit _('Save changes'), class: "btn gl-button btn-confirm"
 
%hr
 
Loading
Loading
Loading
Loading
@@ -7,7 +7,7 @@
- expanded = expanded_by_default?
- general_expanded = @project.errors.empty? ? expanded : true
 
%section.settings#js-general-pipeline-settings.no-animate{ class: ('expanded' if general_expanded), data: { qa_selector: 'general_pipelines_settings_content' } }
%section.settings#js-general-pipeline-settings.no-animate{ class: ('expanded' if general_expanded) }
.settings-header
%h4.settings-title.js-settings-toggle.js-settings-toggle-trigger-only
= _("General pipelines")
Loading
Loading
Loading
Loading
@@ -377,7 +377,6 @@ tables:
- mirror
- mirror_user_id
- shared_runners_enabled
- build_coverage_regex
- build_allow_git_fetch
- build_timeout
- mirror_trigger_builds
Loading
Loading
Loading
Loading
@@ -455,7 +455,6 @@ Example response:
"public_jobs":true,
"build_timeout":3600,
"auto_cancel_pending_pipelines":"enabled",
"build_coverage_regex":null,
"ci_config_path":null,
"shared_with_groups":[
{
Loading
Loading
Loading
Loading
@@ -1224,7 +1224,6 @@ POST /projects
| `auto_devops_enabled` | boolean | **{dotted-circle}** No | Enable Auto DevOps for this project. |
| `autoclose_referenced_issues` | boolean | **{dotted-circle}** No | Set whether auto-closing referenced issues on default branch. |
| `avatar` | mixed | **{dotted-circle}** No | Image file for avatar of the project. |
| `build_coverage_regex` | string | **{dotted-circle}** No | Test coverage parsing. |
| `build_git_strategy` | string | **{dotted-circle}** No | The Git strategy. Defaults to `fetch`. |
| `build_timeout` | integer | **{dotted-circle}** No | The maximum amount of time, in seconds, that a job can run. |
| `builds_access_level` | string | **{dotted-circle}** No | One of `disabled`, `private`, or `enabled`. |
Loading
Loading
@@ -1303,7 +1302,6 @@ POST /projects/user/:user_id
| `auto_devops_enabled` | boolean | **{dotted-circle}** No | Enable Auto DevOps for this project. |
| `autoclose_referenced_issues` | boolean | **{dotted-circle}** No | Set whether auto-closing referenced issues on default branch. |
| `avatar` | mixed | **{dotted-circle}** No | Image file for avatar of the project. |
| `build_coverage_regex` | string | **{dotted-circle}** No | Test coverage parsing. |
| `build_git_strategy` | string | **{dotted-circle}** No | The Git strategy. Defaults to `fetch`. |
| `build_timeout` | integer | **{dotted-circle}** No | The maximum amount of time, in seconds, that a job can run. |
| `builds_access_level` | string | **{dotted-circle}** No | One of `disabled`, `private`, or `enabled`. |
Loading
Loading
@@ -1392,7 +1390,6 @@ Supported attributes:
| `auto_devops_enabled` | boolean | **{dotted-circle}** No | Enable Auto DevOps for this project. |
| `autoclose_referenced_issues` | boolean | **{dotted-circle}** No | Set whether auto-closing referenced issues on default branch. |
| `avatar` | mixed | **{dotted-circle}** No | Image file for avatar of the project. |
| `build_coverage_regex` | string | **{dotted-circle}** No | Test coverage parsing. |
| `build_git_strategy` | string | **{dotted-circle}** No | The Git strategy. Defaults to `fetch`. |
| `build_timeout` | integer | **{dotted-circle}** No | The maximum amount of time, in seconds, that a job can run. |
| `builds_access_level` | string | **{dotted-circle}** No | One of `disabled`, `private`, or `enabled`. |
Loading
Loading
@@ -2718,7 +2715,6 @@ Example response:
"public_jobs": true,
"build_timeout": 3600,
"auto_cancel_pending_pipelines": "enabled",
"build_coverage_regex": null,
"ci_config_path": null,
"shared_with_groups": [],
"only_allow_merge_if_pipeline_succeeds": false,
Loading
Loading
Loading
Loading
@@ -224,35 +224,6 @@ using the [`coverage`](../yaml/index.md#coverage) keyword.
 
Setting the regular expression this way takes precedence over project settings.
 
### Add test coverage results using project settings (DEPRECATED)
> [Deprecated](https://gitlab.com/gitlab-org/gitlab/-/issues/17633) in GitLab 14.9. Replaced by [`coverage` keyword](../yaml/index.md#coverage).
WARNING:
This feature is in its end-of-life process. It is [deprecated](https://gitlab.com/gitlab-org/gitlab/-/issues/17633)
in GitLab 14.9, and is planned for [removal](https://gitlab.com/gitlab-org/gitlab/-/issues/17633) in GitLab 15.0.
You can add test coverage results to merge requests using the Project's CI/CD settings:
- Set using the GitLab UI:
1. On the top bar, select **Menu > Projects** and find your project.
1. On the left sidebar, select **Settings > CI/CD**.
1. Expand **General pipelines**.
1. In the **Test coverage parsing** field, enter a regular expression. Leave blank to disable this feature.
- Set when [editing a project](../../api/projects.md#edit-project) or [creating a project](../../api/projects.md#create-project)
using the GitLab API with the `build_coverage_regex` attribute:
```shell
curl --request PUT --header "PRIVATE-TOKEN: <your-token>" \
--url 'https://gitlab.com/api/v4/projects/<your-project-ID>' \
--data "build_coverage_regex=<your-regular-expression>"
```
You can use <https://rubular.com> to test your regular expression. The regular expression returns the **last**
match found in the output.
### Test coverage examples
 
Use this regex for commonly used test tools.
Loading
Loading
Loading
Loading
@@ -1350,8 +1350,6 @@ In this example:
 
**Additional details**:
 
- Coverage regular expressions set in `gitlab-ci.yml` take precedence over coverage regular expression set in the
[GitLab UI](../pipelines/settings.md#add-test-coverage-results-using-project-settings-deprecated).
- If there is more than one matched line in the job output, the last line is used
(the first result of reverse search).
- If there are multiple matches in a single line, the last match is searched
Loading
Loading
Loading
Loading
@@ -105,7 +105,6 @@ class Project < BasicProjectDetails
end
expose :build_timeout
expose :auto_cancel_pending_pipelines
expose :build_coverage_regex
expose :ci_config_path, if: -> (project, options) { Ability.allowed?(options[:current_user], :download_code, project) }
expose :shared_with_groups do |project, options|
user = options[:current_user]
Loading
Loading
Loading
Loading
@@ -13,7 +13,6 @@ module ProjectsHelpers
optional :build_git_strategy, type: String, values: %w(fetch clone), desc: 'The Git strategy. Defaults to `fetch`'
optional :build_timeout, type: Integer, desc: 'Build timeout'
optional :auto_cancel_pending_pipelines, type: String, values: %w(disabled enabled), desc: 'Auto-cancel pending pipelines'
optional :build_coverage_regex, type: String, desc: 'Test coverage parsing'
optional :ci_config_path, type: String, desc: 'The path to CI config file. Defaults to `.gitlab-ci.yml`'
optional :service_desk_enabled, type: Boolean, desc: 'Disable or enable the service desk'
optional :keep_latest_artifact, type: Boolean, desc: 'Indicates if the latest artifact should be kept for this project.'
Loading
Loading
@@ -124,7 +123,6 @@ def self.update_params_at_least_one_of
:auto_devops_enabled,
:auto_devops_deploy_strategy,
:auto_cancel_pending_pipelines,
:build_coverage_regex,
:build_git_strategy,
:build_timeout,
:builds_access_level,
Loading
Loading
Loading
Loading
@@ -637,7 +637,6 @@ included_attributes:
- :auto_cancel_pending_pipelines
- :autoclose_referenced_issues
- :build_allow_git_fetch
- :build_coverage_regex
- :build_timeout
- :ci_config_path
- :delete_error
Loading
Loading
Loading
Loading
@@ -37288,9 +37288,6 @@ msgstr ""
msgid "Test case"
msgstr ""
 
msgid "Test coverage parsing"
msgstr ""
msgid "Test coverage value for this pipeline was calculated by the coverage value of %d job."
msgid_plural "Test coverage value for this pipeline was calculated by averaging the resulting coverage values of %d jobs."
msgstr[0] ""
Loading
Loading
@@ -37848,9 +37845,6 @@ msgstr ""
msgid "The project was successfully imported."
msgstr ""
 
msgid "The regular expression used to find test coverage output in the job log. For example, use %{regex} for Simplecov (Ruby). Leave blank to disable."
msgstr ""
msgid "The related CI build failed."
msgstr ""
 
Loading
Loading
Loading
Loading
@@ -11,13 +11,6 @@ class CiCd < Page::Base
element :autodevops_settings_content
element :runners_settings_content
element :variables_settings_content
element :general_pipelines_settings_content
end
def expand_general_pipelines(&block)
expand_content(:general_pipelines_settings_content) do
Settings::GeneralPipelines.perform(&block)
end
end
 
def expand_runners_settings(&block)
Loading
Loading
# frozen_string_literal: true
module QA
module Page
module Project
module Settings
class GeneralPipelines < Page::Base
include QA::Page::Settings::Common
view 'app/views/projects/settings/ci_cd/_form.html.haml' do
element :build_coverage_regex_field
element :save_general_pipelines_changes_button
end
def configure_coverage_regex(pattern)
fill_element :build_coverage_regex_field, pattern
click_element :save_general_pipelines_changes_button
end
end
end
end
end
end
Loading
Loading
@@ -3,7 +3,6 @@
module QA
RSpec.describe 'Verify', :runner do
describe 'Code coverage statistics' do
let(:simplecov) { '\(\d+.\d+\%\) covered' }
let(:executor) { "qa-runner-#{Time.now.to_i}" }
let(:runner) do
Resource::Runner.fabricate_via_api! do |runner|
Loading
Loading
@@ -19,8 +18,9 @@ module QA
mr.file_content = <<~EOF
test:
tags: [e2e-test]
coverage: '/\\d+\\.\\d+% covered/'
script:
- echo '(66.67%) covered'
- echo '66.67% covered'
EOF
end
end
Loading
Loading
@@ -34,8 +34,6 @@ module QA
end
 
it 'creates an MR with code coverage statistics', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/348068' do
runner.project.visit!
configure_code_coverage(simplecov)
merge_request.visit!
 
Page::MergeRequest::Show.perform do |mr_widget|
Loading
Loading
@@ -44,16 +42,5 @@ module QA
end
end
end
private
def configure_code_coverage(coverage_tool_pattern)
Page::Project::Menu.perform(&:go_to_ci_cd_settings)
Page::Project::Settings::CiCd.perform do |settings|
settings.expand_general_pipelines do |coverage|
coverage.configure_coverage_regex(coverage_tool_pattern)
end
end
end
end
end
Loading
Loading
@@ -19,7 +19,7 @@ def visit_jobs_page
stub_feature_flags(jobs_table_vue: false)
project.add_maintainer(user)
project.enable_ci
project.update_attribute(:build_coverage_regex, /Coverage (\d+)%/)
build.update!(coverage_regex: '/Coverage (\d+)%/')
 
sign_in(user)
 
Loading
Loading
Loading
Loading
@@ -25,24 +25,6 @@
context 'for maintainer' do
let(:role) { :maintainer }
 
it 'be allowed to change' do
visit project_settings_ci_cd_path(project)
fill_in('Test coverage parsing', with: 'coverage_regex')
page.within '#js-general-pipeline-settings' do
click_on 'Save changes'
end
expect(page.status_code).to eq(200)
page.within '#js-general-pipeline-settings' do
expect(page).to have_button('Save changes', disabled: false)
end
expect(page).to have_field('Test coverage parsing', with: 'coverage_regex')
end
it 'updates auto_cancel_pending_pipelines' do
visit project_settings_ci_cd_path(project)
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment