summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--changelogs/unreleased/enable-auto-cancelling-by-default.yml4
-rw-r--r--db/migrate/20170502065653_make_auto_cancel_pending_pipelines_on_by_default.rb13
-rw-r--r--db/migrate/20170502070007_enable_auto_cancel_pending_pipelines_for_all.rb14
-rw-r--r--db/schema.rb4
-rw-r--r--spec/workers/post_receive_spec.rb6
5 files changed, 38 insertions, 3 deletions
diff --git a/changelogs/unreleased/enable-auto-cancelling-by-default.yml b/changelogs/unreleased/enable-auto-cancelling-by-default.yml
new file mode 100644
index 00000000000..8b1659bf38b
--- /dev/null
+++ b/changelogs/unreleased/enable-auto-cancelling-by-default.yml
@@ -0,0 +1,4 @@
+---
+title: Enable cancelling non-HEAD pending pipelines by default for all projects
+merge_request: 11023
+author:
diff --git a/db/migrate/20170502065653_make_auto_cancel_pending_pipelines_on_by_default.rb b/db/migrate/20170502065653_make_auto_cancel_pending_pipelines_on_by_default.rb
new file mode 100644
index 00000000000..03bf626a08a
--- /dev/null
+++ b/db/migrate/20170502065653_make_auto_cancel_pending_pipelines_on_by_default.rb
@@ -0,0 +1,13 @@
+class MakeAutoCancelPendingPipelinesOnByDefault < ActiveRecord::Migration
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ change_column_default(:projects, :auto_cancel_pending_pipelines, 1)
+ end
+
+ def down
+ change_column_default(:projects, :auto_cancel_pending_pipelines, 0)
+ end
+end
diff --git a/db/migrate/20170502070007_enable_auto_cancel_pending_pipelines_for_all.rb b/db/migrate/20170502070007_enable_auto_cancel_pending_pipelines_for_all.rb
new file mode 100644
index 00000000000..bc43cd34c4d
--- /dev/null
+++ b/db/migrate/20170502070007_enable_auto_cancel_pending_pipelines_for_all.rb
@@ -0,0 +1,14 @@
+class EnableAutoCancelPendingPipelinesForAll < ActiveRecord::Migration
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ connection.execute(
+ 'UPDATE projects SET auto_cancel_pending_pipelines = 1')
+ end
+
+ def down
+ # Nothing we can do!
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 61af066ed3b..79cf95e2c1b 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -981,7 +981,7 @@ ActiveRecord::Schema.define(version: 20170504102911) do
t.boolean "lfs_enabled"
t.text "description_html"
t.boolean "only_allow_merge_if_all_discussions_are_resolved"
- t.integer "auto_cancel_pending_pipelines", default: 0, null: false
+ t.integer "auto_cancel_pending_pipelines", default: 1, null: false
t.boolean "printing_merge_request_link_enabled", default: true, null: false
t.string "import_jid"
t.integer "cached_markdown_version"
@@ -1441,4 +1441,4 @@ ActiveRecord::Schema.define(version: 20170504102911) do
add_foreign_key "timelogs", "merge_requests", name: "fk_timelogs_merge_requests_merge_request_id", on_delete: :cascade
add_foreign_key "trending_projects", "projects", on_delete: :cascade
add_foreign_key "u2f_registrations", "users"
-end
+end \ No newline at end of file
diff --git a/spec/workers/post_receive_spec.rb b/spec/workers/post_receive_spec.rb
index 0260416dbe2..a546ef08d97 100644
--- a/spec/workers/post_receive_spec.rb
+++ b/spec/workers/post_receive_spec.rb
@@ -9,6 +9,10 @@ describe PostReceive do
let(:key) { create(:key, user: project.owner) }
let(:key_id) { key.shell_id }
+ let(:project) do
+ create(:project, :repository, auto_cancel_pending_pipelines: 'disabled')
+ end
+
context "as a resque worker" do
it "reponds to #perform" do
expect(described_class.new).to respond_to(:perform)
@@ -128,4 +132,4 @@ describe PostReceive do
def pwd(project)
File.join(Gitlab.config.repositories.storages.default['path'], project.path_with_namespace)
end
-end
+end \ No newline at end of file