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
45720d6a
Commit
45720d6a
authored
Jul 04, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
f735e7b2
546ee64c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
36 deletions
+23
-36
danger/database/Dangerfile
danger/database/Dangerfile
+1
-31
lib/gitlab/danger/helper.rb
lib/gitlab/danger/helper.rb
+5
-1
spec/lib/gitlab/danger/helper_spec.rb
spec/lib/gitlab/danger/helper_spec.rb
+17
-4
No files found.
danger/database/Dangerfile
View file @
45720d6a
# frozen_string_literal: true
# All the files/directories that should be reviewed by the DB team.
DB_FILES
=
[
'db/'
,
'app/models/project_authorization.rb'
,
'app/services/users/refresh_authorized_projects_service.rb'
,
'lib/gitlab/background_migration.rb'
,
'lib/gitlab/background_migration/'
,
'lib/gitlab/database.rb'
,
'lib/gitlab/database/'
,
'lib/gitlab/github_import.rb'
,
'lib/gitlab/github_import/'
,
'lib/gitlab/sql/'
,
'rubocop/cop/migration'
,
'ee/lib/gitlab/database/'
].
freeze
SCHEMA_NOT_UPDATED_MESSAGE
=
<<~
MSG
**New %<migrations>s added but %<schema>s wasn't updated.**
...
...
@@ -24,20 +8,6 @@ updated too (unless the migration isn't changing the DB schema
and isn't the most recent one).
MSG
def
database_paths_requiring_review
(
files
)
to_review
=
[]
files
.
each
do
|
file
|
review
=
DB_FILES
.
any?
do
|
pattern
|
file
.
start_with?
(
pattern
)
end
to_review
<<
file
if
review
end
to_review
end
non_geo_db_schema_updated
=
!
git
.
modified_files
.
grep
(
%r{
\A
db/schema
\.
rb}
).
empty?
geo_db_schema_updated
=
!
git
.
modified_files
.
grep
(
%r{
\A
ee/db/geo/schema
\.
rb}
).
empty?
...
...
@@ -52,7 +22,7 @@ if geo_migration_created && !geo_db_schema_updated
warn
format
(
SCHEMA_NOT_UPDATED_MESSAGE
,
migrations:
'Geo migrations'
,
schema:
gitlab
.
html_link
(
"ee/db/geo/schema.rb"
))
end
db_paths_to_review
=
database_paths_requiring_review
(
helper
.
all_changed_files
)
db_paths_to_review
=
helper
.
changes_by_category
[
:database
]
unless
db_paths_to_review
.
empty?
message
'This merge request adds or changes files that require a '
\
...
...
lib/gitlab/danger/helper.rb
View file @
45720d6a
...
...
@@ -103,6 +103,11 @@ module Gitlab
yarn
\.
lock
)
\z
}x
=>
:frontend
,
%r{
\A
(ee/)?db/}
=>
:database
,
%r{
\A
(ee/)?lib/gitlab/(database|background_migration|sql|github_import)(/|
\.
rb)}
=>
:database
,
%r{
\A
(app/models/project_authorization|app/services/users/refresh_authorized_projects_service)(/|
\.
rb)}
=>
:database
,
%r{
\A
rubocop/cop/migration(/|
\.
rb)}
=>
:database
,
%r{
\A
(ee/)?app/(?!assets|views)[^/]+}
=>
:backend
,
%r{
\A
(ee/)?(bin|config|danger|generator_templates|lib|rubocop|scripts)/}
=>
:backend
,
%r{
\A
(ee/)?spec/features/}
=>
:test
,
...
...
@@ -112,7 +117,6 @@ module Gitlab
%r{
\A
(Dangerfile|Gemfile|Gemfile.lock|Procfile|Rakefile|
\.
gitlab-ci
\.
yml)
\z
}
=>
:backend
,
%r{
\A
[A-Z_]+_VERSION
\z
}
=>
:backend
,
%r{
\A
(ee/)?db/}
=>
:database
,
%r{
\A
(ee/)?qa/}
=>
:qa
,
# Files that don't fit into any category are marked with :none
...
...
spec/lib/gitlab/danger/helper_spec.rb
View file @
45720d6a
...
...
@@ -87,13 +87,13 @@ describe Gitlab::Danger::Helper do
describe
'#changes_by_category'
do
it
'categorizes changed files'
do
expect
(
fake_git
).
to
receive
(
:added_files
)
{
%w[foo foo.md foo.rb foo.js db/foo qa/foo ee/changelogs/foo.yml]
}
expect
(
fake_git
).
to
receive
(
:added_files
)
{
%w[foo foo.md foo.rb foo.js db/foo
lib/gitlab/database/foo.rb
qa/foo ee/changelogs/foo.yml]
}
allow
(
fake_git
).
to
receive
(
:modified_files
)
{
[]
}
allow
(
fake_git
).
to
receive
(
:renamed_files
)
{
[]
}
expect
(
helper
.
changes_by_category
).
to
eq
(
backend:
%w[foo.rb]
,
database:
%w[db/foo]
,
database:
%w[db/foo
lib/gitlab/database/foo.rb
]
,
frontend:
%w[foo.js]
,
none:
%w[ee/changelogs/foo.yml foo.md]
,
qa:
%w[qa/foo]
,
...
...
@@ -159,9 +159,22 @@ describe Gitlab::Danger::Helper do
'ee/FOO_VERSION'
|
:unknown
'db/foo'
|
:database
'qa/foo'
|
:qa
'db/foo'
|
:database
'ee/db/foo'
|
:database
'app/models/project_authorization.rb'
|
:database
'app/services/users/refresh_authorized_projects_service.rb'
|
:database
'lib/gitlab/background_migration.rb'
|
:database
'lib/gitlab/background_migration/foo'
|
:database
'ee/lib/gitlab/background_migration/foo'
|
:database
'lib/gitlab/database.rb'
|
:database
'lib/gitlab/database/foo'
|
:database
'ee/lib/gitlab/database/foo'
|
:database
'lib/gitlab/github_import.rb'
|
:database
'lib/gitlab/github_import/foo'
|
:database
'lib/gitlab/sql/foo'
|
:database
'rubocop/cop/migration/foo'
|
:database
'qa/foo'
|
:qa
'ee/qa/foo'
|
:qa
'changelogs/foo'
|
:none
...
...
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