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
7efe65d6
Commit
7efe65d6
authored
Aug 13, 2020
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add latest template for Auto Deploy template
This commit adds the latest template
parent
1948210f
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
75 additions
and
20 deletions
+75
-20
changelogs/unreleased/hide-latest-versions-from-ui.yml
changelogs/unreleased/hide-latest-versions-from-ui.yml
+5
-0
doc/development/cicd/templates.md
doc/development/cicd/templates.md
+1
-1
ee/lib/ee/gitlab/template/gitlab_ci_yml_template.rb
ee/lib/ee/gitlab/template/gitlab_ci_yml_template.rb
+2
-2
lib/gitlab/template/finders/global_template_finder.rb
lib/gitlab/template/finders/global_template_finder.rb
+3
-3
lib/gitlab/template/gitlab_ci_yml_template.rb
lib/gitlab/template/gitlab_ci_yml_template.rb
+13
-5
spec/lib/gitlab/ci/templates/templates_spec.rb
spec/lib/gitlab/ci/templates/templates_spec.rb
+30
-5
spec/lib/gitlab/template/finders/global_template_finder_spec.rb
...ib/gitlab/template/finders/global_template_finder_spec.rb
+15
-4
spec/lib/gitlab/template/gitlab_ci_yml_template_spec.rb
spec/lib/gitlab/template/gitlab_ci_yml_template_spec.rb
+6
-0
No files found.
changelogs/unreleased/hide-latest-versions-from-ui.yml
0 → 100644
View file @
7efe65d6
---
title
:
Hide the latest version of templates from the template selector
merge_request
:
40937
author
:
type
:
other
doc/development/cicd/templates.md
View file @
7efe65d6
...
...
@@ -16,7 +16,7 @@ All template files reside in the `lib/gitlab/ci/templates` directory, and are ca
| Sub-directory | Content |
[
Selectable in UI
](
#make-sure-the-new-template-can-be-selected-in-ui
)
|
|----------------|--------------------------------------------------------------|-----------------------------------------------------------------------|
|
`/AWS/*`
| Cloud Deployment (AWS) related jobs | No |
|
`/Jobs/*`
| Auto DevOps related jobs |
Yes
|
|
`/Jobs/*`
| Auto DevOps related jobs |
No
|
|
`/Pages/*`
| Static site generators for GitLab Pages (for example Jekyll) | Yes |
|
`/Security/*`
| Security related jobs | Yes |
|
`/Verify/*`
| Verify/testing related jobs | Yes |
...
...
ee/lib/ee/gitlab/template/gitlab_ci_yml_template.rb
View file @
7efe65d6
...
...
@@ -14,8 +14,8 @@ module EE
super
.
merge
(
categories_ee
)
end
override
:
disabled_template
s
def
disabled_template
s
override
:
additional_excluded_pattern
s
def
additional_excluded_pattern
s
[]
end
...
...
lib/gitlab/template/finders/global_template_finder.rb
View file @
7efe65d6
...
...
@@ -5,10 +5,10 @@ module Gitlab
module
Template
module
Finders
class
GlobalTemplateFinder
<
BaseTemplateFinder
def
initialize
(
base_dir
,
extension
,
categories
=
{},
exclu
sio
ns:
[])
def
initialize
(
base_dir
,
extension
,
categories
=
{},
exclu
ded_patter
ns:
[])
@categories
=
categories
@extension
=
extension
@exclu
sions
=
exclusio
ns
@exclu
ded_patterns
=
excluded_patter
ns
super
(
base_dir
)
end
...
...
@@ -43,7 +43,7 @@ module Gitlab
private
def
excluded?
(
file_name
)
@exclu
sions
.
include?
(
file_name
)
@exclu
ded_patterns
.
any?
{
|
pattern
|
pattern
.
match?
(
file_name
)
}
end
def
select_directory
(
file_name
)
...
...
lib/gitlab/template/gitlab_ci_yml_template.rb
View file @
7efe65d6
...
...
@@ -3,12 +3,16 @@
module
Gitlab
module
Template
class
GitlabCiYmlTemplate
<
BaseTemplate
BASE_EXCLUDED_PATTERNS
=
[
%r{
\.
latest$}
].
freeze
def
content
explanation
=
"# This file is a template, and might need editing before it works on your project."
[
explanation
,
super
].
join
(
"
\n
"
)
end
class
<<
self
include
Gitlab
::
Utils
::
StrongMemoize
def
extension
'.gitlab-ci.yml'
end
...
...
@@ -22,10 +26,14 @@ module Gitlab
}
end
def
disabled_templates
%w[
Verify/Browser-Performance
]
def
excluded_patterns
strong_memoize
(
:excluded_patterns
)
do
BASE_EXCLUDED_PATTERNS
+
additional_excluded_patterns
end
end
def
additional_excluded_patterns
[
%r{Verify/Browser-Performance}
]
end
def
base_dir
...
...
@@ -34,7 +42,7 @@ module Gitlab
def
finder
(
project
=
nil
)
Gitlab
::
Template
::
Finders
::
GlobalTemplateFinder
.
new
(
self
.
base_dir
,
self
.
extension
,
self
.
categories
,
exclu
sions:
self
.
disabled_template
s
self
.
base_dir
,
self
.
extension
,
self
.
categories
,
exclu
ded_patterns:
self
.
excluded_pattern
s
)
end
end
...
...
spec/lib/gitlab/ci/templates/templates_spec.rb
View file @
7efe65d6
...
...
@@ -7,17 +7,17 @@ RSpec.describe 'CI YML Templates' do
let
(
:all_templates
)
{
Gitlab
::
Template
::
GitlabCiYmlTemplate
.
all
.
map
(
&
:full_name
)
}
let
(
:
disabl
ed_templates
)
do
Gitlab
::
Template
::
GitlabCiYmlTemplate
.
disabled_templates
.
map
do
|
templat
e
|
template
+
Gitlab
::
Template
::
GitlabCiYmlTemplate
.
extension
let
(
:
exclud
ed_templates
)
do
all_templates
.
select
do
|
nam
e
|
Gitlab
::
Template
::
GitlabCiYmlTemplate
.
excluded_patterns
.
any?
{
|
pattern
|
pattern
.
match?
(
name
)
}
end
end
context
'
included
in a CI YAML configuration'
do
context
'
when including available templates
in a CI YAML configuration'
do
using
RSpec
::
Parameterized
::
TableSyntax
where
(
:template_name
)
do
all_templates
-
disabl
ed_templates
all_templates
-
exclud
ed_templates
end
with_them
do
...
...
@@ -41,4 +41,29 @@ RSpec.describe 'CI YML Templates' do
end
end
end
context
'when including unavailable templates in a CI YAML configuration'
do
using
RSpec
::
Parameterized
::
TableSyntax
where
(
:template_name
)
do
excluded_templates
end
with_them
do
let
(
:content
)
do
<<~
EOS
include:
- template:
#{
template_name
}
concrete_build_implemented_by_a_user:
stage: test
script: do something
EOS
end
it
'is not valid'
do
expect
(
subject
).
not_to
be_valid
end
end
end
end
spec/lib/gitlab/template/finders/global_template_finder_spec.rb
View file @
7efe65d6
...
...
@@ -15,9 +15,9 @@ RSpec.describe Gitlab::Template::Finders::GlobalTemplateFinder do
FileUtils
.
rm_rf
(
base_dir
)
end
subject
(
:finder
)
{
described_class
.
new
(
base_dir
,
''
,
{
'General'
=>
''
,
'Bar'
=>
'Bar'
},
exclu
sions:
exclusio
ns
)
}
subject
(
:finder
)
{
described_class
.
new
(
base_dir
,
''
,
{
'General'
=>
''
,
'Bar'
=>
'Bar'
},
exclu
ded_patterns:
excluded_patter
ns
)
}
let
(
:exclu
sio
ns
)
{
[]
}
let
(
:exclu
ded_patter
ns
)
{
[]
}
describe
'.find'
do
context
'with a non-prefixed General template'
do
...
...
@@ -38,7 +38,7 @@ RSpec.describe Gitlab::Template::Finders::GlobalTemplateFinder do
end
context
'while listed as an exclusion'
do
let
(
:exclu
sions
)
{
%w[test-template
]
}
let
(
:exclu
ded_patterns
)
{
[
%r{^test-template$}
]
}
it
'does not find the template without a prefix'
do
expect
(
finder
.
find
(
'test-template'
)).
to
be_nil
...
...
@@ -77,7 +77,7 @@ RSpec.describe Gitlab::Template::Finders::GlobalTemplateFinder do
end
context
'while listed as an exclusion'
do
let
(
:exclu
sions
)
{
%w[Bar/test-template
]
}
let
(
:exclu
ded_patterns
)
{
[
%r{^Bar/test-template$}
]
}
it
'does not find the template with a prefix'
do
expect
(
finder
.
find
(
'Bar/test-template'
)).
to
be_nil
...
...
@@ -96,6 +96,17 @@ RSpec.describe Gitlab::Template::Finders::GlobalTemplateFinder do
expect
(
finder
.
find
(
'Bar/test-template'
)).
to
be_nil
end
end
context
'while listed as an exclusion'
do
let
(
:excluded_patterns
)
{
[
%r{
\.
latest$}
]
}
it
'excludes the template matched the pattern'
do
create_template!
(
'test-template.latest'
)
expect
(
finder
.
find
(
'test-template'
)).
to
be_present
expect
(
finder
.
find
(
'test-template.latest'
)).
to
be_nil
end
end
end
end
end
spec/lib/gitlab/template/gitlab_ci_yml_template_spec.rb
View file @
7efe65d6
...
...
@@ -13,6 +13,12 @@ RSpec.describe Gitlab::Template::GitlabCiYmlTemplate do
expect
(
all
).
to
include
(
'Docker'
)
expect
(
all
).
to
include
(
'Ruby'
)
end
it
'does not include Browser-Performance template in FOSS'
do
all
=
subject
.
all
.
map
(
&
:name
)
expect
(
all
).
not_to
include
(
'Browser-Performance'
)
unless
Gitlab
.
ee?
end
end
describe
'#content'
do
...
...
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