Commit d05af7b7 authored by Paco Guzman's avatar Paco Guzman

Check for Ci::Build artifacts at database level

parent 41057b85
...@@ -25,6 +25,7 @@ v 8.11.0 (unreleased) ...@@ -25,6 +25,7 @@ v 8.11.0 (unreleased)
- Load project invited groups and members eagerly in `ProjectTeam#fetch_members` - Load project invited groups and members eagerly in `ProjectTeam#fetch_members`
- Bump gitlab_git to speedup DiffCollection iterations - Bump gitlab_git to speedup DiffCollection iterations
- Make branches sortable without push permission !5462 (winniehell) - Make branches sortable without push permission !5462 (winniehell)
- Check for Ci::Build artifacts at database level on pipeline partial
- Add GitLab Workhorse version to admin dashboard (Katarzyna Kobierska Ula Budziszewska) - Add GitLab Workhorse version to admin dashboard (Katarzyna Kobierska Ula Budziszewska)
- Add the `sprockets-es6` gem - Add the `sprockets-es6` gem
- Multiple trigger variables show in separate lines (Katarzyna Kobierska Ula Budziszewska) - Multiple trigger variables show in separate lines (Katarzyna Kobierska Ula Budziszewska)
......
...@@ -13,6 +13,7 @@ module Ci ...@@ -13,6 +13,7 @@ module Ci
scope :unstarted, ->() { where(runner_id: nil) } scope :unstarted, ->() { where(runner_id: nil) }
scope :ignore_failures, ->() { where(allow_failure: false) } scope :ignore_failures, ->() { where(allow_failure: false) }
scope :with_artifacts, ->() { where.not(artifacts_file: [nil, '']) } scope :with_artifacts, ->() { where.not(artifacts_file: [nil, '']) }
scope :with_artifacts_not_expired, ->() { with_artifacts.where('artifacts_expire_at IS NULL OR artifacts_expire_at > ?', Time.now) }
scope :with_expired_artifacts, ->() { with_artifacts.where('artifacts_expire_at < ?', Time.now) } scope :with_expired_artifacts, ->() { with_artifacts.where('artifacts_expire_at < ?', Time.now) }
scope :last_month, ->() { where('created_at > ?', Date.today - 1.month) } scope :last_month, ->() { where('created_at > ?', Date.today - 1.month) }
scope :manual_actions, ->() { where(when: :manual) } scope :manual_actions, ->() { where(when: :manual) }
......
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
%td.pipeline-actions %td.pipeline-actions
.controls.hidden-xs.pull-right .controls.hidden-xs.pull-right
- artifacts = pipeline.builds.latest.select { |b| b.artifacts? } - artifacts = pipeline.builds.latest.with_artifacts_not_expired
- actions = pipeline.manual_actions - actions = pipeline.manual_actions
- if artifacts.present? || actions.any? - if artifacts.present? || actions.any?
.btn-group.inline .btn-group.inline
......
...@@ -90,5 +90,21 @@ FactoryGirl.define do ...@@ -90,5 +90,21 @@ FactoryGirl.define do
build.save! build.save!
end end
end end
trait :artifacts_expired do
after(:create) do |build, _|
build.artifacts_file =
fixture_file_upload(Rails.root.join('spec/fixtures/ci_build_artifacts.zip'),
'application/zip')
build.artifacts_metadata =
fixture_file_upload(Rails.root.join('spec/fixtures/ci_build_artifacts_metadata.gz'),
'application/x-gzip')
build.artifacts_expire_at = 1.minute.ago
build.save!
end
end
end end
end end
...@@ -116,9 +116,19 @@ describe "Pipelines" do ...@@ -116,9 +116,19 @@ describe "Pipelines" do
it { expect(page).to have_link(with_artifacts.name) } it { expect(page).to have_link(with_artifacts.name) }
end end
context 'with artifacts expired' do
let!(:with_artifacts_expired) { create(:ci_build, :artifacts_expired, :success, pipeline: pipeline, name: 'rspec', stage: 'test') }
before { visit namespace_project_pipelines_path(project.namespace, project) }
it { expect(page).not_to have_selector('.build-artifacts') }
end
context 'without artifacts' do context 'without artifacts' do
let!(:without_artifacts) { create(:ci_build, :success, pipeline: pipeline, name: 'rspec', stage: 'test') } let!(:without_artifacts) { create(:ci_build, :success, pipeline: pipeline, name: 'rspec', stage: 'test') }
before { visit namespace_project_pipelines_path(project.namespace, project) }
it { expect(page).not_to have_selector('.build-artifacts') } it { expect(page).not_to have_selector('.build-artifacts') }
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment