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
47abf00b
Commit
47abf00b
authored
Mar 30, 2017
by
Bob Van Landuyt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update project build status cache when transitioning
parent
9082d1e0
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
16 additions
and
12 deletions
+16
-12
app/models/ci/pipeline.rb
app/models/ci/pipeline.rb
+2
-3
features/steps/shared/project.rb
features/steps/shared/project.rb
+2
-1
spec/features/dashboard/projects_spec.rb
spec/features/dashboard/projects_spec.rb
+7
-4
spec/helpers/projects_helper_spec.rb
spec/helpers/projects_helper_spec.rb
+1
-1
spec/models/ci/pipeline_spec.rb
spec/models/ci/pipeline_spec.rb
+4
-3
No files found.
app/models/ci/pipeline.rb
View file @
47abf00b
...
@@ -31,7 +31,6 @@ module Ci
...
@@ -31,7 +31,6 @@ module Ci
validate
:valid_commit_sha
,
unless: :importing?
validate
:valid_commit_sha
,
unless: :importing?
after_create
:keep_around_commits
,
unless: :importing?
after_create
:keep_around_commits
,
unless: :importing?
after_create
:refresh_build_status_cache
state_machine
:status
,
initial: :created
do
state_machine
:status
,
initial: :created
do
event
:enqueue
do
event
:enqueue
do
...
@@ -99,6 +98,7 @@ module Ci
...
@@ -99,6 +98,7 @@ module Ci
PipelineHooksWorker
.
perform_async
(
id
)
PipelineHooksWorker
.
perform_async
(
id
)
Ci
::
ExpirePipelineCacheService
.
new
(
project
,
nil
)
Ci
::
ExpirePipelineCacheService
.
new
(
project
,
nil
)
.
execute
(
pipeline
)
.
execute
(
pipeline
)
refresh_project_build_status_cache
end
end
end
end
...
@@ -351,7 +351,6 @@ module Ci
...
@@ -351,7 +351,6 @@ module Ci
when
'manual'
then
block
when
'manual'
then
block
end
end
end
end
refresh_build_status_cache
end
end
def
predefined_variables
def
predefined_variables
...
@@ -393,7 +392,7 @@ module Ci
...
@@ -393,7 +392,7 @@ module Ci
.
fabricate!
.
fabricate!
end
end
def
refresh_build_status_cache
def
refresh_
project_
build_status_cache
Gitlab
::
Cache
::
Ci
::
ProjectBuildStatus
.
new
(
project
,
sha:
sha
,
status:
status
).
store_in_cache_if_needed
Gitlab
::
Cache
::
Ci
::
ProjectBuildStatus
.
new
(
project
,
sha:
sha
,
status:
status
).
store_in_cache_if_needed
end
end
...
...
features/steps/shared/project.rb
View file @
47abf00b
...
@@ -251,7 +251,8 @@ module SharedProject
...
@@ -251,7 +251,8 @@ module SharedProject
step
'project "Shop" has CI build'
do
step
'project "Shop" has CI build'
do
project
=
Project
.
find_by
(
name:
"Shop"
)
project
=
Project
.
find_by
(
name:
"Shop"
)
create
:ci_pipeline
,
project:
project
,
sha:
project
.
commit
.
sha
,
ref:
'master'
,
status:
'skipped'
pipeline
=
create
:ci_pipeline
,
project:
project
,
sha:
project
.
commit
.
sha
,
ref:
'master'
pipeline
.
skip
end
end
step
'I should see last commit with CI status'
do
step
'I should see last commit with CI status'
do
...
...
spec/features/dashboard/projects_spec.rb
View file @
47abf00b
...
@@ -7,7 +7,6 @@ RSpec.describe 'Dashboard Projects', feature: true do
...
@@ -7,7 +7,6 @@ RSpec.describe 'Dashboard Projects', feature: true do
before
do
before
do
project
.
team
<<
[
user
,
:developer
]
project
.
team
<<
[
user
,
:developer
]
login_as
user
login_as
user
visit
dashboard_projects_path
end
end
it
'shows the project the user in a member of in the list'
do
it
'shows the project the user in a member of in the list'
do
...
@@ -15,15 +14,19 @@ RSpec.describe 'Dashboard Projects', feature: true do
...
@@ -15,15 +14,19 @@ RSpec.describe 'Dashboard Projects', feature: true do
expect
(
page
).
to
have_content
(
'awesome stuff'
)
expect
(
page
).
to
have_content
(
'awesome stuff'
)
end
end
describe
"with a pipeline"
do
describe
"with a pipeline"
,
redis:
true
do
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
:success
,
project:
project
,
sha:
project
.
commit
.
sha
)
}
let
!
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
,
sha:
project
.
commit
.
sha
)
}
before
do
before
do
pipeline
# Since the cache isn't updated when a new pipeline is created
# we need the pipeline to advance in the pipeline since the cache was created
# by visiting the login page.
pipeline
.
succeed
end
end
it
'shows that the last pipeline passed'
do
it
'shows that the last pipeline passed'
do
visit
dashboard_projects_path
visit
dashboard_projects_path
expect
(
page
).
to
have_xpath
(
"//a[@href='
#{
pipelines_namespace_project_commit_path
(
project
.
namespace
,
project
,
project
.
commit
)
}
']"
)
expect
(
page
).
to
have_xpath
(
"//a[@href='
#{
pipelines_namespace_project_commit_path
(
project
.
namespace
,
project
,
project
.
commit
)
}
']"
)
end
end
end
end
...
...
spec/helpers/projects_helper_spec.rb
View file @
47abf00b
...
@@ -63,7 +63,7 @@ describe ProjectsHelper do
...
@@ -63,7 +63,7 @@ describe ProjectsHelper do
end
end
end
end
describe
"#project_list_cache_key"
do
describe
"#project_list_cache_key"
,
redis:
true
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:project
)
}
it
"includes the namespace"
do
it
"includes the namespace"
do
...
...
spec/models/ci/pipeline_spec.rb
View file @
47abf00b
...
@@ -1079,17 +1079,18 @@ describe Ci::Pipeline, models: true do
...
@@ -1079,17 +1079,18 @@ describe Ci::Pipeline, models: true do
end
end
end
end
describe
'
#update_status
'
do
describe
'
update project cache when transitioning
'
do
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
sha:
'123456'
)
}
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
sha:
'123456'
)
}
it
'updates the cached status'
do
it
'updates the cached status'
do
fake_status
=
double
fake_status
=
double
expect
(
Gitlab
::
Cache
::
Ci
::
ProjectBuildStatus
).
to
receive
(
:new
).
expect
(
Gitlab
::
Cache
::
Ci
::
ProjectBuildStatus
).
to
receive
(
:new
).
with
(
pipeline
.
project
,
sha:
'123456'
,
status:
'
skipped
'
).
with
(
pipeline
.
project
,
sha:
'123456'
,
status:
'
manual
'
).
and_return
(
fake_status
)
and_return
(
fake_status
)
expect
(
fake_status
).
to
receive
(
:store_in_cache_if_needed
)
expect
(
fake_status
).
to
receive
(
:store_in_cache_if_needed
)
pipeline
.
update_status
pipeline
.
block
end
end
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