Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
bff44cbe
Commit
bff44cbe
authored
Sep 16, 2021
by
Erick Bajao
Committed by
Mikołaj Wawrzyniak
Sep 16, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Query new ci feature usage table for coverages
parent
da560e59
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
130 additions
and
8 deletions
+130
-8
app/models/project.rb
app/models/project.rb
+1
-0
config/feature_flags/development/query_project_ci_feature_usages_for_coverage.yml
...elopment/query_project_ci_feature_usages_for_coverage.yml
+8
-0
ee/app/finders/ee/namespaces/projects_finder.rb
ee/app/finders/ee/namespaces/projects_finder.rb
+5
-1
ee/app/models/ee/project.rb
ee/app/models/ee/project.rb
+7
-0
ee/spec/finders/ee/namespaces/projects_finder_spec.rb
ee/spec/finders/ee/namespaces/projects_finder_spec.rb
+37
-4
ee/spec/graphql/ee/resolvers/namespace_projects_resolver_spec.rb
.../graphql/ee/resolvers/namespace_projects_resolver_spec.rb
+39
-3
ee/spec/models/project_spec.rb
ee/spec/models/project_spec.rb
+31
-0
spec/lib/gitlab/import_export/all_models.yml
spec/lib/gitlab/import_export/all_models.yml
+1
-0
spec/models/project_spec.rb
spec/models/project_spec.rb
+1
-0
No files found.
app/models/project.rb
View file @
bff44cbe
...
...
@@ -380,6 +380,7 @@ class Project < ApplicationRecord
has_many
:jira_imports
,
->
{
order
'jira_imports.created_at'
},
class_name:
'JiraImportState'
,
inverse_of: :project
has_many
:daily_build_group_report_results
,
class_name:
'Ci::DailyBuildGroupReportResult'
has_many
:ci_feature_usages
,
class_name:
'Projects::CiFeatureUsage'
has_many
:repository_storage_moves
,
class_name:
'Projects::RepositoryStorageMove'
,
inverse_of: :container
...
...
config/feature_flags/development/query_project_ci_feature_usages_for_coverage.yml
0 → 100644
View file @
bff44cbe
---
name
:
query_project_ci_feature_usages_for_coverage
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/69890
rollout_issue_url
:
https://gitlab.com/gitlab-org/gitlab/-/issues/339974
milestone
:
'
14.3'
type
:
development
group
:
group::testing
default_enabled
:
false
ee/app/finders/ee/namespaces/projects_finder.rb
View file @
bff44cbe
...
...
@@ -39,7 +39,11 @@ module EE
def
with_code_coverage
(
items
)
return
items
unless
params
[
:has_code_coverage
].
present?
items
.
with_code_coverage
if
::
Feature
.
enabled?
(
:query_project_ci_feature_usages_for_coverage
,
namespace
,
default_enabled: :yaml
)
items
.
with_coverage_feature_usage
(
default_branch:
true
)
else
items
.
with_code_coverage
end
end
end
end
...
...
ee/app/models/ee/project.rb
View file @
bff44cbe
...
...
@@ -125,6 +125,13 @@ module EE
joins
(
:daily_build_group_report_results
).
merge
(
::
Ci
::
DailyBuildGroupReportResult
.
with_coverage
.
with_default_branch
).
group
(
:id
)
end
scope
:with_coverage_feature_usage
,
->
(
default_branch:
nil
)
do
join_conditions
=
{
feature: :code_coverage
}
join_conditions
[
:default_branch
]
=
default_branch
unless
default_branch
.
nil?
joins
(
:ci_feature_usages
).
where
(
ci_feature_usages:
join_conditions
).
group
(
:id
)
end
scope
:including_project
,
->
(
project
)
{
where
(
id:
project
)
}
scope
:with_wiki_enabled
,
->
{
with_feature_enabled
(
:wiki
)
}
scope
:within_shards
,
->
(
shard_names
)
{
where
(
repository_storage:
Array
(
shard_names
))
}
...
...
ee/spec/finders/ee/namespaces/projects_finder_spec.rb
View file @
bff44cbe
...
...
@@ -59,13 +59,46 @@ RSpec.describe Namespaces::ProjectsFinder do
end
context
'has_code_coverage'
do
let_it_be
(
:coverage_1
)
{
create
(
:ci_daily_build_group_report_result
,
project:
project_1
)
}
context
'when has_code_coverage is provided'
do
let
(
:params
)
{
{
has_code_coverage:
true
}
}
it
'returns projects with code coverage'
do
expect
(
projects
).
to
contain_exactly
(
project_1
)
before_all
do
create
(
:project_ci_feature_usage
,
feature: :code_coverage
,
project:
project_1
,
default_branch:
true
)
create
(
:ci_daily_build_group_report_result
,
project:
project_1
,
default_branch:
true
)
create
(
:project_ci_feature_usage
,
feature: :code_coverage
,
project:
project_2
,
default_branch:
false
)
create
(
:ci_daily_build_group_report_result
,
project:
project_2
,
default_branch:
false
)
end
context
'and query_project_ci_feature_usages_for_coverage flag is enabled for the given group'
do
before
do
stub_feature_flags
(
query_project_ci_feature_usages_for_coverage:
namespace
)
end
it
'returns projects with code coverage on default branch based on ci feature usages'
do
record
=
ActiveRecord
::
QueryRecorder
.
new
do
expect
(
projects
).
to
contain_exactly
(
project_1
)
end
queried_ci_table
=
record
.
log
.
any?
{
|
l
|
l
.
include?
(
'ci_daily_build_group_report_results'
)}
expect
(
queried_ci_table
).
to
eq
(
false
)
end
end
context
'and query_project_ci_feature_usages_for_coverage flag is disabled for the given group'
do
before
do
stub_feature_flags
(
query_project_ci_feature_usages_for_coverage:
create
(
:group
))
end
it
'returns projects with code coverage on default branch based on daily build group report results'
do
record
=
ActiveRecord
::
QueryRecorder
.
new
do
expect
(
projects
).
to
contain_exactly
(
project_1
)
end
queried_ci_table
=
record
.
log
.
any?
{
|
l
|
l
.
include?
(
'ci_daily_build_group_report_results'
)}
expect
(
queried_ci_table
).
to
eq
(
true
)
end
end
end
...
...
ee/spec/graphql/ee/resolvers/namespace_projects_resolver_spec.rb
View file @
bff44cbe
...
...
@@ -61,9 +61,8 @@ RSpec.describe Resolvers::NamespaceProjectsResolver do
context
'has_code_coverage'
do
subject
(
:projects
)
{
resolve_projects
(
has_code_coverage:
has_code_coverage
)
}
let!
(
:coverage_1
)
{
create
(
:ci_daily_build_group_report_result
,
project:
project_1
)
}
context
'when has_code_coverage is false'
do
let!
(
:coverage_1
)
{
create
(
:ci_daily_build_group_report_result
,
project:
project_1
)
}
let
(
:has_code_coverage
)
{
false
}
it
{
is_expected
.
to
contain_exactly
(
project_1
,
project_2
)
}
...
...
@@ -72,7 +71,44 @@ RSpec.describe Resolvers::NamespaceProjectsResolver do
context
'when has_code_coverage is true'
do
let
(
:has_code_coverage
)
{
true
}
it
{
is_expected
.
to
contain_exactly
(
project_1
)
}
before
do
create
(
:project_ci_feature_usage
,
feature: :code_coverage
,
project:
project_1
,
default_branch:
true
)
create
(
:ci_daily_build_group_report_result
,
project:
project_1
,
default_branch:
true
)
create
(
:project_ci_feature_usage
,
feature: :code_coverage
,
project:
project_2
,
default_branch:
false
)
create
(
:ci_daily_build_group_report_result
,
project:
project_2
,
default_branch:
false
)
end
context
'and query_project_ci_feature_usages_for_coverage flag is enabled for the given group'
do
before
do
stub_feature_flags
(
query_project_ci_feature_usages_for_coverage:
group
)
end
it
'returns projects with code coverage on default branch based on ci feature usages'
do
record
=
ActiveRecord
::
QueryRecorder
.
new
do
expect
(
projects
).
to
contain_exactly
(
project_1
)
end
queried_ci_table
=
record
.
log
.
any?
{
|
l
|
l
.
include?
(
'ci_daily_build_group_report_results'
)}
expect
(
queried_ci_table
).
to
eq
(
false
)
end
end
context
'and query_project_ci_feature_usages_for_coverage flag is disabled for the given group'
do
before
do
stub_feature_flags
(
query_project_ci_feature_usages_for_coverage:
false
)
end
it
'returns projects with code coverage on default branch based on daily build group report results'
do
record
=
ActiveRecord
::
QueryRecorder
.
new
do
expect
(
projects
).
to
contain_exactly
(
project_1
)
end
queried_ci_table
=
record
.
log
.
any?
{
|
l
|
l
.
include?
(
'ci_daily_build_group_report_results'
)}
expect
(
queried_ci_table
).
to
eq
(
true
)
end
end
end
end
end
...
...
ee/spec/models/project_spec.rb
View file @
bff44cbe
...
...
@@ -404,6 +404,37 @@ RSpec.describe Project do
it
{
is_expected
.
to
contain_exactly
(
project_1
,
project_2
)
}
end
describe
'.with_coverage_feature_usage'
do
let_it_be
(
:project_1
)
{
create
(
:project
)
}
let_it_be
(
:project_2
)
{
create
(
:project
)
}
let_it_be
(
:project_3
)
{
create
(
:project
)
}
before_all
do
create
(
:project_ci_feature_usage
,
feature: :code_coverage
,
project:
project_1
,
default_branch:
true
)
create
(
:project_ci_feature_usage
,
feature: :code_coverage
,
project:
project_1
,
default_branch:
false
)
create
(
:project_ci_feature_usage
,
feature: :code_coverage
,
project:
project_2
,
default_branch:
false
)
create
(
:project_ci_feature_usage
,
feature: :security_report
,
project:
project_3
,
default_branch:
true
)
end
context
'when default_branch is not specified'
do
subject
{
described_class
.
with_coverage_feature_usage
}
it
{
is_expected
.
to
contain_exactly
(
project_1
,
project_2
)
}
end
context
'when default_branch is set to true'
do
subject
{
described_class
.
with_coverage_feature_usage
(
default_branch:
true
)
}
it
{
is_expected
.
to
contain_exactly
(
project_1
)
}
end
context
'when default_branch is set to false'
do
subject
{
described_class
.
with_coverage_feature_usage
(
default_branch:
false
)
}
it
{
is_expected
.
to
contain_exactly
(
project_1
,
project_2
)
}
end
end
end
describe
'validations'
do
...
...
spec/lib/gitlab/import_export/all_models.yml
View file @
bff44cbe
...
...
@@ -592,6 +592,7 @@ project:
-
error_tracking_client_keys
-
pending_builds
-
security_scans
-
ci_feature_usages
award_emoji
:
-
awardable
-
user
...
...
spec/models/project_spec.rb
View file @
bff44cbe
...
...
@@ -139,6 +139,7 @@ RSpec.describe Project, factory_default: :keep do
it
{
is_expected
.
to
have_many
(
:error_tracking_errors
).
class_name
(
'ErrorTracking::Error'
)
}
it
{
is_expected
.
to
have_many
(
:error_tracking_client_keys
).
class_name
(
'ErrorTracking::ClientKey'
)
}
it
{
is_expected
.
to
have_many
(
:pending_builds
).
class_name
(
'Ci::PendingBuild'
)
}
it
{
is_expected
.
to
have_many
(
:ci_feature_usages
).
class_name
(
'Projects::CiFeatureUsage'
)
}
# GitLab Pages
it
{
is_expected
.
to
have_many
(
:pages_domains
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment