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
cd03aebe
Commit
cd03aebe
authored
Sep 09, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
53e825cd
2bf5a1ac
Changes
17
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
389 additions
and
37 deletions
+389
-37
app/models/issue.rb
app/models/issue.rb
+1
-1
app/models/merge_request.rb
app/models/merge_request.rb
+1
-1
app/models/milestone.rb
app/models/milestone.rb
+1
-1
app/models/note.rb
app/models/note.rb
+1
-1
app/models/user.rb
app/models/user.rb
+1
-1
changelogs/unreleased/job-rules-e2e.yml
changelogs/unreleased/job-rules-e2e.yml
+5
-0
doc/workflow/repository_mirroring.md
doc/workflow/repository_mirroring.md
+1
-1
lib/gitlab/ci/build/rules.rb
lib/gitlab/ci/build/rules.rb
+8
-1
lib/gitlab/ci/build/rules/rule/clause.rb
lib/gitlab/ci/build/rules/rule/clause.rb
+1
-3
lib/gitlab/ci/config/entry/job.rb
lib/gitlab/ci/config/entry/job.rb
+9
-1
lib/gitlab/ci/config/entry/rules.rb
lib/gitlab/ci/config/entry/rules.rb
+4
-0
lib/gitlab/ci/pipeline/seed/build.rb
lib/gitlab/ci/pipeline/seed/build.rb
+1
-1
lib/gitlab/ci/yaml_processor.rb
lib/gitlab/ci/yaml_processor.rb
+1
-0
spec/lib/gitlab/ci/pipeline/seed/build_spec.rb
spec/lib/gitlab/ci/pipeline/seed/build_spec.rb
+2
-2
spec/lib/gitlab/ci/yaml_processor_spec.rb
spec/lib/gitlab/ci/yaml_processor_spec.rb
+36
-2
spec/models/user_spec.rb
spec/models/user_spec.rb
+1
-1
spec/services/ci/create_pipeline_service_spec.rb
spec/services/ci/create_pipeline_service_spec.rb
+315
-20
No files found.
app/models/issue.rb
View file @
cd03aebe
...
...
@@ -31,7 +31,7 @@ class Issue < ApplicationRecord
has_internal_id
:iid
,
scope: :project
,
init:
->
(
s
)
{
s
&
.
project
&
.
issues
&
.
maximum
(
:iid
)
}
has_many
:events
,
as: :target
,
dependent: :de
stroy
# rubocop:disable Cop/ActiveRecordDependent
has_many
:events
,
as: :target
,
dependent: :de
lete_all
# rubocop:disable Cop/ActiveRecordDependent
has_many
:merge_requests_closing_issues
,
class_name:
'MergeRequestsClosingIssues'
,
...
...
app/models/merge_request.rb
View file @
cd03aebe
...
...
@@ -56,7 +56,7 @@ class MergeRequest < ApplicationRecord
belongs_to
:head_pipeline
,
foreign_key:
"head_pipeline_id"
,
class_name:
"Ci::Pipeline"
has_many
:events
,
as: :target
,
dependent: :de
stroy
# rubocop:disable Cop/ActiveRecordDependent
has_many
:events
,
as: :target
,
dependent: :de
lete_all
# rubocop:disable Cop/ActiveRecordDependent
has_many
:merge_requests_closing_issues
,
class_name:
'MergeRequestsClosingIssues'
,
...
...
app/models/milestone.rb
View file @
cd03aebe
...
...
@@ -39,7 +39,7 @@ class Milestone < ApplicationRecord
has_many
:issues
has_many
:labels
,
->
{
distinct
.
reorder
(
'labels.title'
)
},
through: :issues
has_many
:merge_requests
has_many
:events
,
as: :target
,
dependent: :de
stroy
# rubocop:disable Cop/ActiveRecordDependent
has_many
:events
,
as: :target
,
dependent: :de
lete_all
# rubocop:disable Cop/ActiveRecordDependent
scope
:of_projects
,
->
(
ids
)
{
where
(
project_id:
ids
)
}
scope
:of_groups
,
->
(
ids
)
{
where
(
group_id:
ids
)
}
...
...
app/models/note.rb
View file @
cd03aebe
...
...
@@ -78,7 +78,7 @@ class Note < ApplicationRecord
# suggestions.delete_all calls
has_many
:suggestions
,
->
{
order
(
:relative_order
)
},
inverse_of: :note
,
dependent: :delete_all
# rubocop:disable Cop/ActiveRecordDependent
has_many
:events
,
as: :target
,
dependent: :de
stroy
# rubocop:disable Cop/ActiveRecordDependent
has_many
:events
,
as: :target
,
dependent: :de
lete_all
# rubocop:disable Cop/ActiveRecordDependent
has_one
:system_note_metadata
has_one
:note_diff_file
,
inverse_of: :diff_note
,
foreign_key: :diff_note_id
...
...
app/models/user.rb
View file @
cd03aebe
...
...
@@ -131,7 +131,7 @@ class User < ApplicationRecord
has_many
:notes
,
dependent: :destroy
,
foreign_key: :author_id
# rubocop:disable Cop/ActiveRecordDependent
has_many
:issues
,
dependent: :destroy
,
foreign_key: :author_id
# rubocop:disable Cop/ActiveRecordDependent
has_many
:merge_requests
,
dependent: :destroy
,
foreign_key: :author_id
# rubocop:disable Cop/ActiveRecordDependent
has_many
:events
,
dependent: :de
stroy
,
foreign_key: :author_id
# rubocop:disable Cop/ActiveRecordDependent
has_many
:events
,
dependent: :de
lete_all
,
foreign_key: :author_id
# rubocop:disable Cop/ActiveRecordDependent
has_many
:releases
,
dependent: :nullify
,
foreign_key: :author_id
# rubocop:disable Cop/ActiveRecordDependent
has_many
:subscriptions
,
dependent: :destroy
# rubocop:disable Cop/ActiveRecordDependent
has_many
:oauth_applications
,
class_name:
'Doorkeeper::Application'
,
as: :owner
,
dependent: :destroy
# rubocop:disable Cop/ActiveRecordDependent
...
...
changelogs/unreleased/job-rules-e2e.yml
0 → 100644
View file @
cd03aebe
---
title
:
Passing job rules downstream and E2E specs for job:rules configuration
merge_request
:
32609
author
:
type
:
fixed
doc/workflow/repository_mirroring.md
View file @
cd03aebe
...
...
@@ -102,7 +102,7 @@ The repository will push soon. To force a push, click the appropriate button.
> - [Added Git LFS support](https://gitlab.com/gitlab-org/gitlab-ee/issues/10871) in [GitLab Starter](https://about.gitlab.com/pricing/) 11.11.
NOTE:
**Note:**
This feature
[
is available for free
](
https://gitlab.com/gitlab-org/gitlab-ee/issues/10361
)
to
GitLab.com users until
September 22nd, 2019
.
GitLab.com users until
March 22nd, 2020
.
You can set up a repository to automatically have its branches, tags, and commits updated from an
upstream repository.
...
...
lib/gitlab/ci/build/rules.rb
View file @
cd03aebe
...
...
@@ -6,7 +6,14 @@ module Gitlab
class
Rules
include
::
Gitlab
::
Utils
::
StrongMemoize
Result
=
Struct
.
new
(
:when
,
:start_in
)
Result
=
Struct
.
new
(
:when
,
:start_in
)
do
def
build_attributes
{
when:
self
.
when
,
options:
{
start_in:
start_in
}.
compact
}.
compact
end
end
def
initialize
(
rule_hashes
,
default_when
=
'on_success'
)
@rule_list
=
Rule
.
fabricate_list
(
rule_hashes
)
...
...
lib/gitlab/ci/build/rules/rule/clause.rb
View file @
cd03aebe
...
...
@@ -13,9 +13,7 @@ module Gitlab
UnknownClauseError
=
Class
.
new
(
StandardError
)
def
self
.
fabricate
(
type
,
value
)
type
=
type
.
to_s
.
camelize
self
.
const_get
(
type
).
new
(
value
)
if
self
.
const_defined?
(
type
)
"
#{
self
}
::
#{
type
.
to_s
.
camelize
}
"
.
safe_constantize
&
.
new
(
value
)
end
def
initialize
(
spec
)
...
...
lib/gitlab/ci/config/entry/job.rb
View file @
cd03aebe
...
...
@@ -122,7 +122,7 @@ module Gitlab
helpers
:before_script
,
:script
,
:stage
,
:type
,
:after_script
,
:cache
,
:image
,
:services
,
:only
,
:except
,
:variables
,
:artifacts
,
:environment
,
:coverage
,
:retry
,
:artifacts
,
:environment
,
:coverage
,
:retry
,
:rules
,
:parallel
,
:needs
,
:interruptible
attributes
:script
,
:tags
,
:allow_failure
,
:when
,
:dependencies
,
...
...
@@ -145,6 +145,13 @@ module Gitlab
end
@entries
.
delete
(
:type
)
# This is something of a hack, see issue for details:
# https://gitlab.com/gitlab-org/gitlab-ce/issues/67150
if
!
only_defined?
&&
has_rules?
@entries
.
delete
(
:only
)
@entries
.
delete
(
:except
)
end
end
inherit!
(
deps
)
...
...
@@ -203,6 +210,7 @@ module Gitlab
cache:
cache_value
,
only:
only_value
,
except:
except_value
,
rules:
has_rules?
?
rules_value
:
nil
,
variables:
variables_defined?
?
variables_value
:
{},
environment:
environment_defined?
?
environment_value
:
nil
,
environment_name:
environment_defined?
?
environment_value
[
:name
]
:
nil
,
...
...
lib/gitlab/ci/config/entry/rules.rb
View file @
cd03aebe
...
...
@@ -26,6 +26,10 @@ module Gitlab
end
end
end
def
value
@config
end
end
end
end
...
...
lib/gitlab/ci/pipeline/seed/build.rb
View file @
cd03aebe
...
...
@@ -145,7 +145,7 @@ module Gitlab
def
rules_attributes
strong_memoize
(
:rules_attributes
)
do
@using_rules
?
@rules
.
evaluate
(
@pipeline
,
self
).
to_h
.
compact
:
{}
@using_rules
?
@rules
.
evaluate
(
@pipeline
,
self
).
build_attributes
:
{}
end
end
end
...
...
lib/gitlab/ci/yaml_processor.rb
View file @
cd03aebe
...
...
@@ -42,6 +42,7 @@ module Gitlab
yaml_variables:
yaml_variables
(
name
),
needs_attributes:
job
[
:needs
]
&
.
map
{
|
need
|
{
name:
need
}
},
interruptible:
job
[
:interruptible
],
rules:
job
[
:rules
],
options:
{
image:
job
[
:image
],
services:
job
[
:services
],
...
...
spec/lib/gitlab/ci/pipeline/seed/build_spec.rb
View file @
cd03aebe
...
...
@@ -46,7 +46,7 @@ describe Gitlab::Ci::Pipeline::Seed::Build do
context
'is matched'
do
let
(
:attributes
)
{
{
name:
'rspec'
,
ref:
'master'
,
rules:
[{
if:
'$VAR == null'
,
when:
'delayed'
,
start_in:
'3 hours'
}]
}
}
it
{
is_expected
.
to
include
(
when:
'delayed'
,
start_in:
'3 hours'
)
}
it
{
is_expected
.
to
include
(
when:
'delayed'
,
options:
{
start_in:
'3 hours'
}
)
}
end
context
'is not matched'
do
...
...
@@ -541,7 +541,7 @@ describe Gitlab::Ci::Pipeline::Seed::Build do
it
{
is_expected
.
to
be_included
}
it
'correctly populates when:'
do
expect
(
seed_build
.
attributes
).
to
include
(
when:
'delayed'
,
start_in:
'1 day'
)
expect
(
seed_build
.
attributes
).
to
include
(
when:
'delayed'
,
options:
{
start_in:
'1 day'
}
)
end
end
end
...
...
spec/lib/gitlab/ci/yaml_processor_spec.rb
View file @
cd03aebe
...
...
@@ -16,7 +16,10 @@ module Gitlab
let
(
:config
)
do
YAML
.
dump
(
before_script:
[
'pwd'
],
rspec:
{
script:
'rspec'
}
rspec:
{
script:
'rspec'
,
interruptible:
true
}
)
end
...
...
@@ -29,6 +32,7 @@ module Gitlab
before_script:
[
"pwd"
],
script:
[
"rspec"
]
},
interruptible:
true
,
allow_failure:
false
,
when:
"on_success"
,
yaml_variables:
[]
...
...
@@ -36,6 +40,36 @@ module Gitlab
end
end
context
'with job rules'
do
let
(
:config
)
do
YAML
.
dump
(
rspec:
{
script:
'rspec'
,
rules:
[
{
if:
'$CI_COMMIT_REF_NAME == "master"'
},
{
changes:
%w[README.md]
}
]
}
)
end
it
'returns valid build attributes'
do
expect
(
subject
).
to
eq
({
stage:
'test'
,
stage_idx:
1
,
name:
'rspec'
,
options:
{
script:
[
'rspec'
]
},
rules:
[
{
if:
'$CI_COMMIT_REF_NAME == "master"'
},
{
changes:
%w[README.md]
}
],
allow_failure:
false
,
when:
'on_success'
,
yaml_variables:
[]
})
end
end
describe
'coverage entry'
do
describe
'code coverage regexp'
do
let
(
:config
)
do
...
...
@@ -1252,7 +1286,7 @@ module Gitlab
end
end
describe
'rules
'
do
context
'with when/rules conflict
'
do
subject
{
Gitlab
::
Ci
::
YamlProcessor
.
new
(
YAML
.
dump
(
config
))
}
let
(
:config
)
do
...
...
spec/models/user_spec.rb
View file @
cd03aebe
...
...
@@ -32,7 +32,7 @@ describe User do
it
{
is_expected
.
to
have_many
(
:groups
)
}
it
{
is_expected
.
to
have_many
(
:keys
).
dependent
(
:destroy
)
}
it
{
is_expected
.
to
have_many
(
:deploy_keys
).
dependent
(
:nullify
)
}
it
{
is_expected
.
to
have_many
(
:events
).
dependent
(
:de
stroy
)
}
it
{
is_expected
.
to
have_many
(
:events
).
dependent
(
:de
lete_all
)
}
it
{
is_expected
.
to
have_many
(
:issues
).
dependent
(
:destroy
)
}
it
{
is_expected
.
to
have_many
(
:notes
).
dependent
(
:destroy
)
}
it
{
is_expected
.
to
have_many
(
:merge_requests
).
dependent
(
:destroy
)
}
...
...
spec/services/ci/create_pipeline_service_spec.rb
View file @
cd03aebe
This diff is collapsed.
Click to expand it.
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