BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
003bfac2
Unverified
Commit
003bfac2
authored
Sep 06, 2017
by
Zeger-Jan van de Weg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Incorporate another round of feedback
parent
63e308f6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
60 additions
and
38 deletions
+60
-38
pipeline.rb
app/models/ci/pipeline.rb
+2
-2
project.rb
app/models/project.rb
+1
-1
project_auto_devops.rb
app/models/project_auto_devops.rb
+1
-1
20170828093725_create_project_auto_dev_ops.rb
db/migrate/20170828093725_create_project_auto_dev_ops.rb
+1
-1
schema.rb
db/schema.rb
+1
-1
pipeline_spec.rb
spec/models/ci/pipeline_spec.rb
+54
-32
No files found.
app/models/ci/pipeline.rb
View file @
003bfac2
...
...
@@ -351,9 +351,9 @@ module Ci
@ci_yaml_file
=
case
config_source
when
:repository_source
,
:unknown_source
when
"repository_source"
,
"unknown_source"
ci_yaml_from_repo
when
:auto_devops_source
when
"auto_devops_source"
implied_ci_yaml_file
end
...
...
app/models/project.rb
View file @
003bfac2
...
...
@@ -469,7 +469,7 @@ class Project < ActiveRecord::Base
end
def
auto_devops_enabled?
if
auto_devops
&&
!
auto_devops
.
enabled
.
nil
?
if
auto_devops
&&
auto_devops
.
enabled
.
present
?
auto_devops
.
enabled?
else
current_application_settings
.
auto_devops_enabled?
...
...
app/models/project_auto_devops.rb
View file @
003bfac2
class
ProjectAutoDevops
<
ActiveRecord
::
Base
belongs_to
:project
validates
:domain
,
presence:
true
validates
:domain
,
presence:
true
,
if: :enabled?
end
db/migrate/20170828093725_create_project_auto_dev_ops.rb
View file @
003bfac2
...
...
@@ -9,7 +9,7 @@ class CreateProjectAutoDevOps < ActiveRecord::Migration
create_table
:project_auto_devops
do
|
t
|
t
.
belongs_to
:project
,
null:
false
,
index:
{
unique:
true
}
t
.
boolean
:enabled
,
default:
nil
,
null:
true
t
.
string
:domain
,
null:
false
t
.
string
:domain
end
add_timestamps_with_timezone
(
:project_auto_devops
,
null:
false
)
...
...
db/schema.rb
View file @
003bfac2
...
...
@@ -1125,7 +1125,7 @@ ActiveRecord::Schema.define(version: 20170831092813) do
create_table
"project_auto_devops"
,
force: :cascade
do
|
t
|
t
.
integer
"project_id"
,
null:
false
t
.
boolean
"enabled"
t
.
string
"domain"
,
null:
false
t
.
string
"domain"
t
.
datetime_with_timezone
"created_at"
,
null:
false
t
.
datetime_with_timezone
"updated_at"
,
null:
false
end
...
...
spec/models/ci/pipeline_spec.rb
View file @
003bfac2
...
...
@@ -783,60 +783,82 @@ describe Ci::Pipeline, :mailer do
end
end
describe
'#ci_yaml_file'
do
let
(
:implied_yml
)
{
Gitlab
::
Template
::
GitlabCiYmlTemplate
.
find
(
'Auto-DevOps'
).
content
}
context
'when AutoDevops is enabled'
do
it
'returns the configuration if found'
do
describe
'#detect_ci_yaml_file'
do
context
'when the repo has a config file'
do
it
'returns that configuration'
do
allow
(
pipeline
.
project
.
repository
).
to
receive
(
:gitlab_ci_yml_for
)
.
and_return
(
'config'
)
expect
(
pipeline
.
ci_yaml_file
).
to
be_a
(
String
)
expect
(
pipeline
.
ci_yaml_file
).
not_to
eq
(
implied_yml
)
expect
(
pipeline
.
yaml_errors
).
to
be_nil
expect
(
pipeline
.
repository?
).
to
be
(
true
)
expect
(
pipeline
.
detect_ci_yaml_file
).
to
be_a
(
String
)
expect
(
pipeline
.
repository_source?
).
to
be
(
true
)
end
end
context
'when the repo does not have a config file'
do
let
(
:implied_yml
)
{
Gitlab
::
Template
::
GitlabCiYmlTemplate
.
find
(
'Auto-DevOps'
).
content
}
context
'
when the implied configuration will be us
ed'
do
context
'
auto devops enabl
ed'
do
before
do
allow_any_instance_of
(
ApplicationSetting
)
.
to
receive
(
:auto_devops_enabled?
)
{
true
}
end
it
'returns the implied c
onfiguration when its not found
'
do
it
'returns the implied c
i file
'
do
allow
(
pipeline
.
project
).
to
receive
(
:ci_config_path
)
{
'custom'
}
expect
(
pipeline
.
ci_yaml_file
).
to
eq
(
implied_yml
)
expect
(
pipeline
.
detect_ci_yaml_file
).
to
eq
(
implied_yml
)
expect
(
pipeline
.
auto_devops_source?
).
to
be
(
true
)
end
end
end
end
it
'sets the config sourc
e'
do
allow
(
pipeline
.
project
).
to
receive
(
:ci_config_path
)
{
'custom'
}
describe
'#ci_yaml_fil
e'
do
let
(
:implied_yml
)
{
Gitlab
::
Template
::
GitlabCiYmlTemplate
.
find
(
'Auto-DevOps'
).
content
}
expect
(
pipeline
.
ci_yaml_file
).
to
eq
(
implied_yml
)
expect
(
pipeline
.
auto_devops?
).
to
be
(
true
)
end
before
{
pipeline
.
detect_ci_yaml_file
}
context
'the source is unknown'
do
before
{
pipeline
.
unknown_source!
}
it
'returns the configuration if found'
do
allow
(
pipeline
.
project
.
repository
).
to
receive
(
:gitlab_ci_yml_for
)
.
and_return
(
'config'
)
expect
(
pipeline
.
ci_yaml_file
).
to
be_a
(
String
)
expect
(
pipeline
.
ci_yaml_file
).
not_to
eq
(
implied_yml
)
expect
(
pipeline
.
yaml_errors
).
to
be_nil
end
it
'sets yaml errors if not found'
do
expect
(
pipeline
.
ci_yaml_file
).
to
be_nil
expect
(
pipeline
.
yaml_errors
)
.
to
start_with
(
'Failed to load CI/CD config file'
)
end
end
context
'when AudoDevOps is disabled'
do
context
'when an invalid path is given'
do
it
'sets the yaml errors'
do
allow
(
pipeline
.
project
).
to
receive
(
:ci_config_path
)
{
'custom'
}
context
'the source is the repository'
do
before
{
pipeline
.
repository_source!
}
expect
(
pipeline
.
ci_yaml_file
).
to
be_nil
expect
(
pipeline
.
yaml_errors
)
.
to
start_with
(
'Failed to load CI/CD config file'
)
end
it
'returns the configuration if found'
do
allow
(
pipeline
.
project
.
repository
).
to
receive
(
:gitlab_ci_yml_for
)
.
and_return
(
'config'
)
expect
(
pipeline
.
ci_yaml_file
).
to
be_a
(
String
)
expect
(
pipeline
.
ci_yaml_file
).
not_to
eq
(
implied_yml
)
expect
(
pipeline
.
yaml_errors
).
to
be_nil
end
end
context
'when the config file can be found'
do
it
'has no yaml_errors'
do
allow
(
pipeline
.
project
.
repository
).
to
receive
(
:gitlab_ci_yml_for
)
.
and_return
(
'config'
)
context
'when the source is auto_devops_source'
do
before
{
pipeline
.
auto_devops_source!
}
expect
(
pipeline
.
ci_yaml_file
).
to
eq
(
'config'
)
expect
(
pipeline
.
yaml_errors
).
to
be_nil
end
it
'finds the implied config'
do
allow_any_instance_of
(
ApplicationSetting
)
.
to
receive
(
:auto_devops_enabled?
)
{
true
}
expect
(
pipeline
.
ci_yaml_file
).
to
eq
(
implied_yml
)
expect
(
pipeline
.
yaml_errors
).
to
be_nil
end
end
end
...
...
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