From e16560d187f2dd6ff80129a1b3fa641461a8afa0 Mon Sep 17 00:00:00 2001 From: Anton Lubin Date: Fri, 3 Feb 2023 19:28:42 +0500 Subject: [PATCH 1/6] [#377] Delete old fields from database --- .../20230203071725_delete_obsolete_fields_from_repo.rb | 5 +++++ ...3134111_delete_obsolete_fields_from_repo.uffizzi_core.rb | 6 ++++++ 2 files changed, 11 insertions(+) create mode 100644 core/db/migrate/20230203071725_delete_obsolete_fields_from_repo.rb create mode 100644 db/migrate/20230203134111_delete_obsolete_fields_from_repo.uffizzi_core.rb diff --git a/core/db/migrate/20230203071725_delete_obsolete_fields_from_repo.rb b/core/db/migrate/20230203071725_delete_obsolete_fields_from_repo.rb new file mode 100644 index 00000000..c889dc7f --- /dev/null +++ b/core/db/migrate/20230203071725_delete_obsolete_fields_from_repo.rb @@ -0,0 +1,5 @@ +class DeleteObsoleteFieldsFromRepo < ActiveRecord::Migration[6.1] + def change + remove_columns :uffizzi_core_repos, :deploy_preview_when_pull_request_is_opened, :delete_preview_when_pull_request_is_closed, type: :boolean + end +end diff --git a/db/migrate/20230203134111_delete_obsolete_fields_from_repo.uffizzi_core.rb b/db/migrate/20230203134111_delete_obsolete_fields_from_repo.uffizzi_core.rb new file mode 100644 index 00000000..e345141b --- /dev/null +++ b/db/migrate/20230203134111_delete_obsolete_fields_from_repo.uffizzi_core.rb @@ -0,0 +1,6 @@ +# This migration comes from uffizzi_core (originally 20230203071725) +class DeleteObsoleteFieldsFromRepo < ActiveRecord::Migration[6.1] + def change + remove_columns :uffizzi_core_repos, :deploy_preview_when_pull_request_is_opened, :delete_preview_when_pull_request_is_closed, type: :boolean + end +end From a138d618c4718d50e5231aaeb0ed19e9f518a834 Mon Sep 17 00:00:00 2001 From: Anton Lubin Date: Fri, 3 Feb 2023 19:29:22 +0500 Subject: [PATCH 2/6] [#377] Delete old fields --- .../api/cli/v1/deployment/create_form.rb | 2 -- .../api/cli/v1/deployment/update_form.rb | 2 -- .../builders/container_builder_service.rb | 2 -- .../continuous_preview_parser_service.rb | 2 -- core/test/factories/repos.rb | 2 -- uffizzi-compose-example.yml | 18 ++++++++---------- 6 files changed, 8 insertions(+), 20 deletions(-) diff --git a/core/app/forms/uffizzi_core/api/cli/v1/deployment/create_form.rb b/core/app/forms/uffizzi_core/api/cli/v1/deployment/create_form.rb index 8c3e03dc..cb708996 100644 --- a/core/app/forms/uffizzi_core/api/cli/v1/deployment/create_form.rb +++ b/core/app/forms/uffizzi_core/api/cli/v1/deployment/create_form.rb @@ -34,8 +34,6 @@ class UffizziCore::Api::Cli::V1::Deployment::CreateForm < UffizziCore::Deploymen :kind, :dockerfile_path, :dockerfile_context_path, - :deploy_preview_when_pull_request_is_opened, - :delete_preview_when_pull_request_is_closed, :deploy_preview_when_image_tag_is_created, :delete_preview_when_image_tag_is_updated, :share_to_github, diff --git a/core/app/forms/uffizzi_core/api/cli/v1/deployment/update_form.rb b/core/app/forms/uffizzi_core/api/cli/v1/deployment/update_form.rb index e20ca37e..083ab0e7 100644 --- a/core/app/forms/uffizzi_core/api/cli/v1/deployment/update_form.rb +++ b/core/app/forms/uffizzi_core/api/cli/v1/deployment/update_form.rb @@ -33,8 +33,6 @@ class UffizziCore::Api::Cli::V1::Deployment::UpdateForm < UffizziCore::Deploymen :kind, :dockerfile_path, :dockerfile_context_path, - :deploy_preview_when_pull_request_is_opened, - :delete_preview_when_pull_request_is_closed, :deploy_preview_when_image_tag_is_created, :delete_preview_when_image_tag_is_updated, :share_to_github, diff --git a/core/app/services/uffizzi_core/compose_file/builders/container_builder_service.rb b/core/app/services/uffizzi_core/compose_file/builders/container_builder_service.rb index bb85a647..c03e901f 100644 --- a/core/app/services/uffizzi_core/compose_file/builders/container_builder_service.rb +++ b/core/app/services/uffizzi_core/compose_file/builders/container_builder_service.rb @@ -86,8 +86,6 @@ def build_repo_attributes(container_data) def set_continuous_preview_attributes_to_repo(repo_attributes, global_data, container_data) condition_attributes = [ - :deploy_preview_when_pull_request_is_opened, - :delete_preview_when_pull_request_is_closed, :deploy_preview_when_image_tag_is_created, :delete_preview_when_image_tag_is_updated, :share_to_github, diff --git a/core/app/services/uffizzi_core/compose_file/parsers/continuous_preview_parser_service.rb b/core/app/services/uffizzi_core/compose_file/parsers/continuous_preview_parser_service.rb index 5ccb15ce..2cb3223d 100644 --- a/core/app/services/uffizzi_core/compose_file/parsers/continuous_preview_parser_service.rb +++ b/core/app/services/uffizzi_core/compose_file/parsers/continuous_preview_parser_service.rb @@ -6,8 +6,6 @@ def parse(continuous_preview_data) return {} if continuous_preview_data.nil? { - deploy_preview_when_pull_request_is_opened: trigger_value(continuous_preview_data, 'deploy_preview_when_pull_request_is_opened'), - delete_preview_when_pull_request_is_closed: trigger_value(continuous_preview_data, 'delete_preview_when_pull_request_is_closed'), deploy_preview_when_image_tag_is_created: trigger_value(continuous_preview_data, 'deploy_preview_when_image_tag_is_created'), delete_preview_when_image_tag_is_updated: trigger_value(continuous_preview_data, 'delete_preview_when_image_tag_is_updated'), delete_preview_after: delete_preview_after_value(continuous_preview_data['delete_preview_after']), diff --git a/core/test/factories/repos.rb b/core/test/factories/repos.rb index f8ef905b..66e5383b 100644 --- a/core/test/factories/repos.rb +++ b/core/test/factories/repos.rb @@ -9,8 +9,6 @@ branch description repository_id { generate(:number) } - deploy_preview_when_pull_request_is_opened { false } - delete_preview_when_pull_request_is_closed { false } deploy_preview_when_image_tag_is_created { false } delete_preview_when_image_tag_is_updated { false } delete_preview_after { nil } diff --git a/uffizzi-compose-example.yml b/uffizzi-compose-example.yml index 292568f8..e64d80d0 100644 --- a/uffizzi-compose-example.yml +++ b/uffizzi-compose-example.yml @@ -37,14 +37,12 @@ services: context: https://github.com/UffizziCloud/example-voting-result:main dockerfile: Dockerfile -continuous_preview: - deploy_preview_when_pull_request_is_opened: false - delete_preview_when_pull_request_is_closed: false - deploy_preview_for_image_tag_PR_#-branchname: true - delete_preview_when_pull_request_is_closed: false - delete_preview_in_x_hours: 24 - share_to_github: true +x-uffizzi: + continuous_preview: + deploy_preview_when_image_tag_is_created: true + delete_preview_after: 24 + share_to_github: true -ingress: - service: nginx - port: 8080 + ingress: + service: nginx + port: 8080 From 40b4cd40d68f3674ce11423d64f47c520e5094dd Mon Sep 17 00:00:00 2001 From: Anton Lubin Date: Mon, 6 Feb 2023 19:46:16 +0500 Subject: [PATCH 3/6] [#377] Edit docs --- CONTRIBUTING.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d86253e2..9b8b7464 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -80,11 +80,14 @@ bin/rails test In order to add a new migration do the following steps: -1. Add a new migration inside the core +1. Add a new migration to `core/db/migrate`. 2. Run the command inside the `web` container - ```bash rake uffizzi_core:install ``` - This command copies the new migration to the `db/migrate` folder + +3. Migrate both `core` and `web` with +``` +bundler exec rails db:migrate +``` From d2b5826567e5900f6e690f7f87c73a04d55f7621 Mon Sep 17 00:00:00 2001 From: Anton Lubin Date: Wed, 8 Feb 2023 20:01:11 +0500 Subject: [PATCH 4/6] [#377] Lint --- .../migrate/20230203071725_delete_obsolete_fields_from_repo.rb | 2 ++ ...30203134111_delete_obsolete_fields_from_repo.uffizzi_core.rb | 2 ++ 2 files changed, 4 insertions(+) diff --git a/core/db/migrate/20230203071725_delete_obsolete_fields_from_repo.rb b/core/db/migrate/20230203071725_delete_obsolete_fields_from_repo.rb index c889dc7f..7f6368d6 100644 --- a/core/db/migrate/20230203071725_delete_obsolete_fields_from_repo.rb +++ b/core/db/migrate/20230203071725_delete_obsolete_fields_from_repo.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class DeleteObsoleteFieldsFromRepo < ActiveRecord::Migration[6.1] def change remove_columns :uffizzi_core_repos, :deploy_preview_when_pull_request_is_opened, :delete_preview_when_pull_request_is_closed, type: :boolean diff --git a/db/migrate/20230203134111_delete_obsolete_fields_from_repo.uffizzi_core.rb b/db/migrate/20230203134111_delete_obsolete_fields_from_repo.uffizzi_core.rb index e345141b..aed09f74 100644 --- a/db/migrate/20230203134111_delete_obsolete_fields_from_repo.uffizzi_core.rb +++ b/db/migrate/20230203134111_delete_obsolete_fields_from_repo.uffizzi_core.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This migration comes from uffizzi_core (originally 20230203071725) class DeleteObsoleteFieldsFromRepo < ActiveRecord::Migration[6.1] def change From c9403c95daf8fcbb16281527ff9ce2ab6a688dbf Mon Sep 17 00:00:00 2001 From: Anton Lubin Date: Wed, 8 Feb 2023 21:53:41 +0500 Subject: [PATCH 5/6] [#377] Update schemas --- core/test/dummy/db/schema.rb | 2 -- db/schema.rb | 2 -- 2 files changed, 4 deletions(-) diff --git a/core/test/dummy/db/schema.rb b/core/test/dummy/db/schema.rb index b4da150a..b0c5f4da 100644 --- a/core/test/dummy/db/schema.rb +++ b/core/test/dummy/db/schema.rb @@ -336,8 +336,6 @@ t.boolean "share_to_github" t.integer "delete_preview_after" t.string "tag_pattern_deprecated" - t.boolean "deploy_preview_when_pull_request_is_opened" - t.boolean "delete_preview_when_pull_request_is_closed" t.index ["project_id"], name: "index_repos_on_project_id" end diff --git a/db/schema.rb b/db/schema.rb index 334c076d..765abfaf 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -336,8 +336,6 @@ t.boolean "share_to_github" t.integer "delete_preview_after" t.string "tag_pattern_deprecated" - t.boolean "deploy_preview_when_pull_request_is_opened" - t.boolean "delete_preview_when_pull_request_is_closed" t.index ["project_id"], name: "index_repos_on_project_id" end From ac49d2c7841ccf1ba3c50bdad461cac153f93fc2 Mon Sep 17 00:00:00 2001 From: Anton Lubin Date: Wed, 8 Feb 2023 22:10:20 +0500 Subject: [PATCH 6/6] [#377] Lint --- .../migrate/20230203071725_delete_obsolete_fields_from_repo.rb | 3 ++- ...0203134111_delete_obsolete_fields_from_repo.uffizzi_core.rb | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/core/db/migrate/20230203071725_delete_obsolete_fields_from_repo.rb b/core/db/migrate/20230203071725_delete_obsolete_fields_from_repo.rb index 7f6368d6..77daf6ff 100644 --- a/core/db/migrate/20230203071725_delete_obsolete_fields_from_repo.rb +++ b/core/db/migrate/20230203071725_delete_obsolete_fields_from_repo.rb @@ -2,6 +2,7 @@ class DeleteObsoleteFieldsFromRepo < ActiveRecord::Migration[6.1] def change - remove_columns :uffizzi_core_repos, :deploy_preview_when_pull_request_is_opened, :delete_preview_when_pull_request_is_closed, type: :boolean + remove_columns :uffizzi_core_repos, :deploy_preview_when_pull_request_is_opened, :delete_preview_when_pull_request_is_closed, + type: :boolean end end diff --git a/db/migrate/20230203134111_delete_obsolete_fields_from_repo.uffizzi_core.rb b/db/migrate/20230203134111_delete_obsolete_fields_from_repo.uffizzi_core.rb index aed09f74..29fa5570 100644 --- a/db/migrate/20230203134111_delete_obsolete_fields_from_repo.uffizzi_core.rb +++ b/db/migrate/20230203134111_delete_obsolete_fields_from_repo.uffizzi_core.rb @@ -3,6 +3,7 @@ # This migration comes from uffizzi_core (originally 20230203071725) class DeleteObsoleteFieldsFromRepo < ActiveRecord::Migration[6.1] def change - remove_columns :uffizzi_core_repos, :deploy_preview_when_pull_request_is_opened, :delete_preview_when_pull_request_is_closed, type: :boolean + remove_columns :uffizzi_core_repos, :deploy_preview_when_pull_request_is_opened, :delete_preview_when_pull_request_is_closed, + type: :boolean end end