Открыть боковую панель
nt_test111
nt_project_u8hcxr42ygkw
Коммиты
01431ae3
Коммит
01431ae3
создал
Июл 18, 2019
по автору
James Fargher
Просмотр файлов
Initial detection of Auto-DevOps buildable projects
владелец
34f5eb1b
Изменения
5
Скрыть пробелы
Построчно
Рядом
app/models/ci/pipeline.rb
Просмотр файла @
01431ae3
...
...
@@ -809,11 +809,16 @@ def ci_yaml_from_repo
def
implied_ci_yaml_file
return
unless
project
if
project
.
auto_devops_enabled?
if
project
.
auto_devops_enabled?
&&
auto_devops_buildable?
Gitlab
::
Template
::
GitlabCiYmlTemplate
.
find
(
'Auto-DevOps'
).
content
end
end
def
auto_devops_buildable?
project
.
has_auto_devops_explicitly_enabled?
||
Gitlab
::
AutoDevops
::
BuildableDetector
.
new
(
project
,
sha
).
buildable?
end
def
pipeline_data
Gitlab
::
DataBuilder
::
Pipeline
.
build
(
self
)
end
...
...
app/models/project.rb
Просмотр файла @
01431ae3
...
...
@@ -665,10 +665,14 @@ def auto_devops_enabled?
if
auto_devops
&
.
enabled
.
nil?
has_auto_devops_implicitly_enabled?
else
auto_devops
.
enabled?
has_
auto_devops
_explicitly_
enabled?
end
end
def
has_auto_devops_explicitly_enabled?
auto_devops
&
.
enabled?
end
def
has_auto_devops_implicitly_enabled?
auto_devops_config
=
first_auto_devops_config
...
...
lib/gitlab/auto_devops/buildable_detector.rb
0 → 100644
Просмотр файла @
01431ae3
# frozen_string_literal: true
module
Gitlab
module
AutoDevops
class
BuildableDetector
VARIABLES
=
[
'BUILDPACK_URL'
].
freeze
FILE_PATTERNS
=
[
'Dockerfile'
,
# https://github.com/heroku/heroku-buildpack-clojure
'project.clj'
,
# https://github.com/heroku/heroku-buildpack-go
'go.mod'
,
'Gopkg.mod'
,
'Godeps/Godeps.json'
,
'vendor/vendor.json'
,
'glide.yaml'
,
'src/**.go'
,
# https://github.com/heroku/heroku-buildpack-gradle
'gradlew'
,
'build.gradle'
,
'settings.gradle'
,
# https://github.com/heroku/heroku-buildpack-java
'pom.xml'
,
'pom.atom'
,
'pom.clj'
,
'pom.groovy'
,
'pom.rb'
,
'pom.scala'
,
'pom.yaml'
,
'pom.yml'
,
# https://github.com/heroku/heroku-buildpack-multi
'.buildpacks'
,
# https://github.com/heroku/heroku-buildpack-nodejs
'package.json'
,
# https://github.com/heroku/heroku-buildpack-php
'composer.json'
,
'index.php'
,
# https://github.com/heroku/heroku-buildpack-play
# TODO: detect script excludes some scala files
'*/conf/application.conf'
,
'*modules*'
,
# https://github.com/heroku/heroku-buildpack-python
# TODO: detect script checks that all of these exist, not any
'requirements.txt'
,
'setup.py'
,
'Pipfile'
,
# https://github.com/heroku/heroku-buildpack-ruby
'Gemfile'
,
# https://github.com/heroku/heroku-buildpack-scala
'*.sbt'
,
'project/*.scala'
,
'.sbt/*.scala'
,
'project/build.properties'
,
# https://github.com/dokku/buildpack-nginx
'.static'
].
freeze
def
initialize
(
project
,
ref
)
@project
=
project
@ref
=
ref
end
def
buildable?
detected_variables?
||
detected_files?
end
private
attr_accessor
:project
,
:ref
def
detected_variables?
project
.
ci_variables_for
(
ref:
ref
).
where
(
key:
VARIABLES
).
exists?
end
def
detected_files?
return
unless
tree
=
project
.
repository
.
tree
(
ref
)
tree
.
blobs
.
find
do
|
blob
|
FILE_PATTERNS
.
any?
do
|
pattern
|
File
.
fnmatch?
(
pattern
,
blob
.
path
,
File
::
FNM_CASEFOLD
)
end
end
rescue
Gitlab
::
Git
::
Repository
::
NoRepository
# nop
end
end
end
end
lib/gitlab/ci/pipeline/chain/validate/config.rb
Просмотр файла @
01431ae3
...
...
@@ -11,7 +11,11 @@ class Config < Chain::Base
def
perform!
unless
@pipeline
.
config_processor
unless
@pipeline
.
ci_yaml_file
return
error
(
"Missing
#{
@pipeline
.
ci_yaml_file_path
}
file"
)
if
@pipeline
.
project
.
auto_devops_enabled?
return
error
(
"Auto-DevOps enabled but no buildable files found"
)
else
return
error
(
"Missing
#{
@pipeline
.
ci_yaml_file_path
}
file"
)
end
end
if
@command
.
save_incompleted
&&
@pipeline
.
has_yaml_errors?
...
...
spec/lib/gitlab/auto_devops/buildable_detector_spec.rb
0 → 100644
Просмотр файла @
01431ae3
# frozen_string_literal: true
require
'spec_helper'
describe
Gitlab
::
AutoDevops
::
BuildableDetector
do
describe
'#buildable?'
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:ref
)
{
:head
}
subject
(
:detector
)
{
described_class
.
new
(
project
,
ref
)
}
context
'no matching variables or files'
do
it
'is not buildable'
do
expect
(
detector
).
to_not
be_buildable
end
end
context
'matching variable'
do
before
do
create
(
:ci_variable
,
project:
project
,
key:
'BUILDPACK_URL'
)
end
it
'is buildable'
do
expect
(
detector
).
to
be_buildable
end
end
context
'matching file'
do
let
(
:project
)
{
create
(
:project
,
:custom_repo
,
files:
{
'Dockerfile'
=>
''
})
}
it
'is buildable'
do
expect
(
detector
).
to
be_buildable
end
end
end
end
Редактирование
Предварительный просмотр
Поддерживает Markdown
0%
Попробовать снова
или
прикрепить новый файл
.
Отмена
You are about to add
0
people
to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Отмена
Пожалуйста,
зарегистрируйтесь
или
войдите
чтобы прокомментировать