diff --git a/CHANGELOG.md b/CHANGELOG.md index 537a031a8..32ea5f3d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Unreleased +# 0.45.5 +* Fix order of banners when global lock is enabled +* (bugfix) Widen `check_runs.details_url` and `check_runs.html_url` from 255 to 2048 characters. On MySQL, a + check run with a longer `details_url` raised `ActiveRecord::ValueTooLong`, and `Shipit::Commit#refresh_check_runs!` + stopped before it refreshed the remaining check runs of that commit. Install the new migration with + `rake shipit:install:migrations db:migrate`. + # 0.45.4 * (performance) Preload commit statuses and check runs when serializing deploys. `DeploySerializer` embeds every commit of a deploy and `CommitSerializer` reads each commit's status, so rendering a diff --git a/Gemfile.lock b/Gemfile.lock index 7b176d342..31799a54e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - shipit-engine (0.45.4) + shipit-engine (0.45.5) active_model_serializers (~> 0.9.3) ansi_stream (~> 0.0.6) autoprefixer-rails (~> 6.4.1) diff --git a/app/views/shipit/stacks/_banners.html.erb b/app/views/shipit/stacks/_banners.html.erb index bb1184ff9..1da154a68 100644 --- a/app/views/shipit/stacks/_banners.html.erb +++ b/app/views/shipit/stacks/_banners.html.erb @@ -62,7 +62,18 @@ <% end %> -<% if stack.continuous_delivery_delayed? %> +<% if !stack.deployment_checks_passed? %> + +<% elsif stack.continuous_delivery_delayed? %> -<% elsif !stack.deployment_checks_passed? %> - <% end %> diff --git a/lib/shipit/version.rb b/lib/shipit/version.rb index 9dfb6daa9..23b241872 100644 --- a/lib/shipit/version.rb +++ b/lib/shipit/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Shipit - VERSION = '0.45.4' + VERSION = '0.45.5' end diff --git a/test/controllers/stacks_controller_test.rb b/test/controllers/stacks_controller_test.rb index 6d82212c7..5e68f557c 100644 --- a/test/controllers/stacks_controller_test.rb +++ b/test/controllers/stacks_controller_test.rb @@ -109,6 +109,44 @@ class StacksControllerTest < ActionController::TestCase assert_select 'a[href="http://google.com"]' end + test "#show displays the external lock banner instead of the CD delayed banner when deployment checks fail" do + deployment_checks = Module.new do + def self.call(_stack) + false + end + + def self.message(_stack) + "Deploys were locked via Infra Central" + end + end + Shipit.stubs(:deployment_checks).returns(deployment_checks) + @stack.update!(continuous_deployment: true, continuous_delivery_delayed_since: Time.now.utc) + assert_predicate @stack, :continuous_delivery_delayed? + + get :show, params: { id: @stack.to_param } + + assert_response :ok + assert_select ".banner__title", text: "Stack has been locked by external system!" + assert_select ".banner__content", text: /Deploys were locked via Infra Central/ + assert_select ".banner__title", text: "Continuous Delivery Delayed!", count: 0 + end + + test "#show displays the CD delayed banner when deployment checks pass" do + deployment_checks = Module.new do + def self.call(_stack) + true + end + end + Shipit.stubs(:deployment_checks).returns(deployment_checks) + @stack.update!(continuous_deployment: true, continuous_delivery_delayed_since: Time.now.utc) + + get :show, params: { id: @stack.to_param } + + assert_response :ok + assert_select ".banner__title", text: "Continuous Delivery Delayed!" + assert_select ".banner__title", text: "Stack has been locked by external system!", count: 0 + end + test "#create creates a Stack, queues a job to setup webhooks and redirects to it" do assert_difference "Stack.count" do post :create, params: { diff --git a/test/dummy/db/schema.rb b/test/dummy/db/schema.rb index f784bc6fc..01090593f 100644 --- a/test/dummy/db/schema.rb +++ b/test/dummy/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[8.1].define(version: 2025_02_07_203053) do +ActiveRecord::Schema[8.1].define(version: 2026_09_28_141005) do create_table "api_clients", force: :cascade do |t| t.datetime "created_at", null: false t.integer "creator_id", limit: 4 @@ -25,10 +25,10 @@ t.integer "commit_id", null: false t.string "conclusion", limit: 20 t.datetime "created_at", null: false - t.string "details_url" + t.string "details_url", limit: 2048 t.bigint "github_id", null: false t.datetime "github_updated_at" - t.string "html_url" + t.string "html_url", limit: 2048 t.string "name", null: false t.integer "stack_id", null: false t.string "title", limit: 1024 diff --git a/test/models/shipit/check_run_test.rb b/test/models/shipit/check_run_test.rb index 138c3c182..187a839ec 100644 --- a/test/models/shipit/check_run_test.rb +++ b/test/models/shipit/check_run_test.rb @@ -137,6 +137,18 @@ class CheckRunTest < ActiveSupport::TestCase end end + test ".create_or_update_from_github! persists a details_url longer than 255 characters" do + # Some integrations link to log files whose path embeds a long workspace name. + details_url = "https://logs.example.com/ci/#{'very-long-workspace-name/' * 16}build.log" + assert_operator details_url.length, :>, 255 + + assert_difference -> { @commit.check_runs.count }, +1 do + @commit.check_runs.create_or_update_from_github!(@stack.id, github_check_run(details_url:)) + end + + assert_equal details_url, @commit.check_runs.find_by!(github_id: 424_242).details_url + end + { nil => 'pending', 'success' => 'success', @@ -154,7 +166,12 @@ class CheckRunTest < ActiveSupport::TestCase private - def github_check_run(conclusion: 'success', completed_at: Time.now, started_at: Time.now - 1.minute) + def github_check_run( + conclusion: 'success', + completed_at: Time.now, + started_at: Time.now - 1.minute, + details_url: 'http://example.com/details' + ) OpenStruct.new( id: 424_242, conclusion:, @@ -163,7 +180,7 @@ def github_check_run(conclusion: 'success', completed_at: Time.now, started_at: ), name: 'Test Suite', html_url: 'http://example.com/run', - details_url: 'http://example.com/details', + details_url:, completed_at:, started_at: )