Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
003bfac2
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
003bfac2
编写于
9月 06, 2017
作者:
Z
Zeger-Jan van de Weg
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Incorporate another round of feedback
上级
63e308f6
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
60 addition
and
38 deletion
+60
-38
app/models/ci/pipeline.rb
app/models/ci/pipeline.rb
+2
-2
app/models/project.rb
app/models/project.rb
+1
-1
app/models/project_auto_devops.rb
app/models/project_auto_devops.rb
+1
-1
db/migrate/20170828093725_create_project_auto_dev_ops.rb
db/migrate/20170828093725_create_project_auto_dev_ops.rb
+1
-1
db/schema.rb
db/schema.rb
+1
-1
spec/models/ci/pipeline_spec.rb
spec/models/ci/pipeline_spec.rb
+54
-32
未找到文件。
app/models/ci/pipeline.rb
浏览文件 @
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
浏览文件 @
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
浏览文件 @
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
浏览文件 @
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
浏览文件 @
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
浏览文件 @
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
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录