diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2018-09-02 16:35:15 +0200 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2018-09-04 16:12:50 +0200 |
commit | 955a6c3d429bd18716502cef1bcc1bde2759fb85 (patch) | |
tree | 51f9ffd13b786236b3c495604160e660f776f04e | |
parent | 05ee94beb70a2969b85563a0c41bf5afe48a3699 (diff) | |
download | gitlab-ce-955a6c3d429bd18716502cef1bcc1bde2759fb85.tar.gz |
Add dependent model `build_config` that stores all dynamic job configuration
26 files changed, 155 insertions, 67 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index faa160ad6ba..2c182b02f36 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -8,8 +8,11 @@ module Ci include ObjectStorage::BackgroundMove include Presentable include Importable + include IgnorableColumn include Gitlab::Utils::StrongMemoize + ignore_column :commands + belongs_to :project, inverse_of: :builds belongs_to :runner belongs_to :trigger_request @@ -31,6 +34,7 @@ module Ci has_one :"job_artifacts_#{key}", -> { where(file_type: value) }, class_name: 'Ci::JobArtifact', inverse_of: :job, foreign_key: :job_id end + has_one :config, class_name: 'Ci::BuildConfig' has_one :metadata, class_name: 'Ci::BuildMetadata' has_one :runner_session, class_name: 'Ci::BuildRunnerSession', validate: true, inverse_of: :build @@ -150,6 +154,11 @@ module Ci transition created: :manual end + before_transition any => [:pending, :running] do |build| + # forbid transition if job is archived + !build.archived? + end + after_transition any => [:pending] do |build| build.run_after_commit do BuildQueueWorker.perform_async(id) @@ -201,6 +210,12 @@ module Ci metadata || build_metadata(project: project) end + def archived? + return true unless self.options + + !self.options.dig(:script).present? + end + def detailed_status(current_user) Gitlab::Ci::Status::Build::Factory .new(self, current_user) @@ -217,7 +232,7 @@ module Ci end def playable? - action? && (manual? || retryable?) + action? && !archived? && (manual? || retryable?) end def action? @@ -235,7 +250,7 @@ module Ci end def retryable? - success? || failed? || canceled? + (success? || failed? || canceled?) && !archived? end def retries_count @@ -451,12 +466,12 @@ module Ci artifacts_metadata? end - def artifacts_metadata_entry(path, **options) + def artifacts_metadata_entry(path, **params) artifacts_metadata.open do |metadata_stream| metadata = Gitlab::Ci::Build::Artifacts::Metadata.new( metadata_stream, path, - **options) + **params) metadata.to_entry end @@ -519,11 +534,51 @@ module Ci end def when - read_attribute(:when) || build_attributes_from_config[:when] || 'on_success' + read_attribute(:when) || 'on_success' + end + + def config + return unless BuildConfig.available? + + super + end + + def ensure_config + config || build_config + end + + def options + read_attribute(:options) || + config&.yaml_options || + {} + end + + def options=(value) + unless BuildConfig.available? && Feature.enabled?(:ci_use_build_config) + super + return + end + + # save and remove from this model + ensure_config.yaml_options = value + write_attribute(:options, nil) end def yaml_variables - read_attribute(:yaml_variables) || build_attributes_from_config[:yaml_variables] || [] + read_attribute(:yaml_variables) || + config&.yaml_variables || + [] + end + + def yaml_variables=(value) + unless BuildConfig.available? && Feature.enabled?(:ci_use_build_config) + super + return + end + + # save and remove from this model + ensure_config.yaml_variables = value + write_attribute(:yaml_variables, nil) end def user_variables @@ -631,8 +686,8 @@ module Ci trace end - def serializable_hash(options = {}) - super(options).merge(when: read_attribute(:when)) + def serializable_hash(params = {}) + super(params).merge(when: read_attribute(:when)) end def has_terminal? diff --git a/app/models/ci/build_config.rb b/app/models/ci/build_config.rb new file mode 100644 index 00000000000..2401b8b514b --- /dev/null +++ b/app/models/ci/build_config.rb @@ -0,0 +1,20 @@ +module Ci + class BuildConfig < ActiveRecord::Base + extend Gitlab::Ci::Model + + # The version of the schema that first introduced this model/table. + MINIMUM_SCHEMA_VERSION = 20180831115821 + + def self.available? + @available ||= + ActiveRecord::Migrator.current_version >= MINIMUM_SCHEMA_VERSION + end + + self.table_name = 'ci_builds_config' + + belongs_to :build + + serialize :yaml_options # rubocop:disable Cop/ActiveRecordSerialize + serialize :yaml_variables, Gitlab::Serializer::Ci::Variables # rubocop:disable Cop/ActiveRecordSerialize + end +end diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb index b65d7672973..a61f526feac 100644 --- a/app/models/commit_status.rb +++ b/app/models/commit_status.rb @@ -49,7 +49,8 @@ class CommitStatus < ActiveRecord::Base stuck_or_timeout_failure: 3, runner_system_failure: 4, missing_dependency_failure: 5, - runner_unsupported: 6 + runner_unsupported: 6, + archived_failure: 7 } ## diff --git a/app/presenters/commit_status_presenter.rb b/app/presenters/commit_status_presenter.rb index a08f34e2335..b2503a30165 100644 --- a/app/presenters/commit_status_presenter.rb +++ b/app/presenters/commit_status_presenter.rb @@ -8,7 +8,8 @@ class CommitStatusPresenter < Gitlab::View::Presenter::Delegated stuck_or_timeout_failure: 'There has been a timeout failure or the job got stuck. Check your timeout limits or try again', runner_system_failure: 'There has been a runner system failure, please try again', missing_dependency_failure: 'There has been a missing dependency failure', - runner_unsupported: 'Your runner is outdated, please upgrade your runner' + runner_unsupported: 'Your runner is outdated, please upgrade your runner', + archived_failure: 'The job is not playable as it is archived' }.freeze presents :build @@ -22,6 +23,6 @@ class CommitStatusPresenter < Gitlab::View::Presenter::Delegated end def unrecoverable? - script_failure? || missing_dependency_failure? + script_failure? || missing_dependency_failure? || archived_failure? end end diff --git a/app/services/ci/register_job_service.rb b/app/services/ci/register_job_service.rb index 11f85627faf..35f72005b21 100644 --- a/app/services/ci/register_job_service.rb +++ b/app/services/ci/register_job_service.rb @@ -70,6 +70,11 @@ module Ci build.runner_id = runner.id build.runner_session_attributes = params[:session] if params[:session].present? + if build.archived? + build.drop!(:archived_failure) + return false + end + unless build.has_valid_build_dependencies? build.drop!(:missing_dependency_failure) return false diff --git a/app/services/ci/retry_build_service.rb b/app/services/ci/retry_build_service.rb index 6ceb59e4780..18e4a51214a 100644 --- a/app/services/ci/retry_build_service.rb +++ b/app/services/ci/retry_build_service.rb @@ -2,7 +2,7 @@ module Ci class RetryBuildService < ::BaseService - CLONE_ACCESSORS = %i[pipeline project ref tag options commands name + CLONE_ACCESSORS = %i[pipeline project ref tag options name allow_failure stage stage_id stage_idx trigger_request yaml_variables when environment coverage_regex description tag_list protected].freeze @@ -24,6 +24,10 @@ module Ci raise Gitlab::Access::AccessDeniedError end + if build.archived? + raise Gitlab::Access::AccessDeniedError, "job archived" + end + attributes = CLONE_ACCESSORS.map do |attribute| [attribute, build.public_send(attribute)] # rubocop:disable GitlabSecurity/PublicSend end diff --git a/db/fixtures/development/14_pipelines.rb b/db/fixtures/development/14_pipelines.rb index 5535c4a14e5..603332d7d0b 100644 --- a/db/fixtures/development/14_pipelines.rb +++ b/db/fixtures/development/14_pipelines.rb @@ -92,14 +92,15 @@ class Gitlab::Seeder::Pipelines [] end - def create_pipeline!(project, ref, commit) project.pipelines.create!(sha: commit.id, ref: ref, source: :push) end def build_create!(pipeline, opts = {}) attributes = job_attributes(pipeline, opts) - .merge(commands: '$ build command') + + attributes[:options] ||= {} + attributes[:options][:script] = 'build command' Ci::Build.create!(attributes).tap do |build| # We need to set build trace and artifacts after saving a build diff --git a/db/migrate/20180831115821_create_ci_builds_config.rb b/db/migrate/20180831115821_create_ci_builds_config.rb new file mode 100644 index 00000000000..5eafa6b7937 --- /dev/null +++ b/db/migrate/20180831115821_create_ci_builds_config.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class CreateCiBuildsConfig < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def change + create_table :ci_builds_config, id: :bigserial do |t| + t.integer :build_id, null: false + t.text :yaml_options + t.text :yaml_variables + t.index :build_id, unique: true + t.foreign_key :ci_builds, column: :build_id, on_delete: :cascade + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 02e545bec7d..498adc99d02 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20180826111825) do +ActiveRecord::Schema.define(version: 20180831115821) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -352,6 +352,14 @@ ActiveRecord::Schema.define(version: 20180826111825) do add_index "ci_builds", ["updated_at"], name: "index_ci_builds_on_updated_at", using: :btree add_index "ci_builds", ["user_id"], name: "index_ci_builds_on_user_id", using: :btree + create_table "ci_builds_config", id: :bigserial, force: :cascade do |t| + t.integer "build_id", null: false + t.text "yaml_options" + t.text "yaml_variables" + end + + add_index "ci_builds_config", ["build_id"], name: "index_ci_builds_config_on_build_id", unique: true, using: :btree + create_table "ci_builds_metadata", force: :cascade do |t| t.integer "build_id", null: false t.integer "project_id", null: false @@ -2262,6 +2270,7 @@ ActiveRecord::Schema.define(version: 20180826111825) do add_foreign_key "ci_builds", "ci_pipelines", column: "commit_id", name: "fk_d3130c9a7f", on_delete: :cascade add_foreign_key "ci_builds", "ci_stages", column: "stage_id", name: "fk_3a9eaa254d", on_delete: :cascade add_foreign_key "ci_builds", "projects", name: "fk_befce0568a", on_delete: :cascade + add_foreign_key "ci_builds_config", "ci_builds", column: "build_id", on_delete: :cascade add_foreign_key "ci_builds_metadata", "ci_builds", column: "build_id", on_delete: :cascade add_foreign_key "ci_builds_metadata", "projects", on_delete: :cascade add_foreign_key "ci_builds_runner_session", "ci_builds", column: "build_id", on_delete: :cascade diff --git a/lib/gitlab/ci/build/step.rb b/lib/gitlab/ci/build/step.rb index 0b1ebe4e048..e7c4b566410 100644 --- a/lib/gitlab/ci/build/step.rb +++ b/lib/gitlab/ci/build/step.rb @@ -13,7 +13,6 @@ module Gitlab def from_commands(job) self.new(:script).tap do |step| step.script = job.options[:before_script].to_a + job.options[:script].to_a - step.script = job.commands.split("\n") if step.script.empty? step.timeout = job.metadata_timeout step.when = WHEN_ON_SUCCESS end diff --git a/lib/gitlab/ci/config/entry/job.rb b/lib/gitlab/ci/config/entry/job.rb index 91aac6df4b1..222360f3252 100644 --- a/lib/gitlab/ci/config/entry/job.rb +++ b/lib/gitlab/ci/config/entry/job.rb @@ -103,10 +103,6 @@ module Gitlab @config.merge(to_hash.compact) end - def commands - (before_script_value.to_a + script_value.to_a).join("\n") - end - def manual_action? self.when == 'manual' end @@ -134,7 +130,6 @@ module Gitlab { name: name, before_script: before_script_value, script: script_value, - commands: commands, image: image_value, services: services_value, stage: stage_value, diff --git a/lib/gitlab/ci/status/build/failed.rb b/lib/gitlab/ci/status/build/failed.rb index 508b4814631..fcc8f21275d 100644 --- a/lib/gitlab/ci/status/build/failed.rb +++ b/lib/gitlab/ci/status/build/failed.rb @@ -10,7 +10,8 @@ module Gitlab stuck_or_timeout_failure: 'stuck or timeout failure', runner_system_failure: 'runner system failure', missing_dependency_failure: 'missing dependency failure', - runner_unsupported: 'unsupported runner' + runner_unsupported: 'unsupported runner', + archived_failure: 'job archived' }.freeze def status_tooltip diff --git a/lib/gitlab/ci/yaml_processor.rb b/lib/gitlab/ci/yaml_processor.rb index e829f2a95f8..915498fa05c 100644 --- a/lib/gitlab/ci/yaml_processor.rb +++ b/lib/gitlab/ci/yaml_processor.rb @@ -31,7 +31,6 @@ module Gitlab { stage_idx: @stages.index(job[:stage]), stage: job[:stage], - commands: job[:commands], tag_list: job[:tags] || [], name: job[:name].to_s, allow_failure: job[:ignore], diff --git a/spec/factories/ci/builds.rb b/spec/factories/ci/builds.rb index 9813190925b..f8d927132d4 100644 --- a/spec/factories/ci/builds.rb +++ b/spec/factories/ci/builds.rb @@ -7,7 +7,6 @@ FactoryBot.define do stage_idx 0 ref 'master' tag false - commands 'ls -a' protected false created_at 'Di 29. Okt 09:50:00 CET 2013' pending @@ -15,7 +14,8 @@ FactoryBot.define do options do { image: 'ruby:2.1', - services: ['postgres'] + services: ['postgres'], + script: ['ls -a'] } end @@ -77,7 +77,8 @@ FactoryBot.define do trait :teardown_environment do environment 'staging' - options environment: { name: 'staging', + options script: ['bash'], + environment: { name: 'staging', action: 'stop', url: 'http://staging.example.com/$CI_JOB_NAME' } end @@ -214,6 +215,7 @@ FactoryBot.define do { image: { name: 'ruby:2.1', entrypoint: '/bin/sh' }, services: ['postgres', { name: 'docker:stable-dind', entrypoint: '/bin/sh', command: 'sleep 30', alias: 'docker' }], + script: ['bash'], after_script: %w(ls date), artifacts: { name: 'artifacts_file', diff --git a/spec/features/merge_request/user_sees_mini_pipeline_graph_spec.rb b/spec/features/merge_request/user_sees_mini_pipeline_graph_spec.rb index 0272d300e06..d8f45c7e3ba 100644 --- a/spec/features/merge_request/user_sees_mini_pipeline_graph_spec.rb +++ b/spec/features/merge_request/user_sees_mini_pipeline_graph_spec.rb @@ -5,7 +5,7 @@ describe 'Merge request < User sees mini pipeline graph', :js do let(:user) { project.creator } let(:merge_request) { create(:merge_request, source_project: project, head_pipeline: pipeline) } let(:pipeline) { create(:ci_empty_pipeline, project: project, ref: 'master', status: 'running', sha: project.commit.id) } - let(:build) { create(:ci_build, pipeline: pipeline, stage: 'test', commands: 'test') } + let(:build) { create(:ci_build, pipeline: pipeline, stage: 'test', options: { script: 'test' }) } before do build.run diff --git a/spec/features/projects/pipelines/pipeline_spec.rb b/spec/features/projects/pipelines/pipeline_spec.rb index 603503a531c..896dab35eca 100644 --- a/spec/features/projects/pipelines/pipeline_spec.rb +++ b/spec/features/projects/pipelines/pipeline_spec.rb @@ -18,7 +18,7 @@ describe 'Pipeline', :js do let!(:build_failed) do create(:ci_build, :failed, - pipeline: pipeline, stage: 'test', name: 'test', commands: 'test') + pipeline: pipeline, stage: 'test', name: 'test', options: { script: 'test' }) end let!(:build_running) do diff --git a/spec/features/projects/pipelines/pipelines_spec.rb b/spec/features/projects/pipelines/pipelines_spec.rb index 26a92f14787..f198e0c8031 100644 --- a/spec/features/projects/pipelines/pipelines_spec.rb +++ b/spec/features/projects/pipelines/pipelines_spec.rb @@ -109,7 +109,7 @@ describe 'Pipelines', :js do let!(:build) do create(:ci_build, pipeline: pipeline, stage: 'test', - commands: 'test') + options: { script: 'test' }) end before do @@ -140,7 +140,7 @@ describe 'Pipelines', :js do let!(:build) do create(:ci_build, pipeline: pipeline, stage: 'test', - commands: 'test') + options: { script: 'test' }) end before do @@ -202,7 +202,7 @@ describe 'Pipelines', :js do pipeline: pipeline, name: 'manual build', stage: 'test', - commands: 'test') + options: { script: 'test' }) end before do diff --git a/spec/lib/gitlab/ci/build/step_spec.rb b/spec/lib/gitlab/ci/build/step_spec.rb index cce4efaa069..e3136fc925e 100644 --- a/spec/lib/gitlab/ci/build/step_spec.rb +++ b/spec/lib/gitlab/ci/build/step_spec.rb @@ -18,13 +18,6 @@ describe Gitlab::Ci::Build::Step do end end - context 'when commands are specified' do - it_behaves_like 'has correct script' do - let(:job) { create(:ci_build, :no_options, commands: "ls -la\ndate") } - let(:script) { ['ls -la', 'date'] } - end - end - context 'when script option is specified' do it_behaves_like 'has correct script' do let(:job) { create(:ci_build, :no_options, options: { script: ["ls -la\necho aaa", "date"] }) } @@ -62,7 +55,7 @@ describe Gitlab::Ci::Build::Step do end context 'when after_script is not empty' do - let(:job) { create(:ci_build, options: { after_script: ['ls -la', 'date'] }) } + let(:job) { create(:ci_build, options: { script: ['bash'], after_script: ['ls -la', 'date'] }) } it 'fabricates an object' do expect(subject.name).to eq(:after_script) diff --git a/spec/lib/gitlab/ci/config/entry/global_spec.rb b/spec/lib/gitlab/ci/config/entry/global_spec.rb index 1860ed79bfd..25282f8ff30 100644 --- a/spec/lib/gitlab/ci/config/entry/global_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/global_spec.rb @@ -153,7 +153,6 @@ describe Gitlab::Ci::Config::Entry::Global do rspec: { name: :rspec, script: %w[rspec ls], before_script: %w(ls pwd), - commands: "ls\npwd\nrspec\nls", image: { name: 'ruby:2.2' }, services: [{ name: 'postgres:9.1' }, { name: 'mysql:5.5' }], stage: 'test', @@ -164,7 +163,6 @@ describe Gitlab::Ci::Config::Entry::Global do spinach: { name: :spinach, before_script: [], script: %w[spinach], - commands: 'spinach', image: { name: 'ruby:2.2' }, services: [{ name: 'postgres:9.1' }, { name: 'mysql:5.5' }], stage: 'test', diff --git a/spec/lib/gitlab/ci/config/entry/job_spec.rb b/spec/lib/gitlab/ci/config/entry/job_spec.rb index 6769f64f950..4e207e4e9e9 100644 --- a/spec/lib/gitlab/ci/config/entry/job_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/job_spec.rb @@ -189,7 +189,6 @@ describe Gitlab::Ci::Config::Entry::Job do .to eq(name: :rspec, before_script: %w[ls pwd], script: %w[rspec], - commands: "ls\npwd\nrspec", stage: 'test', ignore: false, after_script: %w[cleanup]) diff --git a/spec/lib/gitlab/ci/config/entry/jobs_spec.rb b/spec/lib/gitlab/ci/config/entry/jobs_spec.rb index c0a2b6517e3..0261caae671 100644 --- a/spec/lib/gitlab/ci/config/entry/jobs_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/jobs_spec.rb @@ -65,12 +65,10 @@ describe Gitlab::Ci::Config::Entry::Jobs do expect(entry.value).to eq( rspec: { name: :rspec, script: %w[rspec], - commands: 'rspec', ignore: false, stage: 'test' }, spinach: { name: :spinach, script: %w[spinach], - commands: 'spinach', ignore: false, stage: 'test' }) end diff --git a/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb b/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb index fffa727c2ed..b37e11ca967 100644 --- a/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb @@ -5,8 +5,7 @@ describe Gitlab::Ci::Pipeline::Seed::Build do let(:attributes) do { name: 'rspec', - ref: 'master', - commands: 'rspec' } + ref: 'master' } end subject do diff --git a/spec/lib/gitlab/ci/yaml_processor_spec.rb b/spec/lib/gitlab/ci/yaml_processor_spec.rb index e73cdc54a15..76a26e21836 100644 --- a/spec/lib/gitlab/ci/yaml_processor_spec.rb +++ b/spec/lib/gitlab/ci/yaml_processor_spec.rb @@ -21,7 +21,6 @@ module Gitlab stage: "test", stage_idx: 1, name: "rspec", - commands: "pwd\nrspec", coverage_regex: nil, tag_list: [], options: { @@ -140,7 +139,6 @@ module Gitlab builds: [{ stage_idx: 1, stage: "test", - commands: "rspec", tag_list: [], name: "rspec", allow_failure: false, @@ -156,7 +154,6 @@ module Gitlab builds: [{ stage_idx: 2, stage: "deploy", - commands: "cap prod", tag_list: [], name: "prod", allow_failure: false, @@ -256,7 +253,7 @@ module Gitlab end it "return commands with scripts concencaced" do - expect(subject[:commands]).to eq("global script\nscript") + expect(subject[:options][:before_script]).to eq(["global script"]) end end @@ -269,7 +266,7 @@ module Gitlab end it "return commands with scripts concencaced" do - expect(subject[:commands]).to eq("local script\nscript") + expect(subject[:options][:before_script]).to eq(["local script"]) end end end @@ -282,7 +279,7 @@ module Gitlab end it "return commands with scripts concencaced" do - expect(subject[:commands]).to eq("script") + expect(subject[:options][:script]).to eq(["script"]) end end @@ -332,7 +329,6 @@ module Gitlab stage: "test", stage_idx: 1, name: "rspec", - commands: "pwd\nrspec", coverage_regex: nil, tag_list: [], options: { @@ -367,7 +363,6 @@ module Gitlab stage: "test", stage_idx: 1, name: "rspec", - commands: "pwd\nrspec", coverage_regex: nil, tag_list: [], options: { @@ -400,7 +395,6 @@ module Gitlab stage: "test", stage_idx: 1, name: "rspec", - commands: "pwd\nrspec", coverage_regex: nil, tag_list: [], options: { @@ -429,7 +423,6 @@ module Gitlab stage: "test", stage_idx: 1, name: "rspec", - commands: "pwd\nrspec", coverage_regex: nil, tag_list: [], options: { @@ -675,7 +668,6 @@ module Gitlab stage: "test", stage_idx: 1, name: "rspec", - commands: "pwd\nrspec", coverage_regex: nil, tag_list: [], options: { @@ -889,7 +881,6 @@ module Gitlab stage: "test", stage_idx: 1, name: "normal_job", - commands: "test", coverage_regex: nil, tag_list: [], options: { @@ -937,7 +928,6 @@ module Gitlab stage: "build", stage_idx: 0, name: "job1", - commands: "execute-script-for-job", coverage_regex: nil, tag_list: [], options: { @@ -952,7 +942,6 @@ module Gitlab stage: "build", stage_idx: 0, name: "job2", - commands: "execute-script-for-job", coverage_regex: nil, tag_list: [], options: { diff --git a/spec/presenters/ci/build_presenter_spec.rb b/spec/presenters/ci/build_presenter_spec.rb index 547d95e0908..6c7d8a1c011 100644 --- a/spec/presenters/ci/build_presenter_spec.rb +++ b/spec/presenters/ci/build_presenter_spec.rb @@ -231,7 +231,7 @@ describe Ci::BuildPresenter do let(:build) { create(:ci_build, :failed, :script_failure) } context 'when is a script or missing dependency failure' do - let(:failure_reasons) { %w(script_failure missing_dependency_failure) } + let(:failure_reasons) { %w(script_failure missing_dependency_failure archived_failure) } it 'should return false' do failure_reasons.each do |failure_reason| diff --git a/spec/requests/api/runner_spec.rb b/spec/requests/api/runner_spec.rb index 43ceb332cfb..dc6163e326a 100644 --- a/spec/requests/api/runner_spec.rb +++ b/spec/requests/api/runner_spec.rb @@ -267,7 +267,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do let(:runner) { create(:ci_runner, :project, projects: [project]) } let(:job) do create(:ci_build, :artifacts, :extended_options, - pipeline: pipeline, name: 'spinach', stage: 'test', stage_idx: 0, commands: "ls\ndate") + pipeline: pipeline, name: 'spinach', stage: 'test', stage_idx: 0) end describe 'POST /api/v4/jobs/request' do @@ -402,7 +402,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do let(:expected_steps) do [{ 'name' => 'script', - 'script' => %w(ls date), + 'script' => %w(bash), 'timeout' => job.metadata_timeout, 'when' => 'on_success', 'allow_failure' => false }, @@ -568,7 +568,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do let!(:test_job) do create(:ci_build, pipeline: pipeline, token: 'test-job-token', name: 'deploy', stage: 'deploy', stage_idx: 1, - options: { dependencies: [job2.name] }) + options: { script: ['bash'], dependencies: [job2.name] }) end before do @@ -592,7 +592,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do let!(:empty_dependencies_job) do create(:ci_build, pipeline: pipeline, token: 'test-job-token', name: 'empty_dependencies_job', stage: 'deploy', stage_idx: 1, - options: { dependencies: [] }) + options: { script: ['bash'], dependencies: [] }) end before do diff --git a/spec/services/ci/process_pipeline_service_spec.rb b/spec/services/ci/process_pipeline_service_spec.rb index feb5120bc68..b8adddf1916 100644 --- a/spec/services/ci/process_pipeline_service_spec.rb +++ b/spec/services/ci/process_pipeline_service_spec.rb @@ -493,9 +493,9 @@ describe Ci::ProcessPipelineService, '#execute' do context 'when builds with auto-retries are configured' do before do - create_build('build:1', stage_idx: 0, user: user, options: { retry: 2 }) + create_build('build:1', stage_idx: 0, user: user, options: { script: 'aa', retry: 2 }) create_build('test:1', stage_idx: 1, user: user, when: :on_failure) - create_build('test:2', stage_idx: 1, user: user, options: { retry: 1 }) + create_build('test:2', stage_idx: 1, user: user, options: { script: 'aa', retry: 1 }) end it 'automatically retries builds in a valid order' do |