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
084f1ad5
Commit
084f1ad5
authored
Oct 19, 2021
by
Marius Bobin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cache CI variables used for rules evaluation
Cache CI variables used for rules evaluation Changelog: performance
parent
03bc1b05
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
68 additions
and
53 deletions
+68
-53
app/models/ci/pipeline.rb
app/models/ci/pipeline.rb
+47
-36
app/models/project.rb
app/models/project.rb
+10
-8
ee/app/models/ee/project.rb
ee/app/models/ee/project.rb
+3
-1
ee/spec/lib/gitlab/ci/templates/Jobs/dast_default_branch_gitlab_ci_yaml_spec.rb
...templates/Jobs/dast_default_branch_gitlab_ci_yaml_spec.rb
+1
-1
ee/spec/lib/gitlab/ci/templates/cluster_image_scanning_gitlab_ci_yaml_spec.rb
...i/templates/cluster_image_scanning_gitlab_ci_yaml_spec.rb
+1
-1
ee/spec/lib/gitlab/ci/templates/container_scanning_gitlab_ci_yaml_spec.rb
...ab/ci/templates/container_scanning_gitlab_ci_yaml_spec.rb
+2
-2
ee/spec/lib/gitlab/ci/templates/license_scanning_gitlab_ci_yaml_spec.rb
...tlab/ci/templates/license_scanning_gitlab_ci_yaml_spec.rb
+1
-1
ee/spec/services/ci/create_pipeline_service/dast_configuration_spec.rb
...ces/ci/create_pipeline_service/dast_configuration_spec.rb
+1
-1
spec/services/ci/create_pipeline_service_spec.rb
spec/services/ci/create_pipeline_service_spec.rb
+2
-2
No files found.
app/models/ci/pipeline.rb
View file @
084f1ad5
...
...
@@ -684,7 +684,9 @@ module Ci
end
def
freeze_period?
Ci
::
FreezePeriodStatus
.
new
(
project:
project
).
execute
strong_memoize
(
:freeze_period
)
do
Ci
::
FreezePeriodStatus
.
new
(
project:
project
).
execute
end
end
def
has_warnings?
...
...
@@ -796,20 +798,7 @@ module Ci
variables
.
append
(
key:
'CI_PIPELINE_CREATED_AT'
,
value:
created_at
&
.
iso8601
)
variables
.
concat
(
predefined_commit_variables
)
if
merge_request?
variables
.
append
(
key:
'CI_MERGE_REQUEST_EVENT_TYPE'
,
value:
merge_request_event_type
.
to_s
)
variables
.
append
(
key:
'CI_MERGE_REQUEST_SOURCE_BRANCH_SHA'
,
value:
source_sha
.
to_s
)
variables
.
append
(
key:
'CI_MERGE_REQUEST_TARGET_BRANCH_SHA'
,
value:
target_sha
.
to_s
)
diff
=
self
.
merge_request_diff
if
diff
.
present?
variables
.
append
(
key:
'CI_MERGE_REQUEST_DIFF_ID'
,
value:
diff
.
id
.
to_s
)
variables
.
append
(
key:
'CI_MERGE_REQUEST_DIFF_BASE_SHA'
,
value:
diff
.
base_commit_sha
)
end
variables
.
concat
(
merge_request
.
predefined_variables
)
end
variables
.
concat
(
predefined_merge_request_variables
)
if
open_merge_requests_refs
.
any?
variables
.
append
(
key:
'CI_OPEN_MERGE_REQUESTS'
,
value:
open_merge_requests_refs
.
join
(
','
))
...
...
@@ -825,27 +814,49 @@ module Ci
end
def
predefined_commit_variables
Gitlab
::
Ci
::
Variables
::
Collection
.
new
.
tap
do
|
variables
|
variables
.
append
(
key:
'CI_COMMIT_SHA'
,
value:
sha
)
variables
.
append
(
key:
'CI_COMMIT_SHORT_SHA'
,
value:
short_sha
)
variables
.
append
(
key:
'CI_COMMIT_BEFORE_SHA'
,
value:
before_sha
)
variables
.
append
(
key:
'CI_COMMIT_REF_NAME'
,
value:
source_ref
)
variables
.
append
(
key:
'CI_COMMIT_REF_SLUG'
,
value:
source_ref_slug
)
variables
.
append
(
key:
'CI_COMMIT_BRANCH'
,
value:
ref
)
if
branch?
variables
.
append
(
key:
'CI_COMMIT_TAG'
,
value:
ref
)
if
tag?
variables
.
append
(
key:
'CI_COMMIT_MESSAGE'
,
value:
git_commit_message
.
to_s
)
variables
.
append
(
key:
'CI_COMMIT_TITLE'
,
value:
git_commit_full_title
.
to_s
)
variables
.
append
(
key:
'CI_COMMIT_DESCRIPTION'
,
value:
git_commit_description
.
to_s
)
variables
.
append
(
key:
'CI_COMMIT_REF_PROTECTED'
,
value:
(
!!
protected_ref?
).
to_s
)
variables
.
append
(
key:
'CI_COMMIT_TIMESTAMP'
,
value:
git_commit_timestamp
.
to_s
)
variables
.
append
(
key:
'CI_COMMIT_AUTHOR'
,
value:
git_author_full_text
.
to_s
)
# legacy variables
variables
.
append
(
key:
'CI_BUILD_REF'
,
value:
sha
)
variables
.
append
(
key:
'CI_BUILD_BEFORE_SHA'
,
value:
before_sha
)
variables
.
append
(
key:
'CI_BUILD_REF_NAME'
,
value:
source_ref
)
variables
.
append
(
key:
'CI_BUILD_REF_SLUG'
,
value:
source_ref_slug
)
variables
.
append
(
key:
'CI_BUILD_TAG'
,
value:
ref
)
if
tag?
strong_memoize
(
:predefined_commit_variables
)
do
Gitlab
::
Ci
::
Variables
::
Collection
.
new
.
tap
do
|
variables
|
variables
.
append
(
key:
'CI_COMMIT_SHA'
,
value:
sha
)
variables
.
append
(
key:
'CI_COMMIT_SHORT_SHA'
,
value:
short_sha
)
variables
.
append
(
key:
'CI_COMMIT_BEFORE_SHA'
,
value:
before_sha
)
variables
.
append
(
key:
'CI_COMMIT_REF_NAME'
,
value:
source_ref
)
variables
.
append
(
key:
'CI_COMMIT_REF_SLUG'
,
value:
source_ref_slug
)
variables
.
append
(
key:
'CI_COMMIT_BRANCH'
,
value:
ref
)
if
branch?
variables
.
append
(
key:
'CI_COMMIT_TAG'
,
value:
ref
)
if
tag?
variables
.
append
(
key:
'CI_COMMIT_MESSAGE'
,
value:
git_commit_message
.
to_s
)
variables
.
append
(
key:
'CI_COMMIT_TITLE'
,
value:
git_commit_full_title
.
to_s
)
variables
.
append
(
key:
'CI_COMMIT_DESCRIPTION'
,
value:
git_commit_description
.
to_s
)
variables
.
append
(
key:
'CI_COMMIT_REF_PROTECTED'
,
value:
(
!!
protected_ref?
).
to_s
)
variables
.
append
(
key:
'CI_COMMIT_TIMESTAMP'
,
value:
git_commit_timestamp
.
to_s
)
variables
.
append
(
key:
'CI_COMMIT_AUTHOR'
,
value:
git_author_full_text
.
to_s
)
# legacy variables
variables
.
append
(
key:
'CI_BUILD_REF'
,
value:
sha
)
variables
.
append
(
key:
'CI_BUILD_BEFORE_SHA'
,
value:
before_sha
)
variables
.
append
(
key:
'CI_BUILD_REF_NAME'
,
value:
source_ref
)
variables
.
append
(
key:
'CI_BUILD_REF_SLUG'
,
value:
source_ref_slug
)
variables
.
append
(
key:
'CI_BUILD_TAG'
,
value:
ref
)
if
tag?
end
end
end
def
predefined_merge_request_variables
strong_memoize
(
:predefined_merge_request_variables
)
do
Gitlab
::
Ci
::
Variables
::
Collection
.
new
.
tap
do
|
variables
|
next
variables
unless
merge_request?
variables
.
append
(
key:
'CI_MERGE_REQUEST_EVENT_TYPE'
,
value:
merge_request_event_type
.
to_s
)
variables
.
append
(
key:
'CI_MERGE_REQUEST_SOURCE_BRANCH_SHA'
,
value:
source_sha
.
to_s
)
variables
.
append
(
key:
'CI_MERGE_REQUEST_TARGET_BRANCH_SHA'
,
value:
target_sha
.
to_s
)
diff
=
self
.
merge_request_diff
if
diff
.
present?
variables
.
append
(
key:
'CI_MERGE_REQUEST_DIFF_ID'
,
value:
diff
.
id
.
to_s
)
variables
.
append
(
key:
'CI_MERGE_REQUEST_DIFF_BASE_SHA'
,
value:
diff
.
base_commit_sha
)
end
variables
.
concat
(
merge_request
.
predefined_variables
)
end
end
end
...
...
app/models/project.rb
View file @
084f1ad5
...
...
@@ -2054,14 +2054,16 @@ class Project < ApplicationRecord
end
def
predefined_variables
Gitlab
::
Ci
::
Variables
::
Collection
.
new
.
concat
(
predefined_ci_server_variables
)
.
concat
(
predefined_project_variables
)
.
concat
(
pages_variables
)
.
concat
(
container_registry_variables
)
.
concat
(
dependency_proxy_variables
)
.
concat
(
auto_devops_variables
)
.
concat
(
api_variables
)
strong_memoize
(
:predefined_variables
)
do
Gitlab
::
Ci
::
Variables
::
Collection
.
new
.
concat
(
predefined_ci_server_variables
)
.
concat
(
predefined_project_variables
)
.
concat
(
pages_variables
)
.
concat
(
container_registry_variables
)
.
concat
(
dependency_proxy_variables
)
.
concat
(
auto_devops_variables
)
.
concat
(
api_variables
)
end
end
def
predefined_project_variables
...
...
ee/app/models/ee/project.rb
View file @
084f1ad5
...
...
@@ -808,7 +808,9 @@ module EE
override
:predefined_variables
def
predefined_variables
super
.
concat
(
requirements_ci_variables
)
strong_memoize
(
:ee_predefined_variables
)
do
super
.
concat
(
requirements_ci_variables
)
end
end
def
add_template_export_job
(
current_user
:,
after_export_strategy:
nil
,
params:
{})
...
...
ee/spec/lib/gitlab/ci/templates/Jobs/dast_default_branch_gitlab_ci_yaml_spec.rb
View file @
084f1ad5
...
...
@@ -22,7 +22,7 @@ RSpec.describe 'Jobs/DAST-Default-Branch-Deploy.gitlab-ci.yml' do
end
describe
'the created pipeline'
do
let_it_be
(
:project
)
do
let_it_be
_with_refind
(
:project
)
do
create
(
:project
,
:repository
,
variables:
[
build
(
:ci_variable
,
key:
'CI_KUBERNETES_ACTIVE'
,
value:
'true'
)
])
...
...
ee/spec/lib/gitlab/ci/templates/cluster_image_scanning_gitlab_ci_yaml_spec.rb
View file @
084f1ad5
...
...
@@ -6,7 +6,7 @@ RSpec.describe 'Cluster-Image-Scanning.gitlab-ci.yml' do
subject
(
:template
)
{
Gitlab
::
Template
::
GitlabCiYmlTemplate
.
find
(
'Cluster-Image-Scanning'
)
}
describe
'the created pipeline'
do
let_it_be
(
:project
)
{
create
(
:project
,
:custom_repo
,
files:
{
'README.txt'
=>
''
})
}
let_it_be
_with_refind
(
:project
)
{
create
(
:project
,
:custom_repo
,
files:
{
'README.txt'
=>
''
})
}
let
(
:default_branch
)
{
'master'
}
let
(
:user
)
{
project
.
owner
}
...
...
ee/spec/lib/gitlab/ci/templates/container_scanning_gitlab_ci_yaml_spec.rb
View file @
084f1ad5
...
...
@@ -6,11 +6,11 @@ RSpec.describe 'Container-Scanning.gitlab-ci.yml' do
subject
(
:template
)
{
Gitlab
::
Template
::
GitlabCiYmlTemplate
.
find
(
'Container-Scanning'
)
}
describe
'the created pipeline'
do
let_it_be
(
:project
)
{
create
(
:project
,
:custom_repo
,
files:
{
'README.txt'
=>
''
})
}
let_it_be
_with_refind
(
:project
)
{
create
(
:project
,
:custom_repo
,
files:
{
'README.txt'
=>
''
})
}
let
(
:default_branch
)
{
'master'
}
let
(
:user
)
{
project
.
owner
}
let
(
:service
)
{
Ci
::
CreatePipelineService
.
new
(
project
,
user
,
ref:
'master'
)
}
let
(
:service
)
{
Ci
::
CreatePipelineService
.
new
(
project
,
user
,
ref:
'master'
)
}
let
(
:pipeline
)
{
service
.
execute!
(
:push
).
payload
}
let
(
:build_names
)
{
pipeline
.
builds
.
pluck
(
:name
)
}
...
...
ee/spec/lib/gitlab/ci/templates/license_scanning_gitlab_ci_yaml_spec.rb
View file @
084f1ad5
...
...
@@ -6,7 +6,7 @@ RSpec.describe 'License-Scanning.gitlab-ci.yml' do
subject
(
:template
)
{
Gitlab
::
Template
::
GitlabCiYmlTemplate
.
find
(
'License-Scanning'
)
}
describe
'the created pipeline'
do
let_it_be
(
:project
)
{
create
(
:project
,
:custom_repo
,
files:
{
'README.txt'
=>
''
})
}
let_it_be
_with_refind
(
:project
)
{
create
(
:project
,
:custom_repo
,
files:
{
'README.txt'
=>
''
})
}
let
(
:default_branch
)
{
'master'
}
let
(
:user
)
{
project
.
owner
}
...
...
ee/spec/services/ci/create_pipeline_service/dast_configuration_spec.rb
View file @
084f1ad5
...
...
@@ -3,7 +3,7 @@
require
'spec_helper'
RSpec
.
describe
Ci
::
CreatePipelineService
do
let_it_be
(
:project
)
{
create
(
:project
,
:custom_repo
,
files:
{
'README.txt'
=>
''
})
}
let_it_be
_with_refind
(
:project
)
{
create
(
:project
,
:custom_repo
,
files:
{
'README.txt'
=>
''
})
}
let_it_be
(
:user
)
{
create
(
:user
,
developer_projects:
[
project
])
}
let_it_be
(
:dast_site_profile
)
{
create
(
:dast_site_profile
,
project:
project
)
}
let_it_be
(
:dast_scanner_profile
)
{
create
(
:dast_scanner_profile
,
project:
project
)
}
...
...
spec/services/ci/create_pipeline_service_spec.rb
View file @
084f1ad5
...
...
@@ -5,8 +5,8 @@ require 'spec_helper'
RSpec
.
describe
Ci
::
CreatePipelineService
do
include
ProjectForksHelper
let_it_be
(
:project
,
reload:
true
)
{
create
(
:project
,
:repository
)
}
let_it_be
(
:user
,
reload:
true
)
{
project
.
owner
}
let_it_be
_with_refind
(
:project
)
{
create
(
:project
,
:repository
)
}
let_it_be
_with_reload
(
:user
)
{
project
.
owner
}
let
(
:ref_name
)
{
'refs/heads/master'
}
...
...
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