Skip to content
代码片段 群组 项目
未验证 提交 29f63398 编辑于 作者: Lin Jen-Shin's avatar Lin Jen-Shin 提交者: GitLab
浏览文件

Merge branch 'pl-spec-factories-predictive-create' into 'master'

CI: Skip testing factory creations in predictive and fail-fast jobs

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/149821



Merged-by: default avatarLin Jen-Shin <jen-shin@gitlab.com>
Approved-by: default avatarDavid Dieulivol <ddieulivol@gitlab.com>
Approved-by: default avatarLin Jen-Shin <jen-shin@gitlab.com>
Co-authored-by: default avatarPeter Leitzen <pleitzen@gitlab.com>
No related branches found
No related tags found
无相关合并请求
...@@ -82,6 +82,7 @@ ...@@ -82,6 +82,7 @@
].freeze ].freeze
geo_configured = Gitlab.ee? && Gitlab::Geo.geo_database_configured? geo_configured = Gitlab.ee? && Gitlab::Geo.geo_database_configured?
check_create = !Support::GitlabCi.predictive_job? && !Support::GitlabCi.fail_fast_job?
shared_examples 'factory' do |factory| shared_examples 'factory' do |factory|
skip_any = skipped.include?([factory.name, any]) skip_any = skipped.include?([factory.name, any])
...@@ -107,7 +108,7 @@ ...@@ -107,7 +108,7 @@
expect { build(factory.name) }.not_to raise_error expect { build(factory.name) }.not_to raise_error
end end
it 'does not raise error when created' do it 'does not raise error when created', if: check_create do
pending 'Factory skipped linting due to legacy error' if skip_any pending 'Factory skipped linting due to legacy error' if skip_any
expect { create(factory.name) }.not_to raise_error # rubocop:disable Rails/SaveBang expect { create(factory.name) }.not_to raise_error # rubocop:disable Rails/SaveBang
...@@ -117,7 +118,7 @@ ...@@ -117,7 +118,7 @@
skip_trait = skip_any || skipped.include?([factory.name, trait_name.to_sym]) skip_trait = skip_any || skipped.include?([factory.name, trait_name.to_sym])
describe "linting :#{trait_name} trait" do describe "linting :#{trait_name} trait" do
it 'does not raise error when created' do it 'does not raise error when created', if: check_create do
skip 'Trait skipped linting due to legacy error' if skip_trait skip 'Trait skipped linting due to legacy error' if skip_trait
expect { create(factory.name, trait_name) }.not_to raise_error expect { create(factory.name, trait_name) }.not_to raise_error
......
# frozen_string_literal: true
module Support
module GitlabCi
module_function
def predictive_job?
ENV['CI_JOB_NAME']&.include?('predictive')
end
def fail_fast_job?
ENV['CI_JOB_NAME']&.include?('fail-fast')
end
end
end
# frozen_string_literal: true
require 'fast_spec_helper'
require 'rspec-parameterized'
require_relative '../../support/helpers/gitlab_ci'
RSpec.describe Support::GitlabCi, feature_category: :tooling do # rubocop:disable RSpec/FilePath -- Avoid deep nesting
using RSpec::Parameterized::TableSyntax
describe '.predictive_job?' do
before do
stub_env('CI_JOB_NAME', name)
end
subject { described_class.predictive_job? }
where(:name, :expected) do
'rspec-ee unit predictive 4/4' | be_truthy
'rspec system predictive 1/4' | be_truthy
'rspec unit 1/4' | be_falsey
nil | be_falsey
end
with_them do
it { is_expected.to expected }
end
end
describe '.fail_fast_job?' do
before do
stub_env('CI_JOB_NAME', name)
end
subject { described_class.fail_fast_job? }
where(:name, :expected) do
'rspec fail-fast' | be_truthy
'rspec-ee fail-fast' | be_truthy
'rspec-ee unit predictive 4/4' | be_falsey
nil | be_falsey
end
with_them do
it { is_expected.to expected }
end
end
end
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册