Skip to content
Merged

0.45.5 #1509

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
26 changes: 13 additions & 13 deletions app/views/shipit/stacks/_banners.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,18 @@
</div>
<% end %>

<% if stack.continuous_delivery_delayed? %>
<% if !stack.deployment_checks_passed? %>
<div class="banner banner--orange">
<div class="banner__inner wrapper">
<div class="banner__content">
<h2 class="banner__title">Stack has been locked by external system!</h2>
<p class = "banner__text">
<%= simple_format(deployment_checks_message(stack)) %>
</p>
</div>
</div>
</div>
<% elsif stack.continuous_delivery_delayed? %>
<div class="banner">
<div class="banner__inner wrapper">
<div class="banner__content">
Expand All @@ -71,7 +82,7 @@
Continuous Delivery for this stack is currently paused because

<% if stack.next_commit_to_deploy %>
<%= link_to_if stack.deployment_checks_passed?, 'the pre-deploy checks failed', stack_commit_checks_path(stack, sha: stack.next_commit_to_deploy.sha) %>.
<%= link_to 'the pre-deploy checks failed', stack_commit_checks_path(stack, sha: stack.next_commit_to_deploy.sha) %>.
<% else %>
the pre-deploy checks failed.
<% end %>
Expand All @@ -80,15 +91,4 @@
</div>
</div>
</div>
<% elsif !stack.deployment_checks_passed? %>
<div class="banner banner--orange">
<div class="banner__inner wrapper">
<div class="banner__content">
<h2 class="banner__title">Stack has been locked by external system!</h2>
<p class = "banner__text">
<%= simple_format(deployment_checks_message(stack)) %>
</p>
</div>
</div>
</div>
<% end %>
2 changes: 1 addition & 1 deletion lib/shipit/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Shipit
VERSION = '0.45.4'
VERSION = '0.45.5'
end
38 changes: 38 additions & 0 deletions test/controllers/stacks_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
6 changes: 3 additions & 3 deletions test/dummy/db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
21 changes: 19 additions & 2 deletions test/models/shipit/check_run_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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:,
Expand All @@ -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:
)
Expand Down
Loading