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
e32c82ed
Commit
e32c82ed
authored
Apr 05, 2019
by
Sean McGivern
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Merge branch 'require-all-templates-to-include-default-stages' into 'master'"
This reverts merge request !26954
parent
4dd53240
Changes
18
Show whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
50 additions
and
64 deletions
+50
-64
changelogs/unreleased/require-all-templates-to-include-default-stages.yml
...eased/require-all-templates-to-include-default-stages.yml
+0
-5
lib/gitlab/ci/config.rb
lib/gitlab/ci/config.rb
+6
-2
lib/gitlab/ci/config/external/file/local.rb
lib/gitlab/ci/config/external/file/local.rb
+1
-3
lib/gitlab/ci/templates/Android-Fastlane.gitlab-ci.yml
lib/gitlab/ci/templates/Android-Fastlane.gitlab-ci.yml
+0
-1
lib/gitlab/ci/templates/Android.gitlab-ci.yml
lib/gitlab/ci/templates/Android.gitlab-ci.yml
+4
-0
lib/gitlab/ci/templates/Auto-DevOps.gitlab-ci.yml
lib/gitlab/ci/templates/Auto-DevOps.gitlab-ci.yml
+0
-1
lib/gitlab/ci/templates/Chef.gitlab-ci.yml
lib/gitlab/ci/templates/Chef.gitlab-ci.yml
+2
-4
lib/gitlab/ci/templates/Go.gitlab-ci.yml
lib/gitlab/ci/templates/Go.gitlab-ci.yml
+0
-1
lib/gitlab/ci/templates/Mono.gitlab-ci.yml
lib/gitlab/ci/templates/Mono.gitlab-ci.yml
+0
-1
lib/gitlab/ci/templates/OpenShift.gitlab-ci.yml
lib/gitlab/ci/templates/OpenShift.gitlab-ci.yml
+0
-2
lib/gitlab/ci/templates/Packer.gitlab-ci.yml
lib/gitlab/ci/templates/Packer.gitlab-ci.yml
+0
-2
lib/gitlab/ci/templates/Serverless.gitlab-ci.yml
lib/gitlab/ci/templates/Serverless.gitlab-ci.yml
+0
-1
lib/gitlab/ci/templates/Swift.gitlab-ci.yml
lib/gitlab/ci/templates/Swift.gitlab-ci.yml
+0
-2
lib/gitlab/ci/templates/Terraform.gitlab-ci.yml
lib/gitlab/ci/templates/Terraform.gitlab-ci.yml
+0
-1
lib/gitlab/ci/templates/iOS-Fastlane.gitlab-ci.yml
lib/gitlab/ci/templates/iOS-Fastlane.gitlab-ci.yml
+0
-2
lib/gitlab/template/base_template.rb
lib/gitlab/template/base_template.rb
+0
-6
spec/lib/gitlab/ci/templates/templates_spec.rb
spec/lib/gitlab/ci/templates/templates_spec.rb
+34
-20
spec/lib/gitlab/ci/yaml_processor_spec.rb
spec/lib/gitlab/ci/yaml_processor_spec.rb
+3
-10
No files found.
changelogs/unreleased/require-all-templates-to-include-default-stages.yml
deleted
100644 → 0
View file @
4dd53240
---
title
:
Require all templates to use default stages
merge_request
:
26954
author
:
type
:
fixed
lib/gitlab/ci/config.rb
View file @
e32c82ed
...
@@ -73,13 +73,17 @@ module Gitlab
...
@@ -73,13 +73,17 @@ module Gitlab
def
build_config
(
config
,
project
:,
sha
:,
user
:)
def
build_config
(
config
,
project
:,
sha
:,
user
:)
initial_config
=
Gitlab
::
Config
::
Loader
::
Yaml
.
new
(
config
).
load!
initial_config
=
Gitlab
::
Config
::
Loader
::
Yaml
.
new
(
config
).
load!
if
project
process_external_files
(
initial_config
,
project:
project
,
sha:
sha
,
user:
user
)
process_external_files
(
initial_config
,
project:
project
,
sha:
sha
,
user:
user
)
else
initial_config
end
end
end
def
process_external_files
(
config
,
project
:,
sha
:,
user
:)
def
process_external_files
(
config
,
project
:,
sha
:,
user
:)
Config
::
External
::
Processor
.
new
(
config
,
Config
::
External
::
Processor
.
new
(
config
,
project:
project
,
project:
project
,
sha:
sha
||
project
&
.
repository
&
.
root_ref_sha
,
sha:
sha
||
project
.
repository
.
root_ref_sha
,
user:
user
,
user:
user
,
expandset:
Set
.
new
).
perform
expandset:
Set
.
new
).
perform
end
end
...
...
lib/gitlab/ci/config/external/file/local.rb
View file @
e32c82ed
...
@@ -21,9 +21,7 @@ module Gitlab
...
@@ -21,9 +21,7 @@ module Gitlab
private
private
def
validate_content!
def
validate_content!
if
context
.
project
&
.
repository
.
nil?
if
content
.
nil?
errors
.
push
(
"Local file `
#{
location
}
` does not have project!"
)
elsif
content
.
nil?
errors
.
push
(
"Local file `
#{
location
}
` does not exist!"
)
errors
.
push
(
"Local file `
#{
location
}
` does not exist!"
)
elsif
content
.
blank?
elsif
content
.
blank?
errors
.
push
(
"Local file `
#{
location
}
` is empty!"
)
errors
.
push
(
"Local file `
#{
location
}
` is empty!"
)
...
...
lib/gitlab/ci/templates/Android-Fastlane.gitlab-ci.yml
View file @
e32c82ed
...
@@ -6,7 +6,6 @@ stages:
...
@@ -6,7 +6,6 @@ stages:
-
environment
-
environment
-
build
-
build
-
test
-
test
-
deploy
-
internal
-
internal
-
alpha
-
alpha
-
beta
-
beta
...
...
lib/gitlab/ci/templates/Android.gitlab-ci.yml
View file @
e32c82ed
...
@@ -24,6 +24,10 @@ before_script:
...
@@ -24,6 +24,10 @@ before_script:
-
yes | android-sdk-linux/tools/bin/sdkmanager --licenses
-
yes | android-sdk-linux/tools/bin/sdkmanager --licenses
-
set -o pipefail
-
set -o pipefail
stages
:
-
build
-
test
lintDebug
:
lintDebug
:
stage
:
build
stage
:
build
script
:
script
:
...
...
lib/gitlab/ci/templates/Auto-DevOps.gitlab-ci.yml
View file @
e32c82ed
...
@@ -60,7 +60,6 @@ variables:
...
@@ -60,7 +60,6 @@ variables:
stages
:
stages
:
-
build
-
build
-
test
-
test
-
deploy
# dummy stage to follow the template guidelines
-
review
-
review
-
dast
-
dast
-
staging
-
staging
...
...
lib/gitlab/ci/templates/Chef.gitlab-ci.yml
View file @
e32c82ed
...
@@ -14,11 +14,9 @@ variables:
...
@@ -14,11 +14,9 @@ variables:
KITCHEN_LOCAL_YAML
:
"
.kitchen.dokken.yml"
KITCHEN_LOCAL_YAML
:
"
.kitchen.dokken.yml"
stages
:
stages
:
-
build
-
lint
-
lint
-
tes
t
-
uni
t
-
functional
-
functional
-
deploy
foodcritic
:
foodcritic
:
stage
:
lint
stage
:
lint
...
@@ -31,7 +29,7 @@ cookstyle:
...
@@ -31,7 +29,7 @@ cookstyle:
-
chef exec cookstyle .
-
chef exec cookstyle .
chefspec
:
chefspec
:
stage
:
tes
t
stage
:
uni
t
script
:
script
:
-
chef exec rspec spec
-
chef exec rspec spec
...
...
lib/gitlab/ci/templates/Go.gitlab-ci.yml
View file @
e32c82ed
...
@@ -18,7 +18,6 @@ before_script:
...
@@ -18,7 +18,6 @@ before_script:
stages
:
stages
:
-
test
-
test
-
build
-
build
-
deploy
format
:
format
:
stage
:
test
stage
:
test
...
...
lib/gitlab/ci/templates/Mono.gitlab-ci.yml
View file @
e32c82ed
...
@@ -15,7 +15,6 @@
...
@@ -15,7 +15,6 @@
image
:
mono:latest
image
:
mono:latest
stages
:
stages
:
-
build
-
test
-
test
-
deploy
-
deploy
...
...
lib/gitlab/ci/templates/OpenShift.gitlab-ci.yml
View file @
e32c82ed
image
:
ayufan/openshift-cli
image
:
ayufan/openshift-cli
stages
:
stages
:
-
build
# dummy stage to follow the template guidelines
-
test
-
test
-
deploy
# dummy stage to follow the template guidelines
-
review
-
review
-
staging
-
staging
-
production
-
production
...
...
lib/gitlab/ci/templates/Packer.gitlab-ci.yml
View file @
e32c82ed
...
@@ -9,8 +9,6 @@ before_script:
...
@@ -9,8 +9,6 @@ before_script:
stages
:
stages
:
-
validate
-
validate
-
build
-
test
-
deploy
-
deploy
validate
:
validate
:
...
...
lib/gitlab/ci/templates/Serverless.gitlab-ci.yml
View file @
e32c82ed
...
@@ -4,7 +4,6 @@ image: alpine:latest
...
@@ -4,7 +4,6 @@ image: alpine:latest
stages
:
stages
:
-
build
-
build
-
test
-
deploy
-
deploy
.serverless:build:image:
.serverless:build:image:
...
...
lib/gitlab/ci/templates/Swift.gitlab-ci.yml
View file @
e32c82ed
...
@@ -2,9 +2,7 @@
...
@@ -2,9 +2,7 @@
# This file assumes an own GitLab CI runner, setup on a macOS system.
# This file assumes an own GitLab CI runner, setup on a macOS system.
stages
:
stages
:
-
build
-
build
-
test
-
archive
-
archive
-
deploy
build_project
:
build_project
:
stage
:
build
stage
:
build
...
...
lib/gitlab/ci/templates/Terraform.gitlab-ci.yml
View file @
e32c82ed
...
@@ -24,7 +24,6 @@ before_script:
...
@@ -24,7 +24,6 @@ before_script:
stages
:
stages
:
-
validate
-
validate
-
build
-
build
-
test
-
deploy
-
deploy
validate
:
validate
:
...
...
lib/gitlab/ci/templates/iOS-Fastlane.gitlab-ci.yml
View file @
e32c82ed
...
@@ -12,8 +12,6 @@
...
@@ -12,8 +12,6 @@
stages
:
stages
:
-
build
-
build
-
test
-
deploy
variables
:
variables
:
LC_ALL
:
"
en_US.UTF-8"
LC_ALL
:
"
en_US.UTF-8"
...
...
lib/gitlab/template/base_template.rb
View file @
e32c82ed
...
@@ -16,12 +16,6 @@ module Gitlab
...
@@ -16,12 +16,6 @@ module Gitlab
end
end
alias_method
:key
,
:name
alias_method
:key
,
:name
def
full_name
Pathname
.
new
(
@path
)
.
relative_path_from
(
self
.
class
.
base_dir
)
.
to_s
end
def
content
def
content
@finder
.
read
(
@path
)
@finder
.
read
(
@path
)
end
end
...
...
spec/lib/gitlab/ci/templates/templates_spec.rb
View file @
e32c82ed
...
@@ -3,32 +3,46 @@
...
@@ -3,32 +3,46 @@
require
'spec_helper'
require
'spec_helper'
describe
"CI YML Templates"
do
describe
"CI YML Templates"
do
using
RSpec
::
Parameterized
::
TableSyntax
ABSTRACT_TEMPLATES
=
%w[Serverless]
.
freeze
# These templates depend on the presence of the `project`
subject
{
Gitlab
::
Ci
::
YamlProcessor
.
new
(
content
)
}
# param to enable processing of `include:` within CI config.
PROJECT_DEPENDENT_TEMPLATES
=
%w[Auto-DevOps DAST]
.
freeze
def
self
.
concrete_templates
Gitlab
::
Template
::
GitlabCiYmlTemplate
.
all
.
reject
do
|
template
|
ABSTRACT_TEMPLATES
.
include?
(
template
.
name
)
end
end
where
(
:template_name
)
do
def
self
.
abstract_templates
Gitlab
::
Template
::
GitlabCiYmlTemplate
.
all
.
map
(
&
:full_name
)
Gitlab
::
Template
::
GitlabCiYmlTemplate
.
all
.
select
do
|
template
|
ABSTRACT_TEMPLATES
.
include?
(
template
.
name
)
end
end
end
describe
'concrete templates with CI/CD jobs'
do
concrete_templates
.
each
do
|
template
|
it
"
#{
template
.
name
}
template should be valid"
do
# Trigger processing of included files
project
=
create
(
:project
,
:test_repo
)
if
PROJECT_DEPENDENT_TEMPLATES
.
include?
(
template
.
name
)
with_them
do
expect
{
Gitlab
::
Ci
::
YamlProcessor
.
new
(
template
.
content
,
project:
project
)
}
let
(
:content
)
do
.
not_to
raise_error
<<~
EOS
end
include:
end
- template:
#{
template_name
}
end
describe
'abstract templates without concrete jobs defined'
do
abstract_templates
.
each
do
|
template
|
it
"
#{
template
.
name
}
template should be valid after being implemented"
do
content
=
template
.
content
+
<<~
EOS
concrete_build_implemented_by_a_user:
concrete_build_implemented_by_a_user:
stage: test
stage: build
script: do something
script: do something
EOS
EOS
end
it
'is valid'
do
expect
{
Gitlab
::
Ci
::
YamlProcessor
.
new
(
content
)
}.
not_to
raise_error
expect
{
subject
}.
not_to
raise_error
end
end
it
'require default stages to be included'
do
expect
(
subject
.
stages
).
to
include
(
*
Gitlab
::
Ci
::
Config
::
Entry
::
Stages
.
default
)
end
end
end
end
end
end
spec/lib/gitlab/ci/yaml_processor_spec.rb
View file @
e32c82ed
...
@@ -626,8 +626,8 @@ module Gitlab
...
@@ -626,8 +626,8 @@ module Gitlab
context
"when an array is provided"
do
context
"when an array is provided"
do
let
(
:include_content
)
{
[
"/local.gitlab-ci.yml"
]
}
let
(
:include_content
)
{
[
"/local.gitlab-ci.yml"
]
}
it
"
returns a validation
error"
do
it
"
does not return any
error"
do
expect
{
subject
}.
to
raise_error
(
Gitlab
::
Ci
::
YamlProcessor
::
ValidationError
,
/does not have project/
)
expect
{
subject
}.
not_to
raise_error
end
end
end
end
...
@@ -643,18 +643,11 @@ module Gitlab
...
@@ -643,18 +643,11 @@ module Gitlab
let
(
:include_content
)
do
let
(
:include_content
)
do
[
[
'https://gitlab.com/awesome-project/raw/master/.before-script-template.yml'
,
'https://gitlab.com/awesome-project/raw/master/.before-script-template.yml'
,
'/templates/.after-script-template.yml'
,
{
template:
'Auto-DevOps.gitlab-ci.yml'
}
{
template:
'Auto-DevOps.gitlab-ci.yml'
}
]
]
end
end
before
do
WebMock
.
stub_request
(
:get
,
'https://gitlab.com/awesome-project/raw/master/.before-script-template.yml'
)
.
to_return
(
status:
200
,
headers:
{
'Content-Type'
=>
'application/json'
},
body:
'prepare: { script: ls -al }'
)
end
it
"does not return any error"
do
it
"does not return any error"
do
expect
{
subject
}.
not_to
raise_error
expect
{
subject
}.
not_to
raise_error
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