Commit 35b9213c authored by Zeger-Jan van de Weg's avatar Zeger-Jan van de Weg

Add config_source to ci_pipelines

Given the user can soon have multiple config sources for CI, we now store
what type at the time of the pipeline run we chose. This will give us
insight into what triggered the new pipeline so we can display it to the
enduser.
parent 770bcf71
...@@ -57,6 +57,13 @@ export default { ...@@ -57,6 +57,13 @@ export default {
:title="pipeline.yaml_errors"> :title="pipeline.yaml_errors">
yaml invalid yaml invalid
</span> </span>
<span
v-if="pipeline.flags.auto_devops"
v-tooltip
class="label label-info"
title="Pipeline was configured by Auto DevOps">
Auto DevOps
</span>
<span <span
v-if="pipeline.flags.stuck" v-if="pipeline.flags.stuck"
class="js-pipeline-url-stuck label label-warning"> class="js-pipeline-url-stuck label label-warning">
......
...@@ -50,6 +50,11 @@ module Ci ...@@ -50,6 +50,11 @@ module Ci
external: 6 external: 6
} }
enum config_source: {
repository: nil,
auto_devops: 1
}
state_machine :status, initial: :created do state_machine :status, initial: :created do
event :enqueue do event :enqueue do
transition created: :pending transition created: :pending
...@@ -338,10 +343,14 @@ module Ci ...@@ -338,10 +343,14 @@ module Ci
def ci_yaml_file def ci_yaml_file
return @ci_yaml_file if defined?(@ci_yaml_file) return @ci_yaml_file if defined?(@ci_yaml_file)
@ci_yaml_file = (ci_yaml_from_repo || implied_ci_yaml_file).tap do |config| @ci_yaml_file = ci_yaml_from_repo
unless config @ci_yaml_file ||= implied_ci_yaml_file&.tap { self.auto_devops! }
self.yaml_errors = "Failed to load CI/CD config file for #{sha}"
end if @ci_yaml_file
@ci_yaml_file
else
self.yaml_errors = "Failed to load CI/CD config file for #{sha}"
nil
end end
end end
......
...@@ -16,6 +16,7 @@ class PipelineEntity < Grape::Entity ...@@ -16,6 +16,7 @@ class PipelineEntity < Grape::Entity
expose :flags do expose :flags do
expose :latest?, as: :latest expose :latest?, as: :latest
expose :stuck?, as: :stuck expose :stuck?, as: :stuck
expose :auto_devops?, as: :auto_devops
expose :has_yaml_errors?, as: :yaml_errors expose :has_yaml_errors?, as: :yaml_errors
expose :can_retry?, as: :retryable expose :can_retry?, as: :retryable
expose :can_cancel?, as: :cancelable expose :can_cancel?, as: :cancelable
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
"finished-path" => project_pipelines_path(@project, scope: :finished), "finished-path" => project_pipelines_path(@project, scope: :finished),
"branches-path" => project_pipelines_path(@project, scope: :branches), "branches-path" => project_pipelines_path(@project, scope: :branches),
"tags-path" => project_pipelines_path(@project, scope: :tags), "tags-path" => project_pipelines_path(@project, scope: :tags),
"has-ci" => @repository.gitlab_ci_yml, "has-ci" => @repository.gitlab_ci_yml || @project.auto_devops_enabled?,
"ci-lint-path" => ci_lint_path } } "ci-lint-path" => ci_lint_path } }
= page_specific_javascript_bundle_tag('common_vue') = page_specific_javascript_bundle_tag('common_vue')
......
class AddConfigSourceToPipelines < ActiveRecord::Migration
DOWNTIME = false
def change
add_column(:ci_pipelines, :config_source, :integer, allow_null: true)
end
end
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20170828093725) do ActiveRecord::Schema.define(version: 20170824162758) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
...@@ -125,11 +125,10 @@ ActiveRecord::Schema.define(version: 20170828093725) do ...@@ -125,11 +125,10 @@ ActiveRecord::Schema.define(version: 20170828093725) do
t.boolean "prometheus_metrics_enabled", default: false, null: false t.boolean "prometheus_metrics_enabled", default: false, null: false
t.boolean "help_page_hide_commercial_content", default: false t.boolean "help_page_hide_commercial_content", default: false
t.string "help_page_support_url" t.string "help_page_support_url"
t.boolean "password_authentication_enabled"
t.integer "performance_bar_allowed_group_id" t.integer "performance_bar_allowed_group_id"
t.boolean "hashed_storage_enabled", default: false, null: false t.boolean "password_authentication_enabled"
t.boolean "project_export_enabled", default: true, null: false t.boolean "project_export_enabled", default: true, null: false
t.boolean "auto_devops_enabled", default: false, null: false t.boolean "hashed_storage_enabled", default: false, null: false
end end
create_table "audit_events", force: :cascade do |t| create_table "audit_events", force: :cascade do |t|
...@@ -1117,16 +1116,6 @@ ActiveRecord::Schema.define(version: 20170828093725) do ...@@ -1117,16 +1116,6 @@ ActiveRecord::Schema.define(version: 20170828093725) do
add_index "project_authorizations", ["project_id"], name: "index_project_authorizations_on_project_id", using: :btree add_index "project_authorizations", ["project_id"], name: "index_project_authorizations_on_project_id", using: :btree
add_index "project_authorizations", ["user_id", "project_id", "access_level"], name: "index_project_authorizations_on_user_id_project_id_access_level", unique: true, using: :btree add_index "project_authorizations", ["user_id", "project_id", "access_level"], name: "index_project_authorizations_on_user_id_project_id_access_level", unique: true, using: :btree
create_table "project_auto_devops", force: :cascade do |t|
t.integer "project_id"
t.boolean "enabled", default: true
t.string "domain"
t.datetime_with_timezone "created_at", null: false
t.datetime_with_timezone "updated_at", null: false
end
add_index "project_auto_devops", ["project_id"], name: "index_project_auto_devops_on_project_id", using: :btree
create_table "project_features", force: :cascade do |t| create_table "project_features", force: :cascade do |t|
t.integer "project_id" t.integer "project_id"
t.integer "merge_requests_access_level" t.integer "merge_requests_access_level"
...@@ -1210,7 +1199,6 @@ ActiveRecord::Schema.define(version: 20170828093725) do ...@@ -1210,7 +1199,6 @@ ActiveRecord::Schema.define(version: 20170828093725) do
t.string "repository_storage", default: "default", null: false t.string "repository_storage", default: "default", null: false
t.boolean "request_access_enabled", default: false, null: false t.boolean "request_access_enabled", default: false, null: false
t.boolean "has_external_wiki" t.boolean "has_external_wiki"
t.string "ci_config_path"
t.boolean "lfs_enabled" t.boolean "lfs_enabled"
t.text "description_html" t.text "description_html"
t.boolean "only_allow_merge_if_all_discussions_are_resolved" t.boolean "only_allow_merge_if_all_discussions_are_resolved"
...@@ -1218,8 +1206,9 @@ ActiveRecord::Schema.define(version: 20170828093725) do ...@@ -1218,8 +1206,9 @@ ActiveRecord::Schema.define(version: 20170828093725) do
t.integer "auto_cancel_pending_pipelines", default: 1, null: false t.integer "auto_cancel_pending_pipelines", default: 1, null: false
t.string "import_jid" t.string "import_jid"
t.integer "cached_markdown_version" t.integer "cached_markdown_version"
t.text "delete_error"
t.datetime "last_repository_updated_at" t.datetime "last_repository_updated_at"
t.string "ci_config_path"
t.text "delete_error"
t.integer "storage_version", limit: 2 t.integer "storage_version", limit: 2
end end
...@@ -1733,7 +1722,6 @@ ActiveRecord::Schema.define(version: 20170828093725) do ...@@ -1733,7 +1722,6 @@ ActiveRecord::Schema.define(version: 20170828093725) do
add_foreign_key "personal_access_tokens", "users" add_foreign_key "personal_access_tokens", "users"
add_foreign_key "project_authorizations", "projects", on_delete: :cascade add_foreign_key "project_authorizations", "projects", on_delete: :cascade
add_foreign_key "project_authorizations", "users", on_delete: :cascade add_foreign_key "project_authorizations", "users", on_delete: :cascade
add_foreign_key "project_auto_devops", "projects", name: "fk_45436b12b2", on_delete: :cascade
add_foreign_key "project_features", "projects", name: "fk_18513d9b92", on_delete: :cascade add_foreign_key "project_features", "projects", name: "fk_18513d9b92", on_delete: :cascade
add_foreign_key "project_group_links", "projects", name: "fk_daa8cee94c", on_delete: :cascade add_foreign_key "project_group_links", "projects", name: "fk_daa8cee94c", on_delete: :cascade
add_foreign_key "project_import_data", "projects", name: "fk_ffb9ee3a10", on_delete: :cascade add_foreign_key "project_import_data", "projects", name: "fk_ffb9ee3a10", on_delete: :cascade
......
...@@ -794,14 +794,27 @@ describe Ci::Pipeline, :mailer do ...@@ -794,14 +794,27 @@ describe Ci::Pipeline, :mailer do
expect(pipeline.ci_yaml_file).to be_a(String) expect(pipeline.ci_yaml_file).to be_a(String)
expect(pipeline.ci_yaml_file).not_to eq(implied_yml) expect(pipeline.ci_yaml_file).not_to eq(implied_yml)
expect(pipeline.yaml_errors).to be_nil expect(pipeline.yaml_errors).to be_nil
expect(pipeline.repository?).to be(true)
end end
it 'returns the implied configuration when its not found' do context 'when the implied configuration will be used' do
allow_any_instance_of(ApplicationSetting) before do
.to receive(:auto_devops_enabled?) { true } allow_any_instance_of(ApplicationSetting)
allow(pipeline.project).to receive(:ci_config_path) { 'custom' } .to receive(:auto_devops_enabled?) { true }
end
expect(pipeline.ci_yaml_file).to eq(implied_yml) it 'returns the implied configuration when its not found' do
allow(pipeline.project).to receive(:ci_config_path) { 'custom' }
expect(pipeline.ci_yaml_file).to eq(implied_yml)
end
it 'sets the config source' do
allow(pipeline.project).to receive(:ci_config_path) { 'custom' }
expect(pipeline.ci_yaml_file).to eq(implied_yml)
expect(pipeline.auto_devops?).to be(true)
end
end end
end end
......
...@@ -36,7 +36,7 @@ describe PipelineEntity do ...@@ -36,7 +36,7 @@ describe PipelineEntity do
it 'contains flags' do it 'contains flags' do
expect(subject).to include :flags expect(subject).to include :flags
expect(subject[:flags]) expect(subject[:flags])
.to include :latest, :stuck, .to include :latest, :stuck, :auto_devops,
:yaml_errors, :retryable, :cancelable :yaml_errors, :retryable, :cancelable
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