From a70eccd6bac824ab9e2d674fbe2e57208d8bf6e4 Mon Sep 17 00:00:00 2001 From: David Singleton Date: Wed, 21 Jan 2015 12:37:56 +0000 Subject: [PATCH 1/9] Improve rendering of commit hashes in log We don't need the full hash, the short version will do, and won't interfer with the rest of the commit information. Also make it fixed width font for better readability --- app/assets/stylesheets/application.scss | 4 ++++ app/views/applications/show.html.erb | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 4e84142d9..edb4eb4d5 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -21,3 +21,7 @@ h1 { @extend .text-muted; padding-left: 1em; } + +.commit-hash { + font-family: monospace; +} diff --git a/app/views/applications/show.html.erb b/app/views/applications/show.html.erb index c524919dc..36e892581 100644 --- a/app/views/applications/show.html.erb +++ b/app/views/applications/show.html.erb @@ -62,7 +62,7 @@ <% end %> - <%= link_to commit[:sha], "#{@application.repo_url}/commit/#{commit[:sha]}", target: "_blank", class: "pull-right" %> + <%= link_to commit[:sha][0..8], "#{@application.repo_url}/commit/#{commit[:sha]}", target: "_blank", class: "commit-hash pull-right" %> From 3358cd1833aee86df7083c3281043164a3807629 Mon Sep 17 00:00:00 2001 From: David Singleton Date: Wed, 21 Jan 2015 15:25:05 +0000 Subject: [PATCH 2/9] Slightly improved UI for marking tags that are on staging/prod --- app/assets/stylesheets/application.scss | 19 +++++++++++++++++++ app/views/applications/show.html.erb | 9 +++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index edb4eb4d5..51b29bce6 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -25,3 +25,22 @@ h1 { .commit-hash { font-family: monospace; } + +.deployment { + margin: 0 0 10px 0; + + .env { + min-width: 8em; + } + + time { + // to match `.label` + font-size: 75%; + } + + &.production { + .env { + background: $production-color + } + } +} diff --git a/app/views/applications/show.html.erb b/app/views/applications/show.html.erb index 36e892581..0ff37d363 100644 --- a/app/views/applications/show.html.erb +++ b/app/views/applications/show.html.erb @@ -37,10 +37,11 @@ <% tags.each do |tag| %> <% if deployments = @latest_deploy_to_each_environment_by_version[tag[:name]] %> <% deployments.each do |deployment| %> - <%= deployment.environment %> - at - <%= human_datetime(deployment.created_at) %> -
+

+ <%= deployment.environment.humanize %> + at + <%= time_tag(deployment.created_at, human_datetime(deployment.created_at)) %> +

<% end %> <% end %> <% end %> From 87743e81db8463d1a7e94360cadb8d29ec8c1d44 Mon Sep 17 00:00:00 2001 From: David Singleton Date: Wed, 21 Jan 2015 16:54:03 +0000 Subject: [PATCH 3/9] Add a 'candidate release' view, to be using during deployment Simplify deployment process by giving you one page with all the links and information you should need to do a deploy. - Navigate to the new view from the list of commits/tags for an application - See where production is, what release and how old - Preview what commits, and authors, this release will contain with a link to view the full file diff on github - Deep link to the staging/production deploy jobs, prefilling the application and release tag --- app/assets/stylesheets/application.scss | 7 ++ app/controllers/applications_controller.rb | 27 ++++++- app/models/application.rb | 8 ++ app/views/applications/deploy.html.erb | 85 ++++++++++++++++++++++ app/views/applications/show.html.erb | 2 +- config/routes.rb | 4 + 6 files changed, 128 insertions(+), 5 deletions(-) create mode 100644 app/views/applications/deploy.html.erb diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 51b29bce6..dc89dd642 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -22,6 +22,7 @@ h1 { padding-left: 1em; } +table.commits td.hash, .commit-hash { font-family: monospace; } @@ -44,3 +45,9 @@ h1 { } } } + +.release-tag { + &.label a { + color: #fff; + } +} diff --git a/app/controllers/applications_controller.rb b/app/controllers/applications_controller.rb index 89f2399d7..aaa131226 100644 --- a/app/controllers/applications_controller.rb +++ b/app/controllers/applications_controller.rb @@ -1,6 +1,6 @@ class ApplicationsController < ApplicationController before_filter :redirect_if_read_only_user, only: [:new, :edit, :create, :update, :update_notes] - before_filter :find_application, only: [:show, :edit, :update, :update_notes] + before_filter :find_application, only: [:show, :edit, :update, :update_notes, :deploy] def index @environments = ["staging", "production"] @@ -25,11 +25,11 @@ def show @latest_deploy_to_each_environment_by_version[deployment.version] << deployment end - production_deploy = @application.deployments.last_deploy_to "production" - if production_deploy + @production_deploy = @application.deployments.last_deploy_to "production" + if @production_deploy comparison = github.compare( @application.repo, - production_deploy.version, + @production_deploy.version, "master" ) # The `compare` API shows commits in forward chronological order @@ -52,6 +52,25 @@ def new def edit end + def deploy + @release_tag = params[:tag] + + @production_deploy = @application.deployments.last_deploy_to "production" + if @production_deploy + comparison = github.compare( + @application.repo, + @production_deploy.version, + @release_tag + ) + # The `compare` API shows commits in forward chronological order + @commits = comparison.commits.reverse + end + @github_available = true + rescue Octokit::NotFound => e + @github_available = false + @github_error = e + end + def create @application = Application.new(params[:application]) diff --git a/app/models/application.rb b/app/models/application.rb index 5f56319a1..bdebf2014 100644 --- a/app/models/application.rb +++ b/app/models/application.rb @@ -52,4 +52,12 @@ def fallback_shortname def repo_url "https://#{domain}/#{repo}" end + + def repo_compare_url(from, to) + "https://#{domain}/#{repo}/compare/#{from}...#{to}" + end + + def repo_tag_url(tag) + "https://#{domain}/#{repo}/releases/tag/#{tag}" + end end diff --git a/app/views/applications/deploy.html.erb b/app/views/applications/deploy.html.erb new file mode 100644 index 000000000..70c37954f --- /dev/null +++ b/app/views/applications/deploy.html.erb @@ -0,0 +1,85 @@ +<% content_for :page_title, @application.name %> + + + +
+

Candidate Release <%= @release_tag %>

+

Production was deployed to <%= @production_deploy.version %><%= time_ago_in_words(@production_deploy.created_at) %> ago

+ + <% unless @application.staging_and_production_in_sync? %> +
+
Production and Staging are not in sync
+
Proceed with caution and check the differences between production and staging
+
+ <% end %> + +

+ + Full Diff + +

+ +

<%= @commits.length %> <%= 'commit'.pluralize(@commits.length) %>

+ + <% if @github_available %> + + + + + + + + + + <% @commits.each do |commit| %> + + + + + + <% end %> + +
HashCommitAuthor
+ <%= link_to commit[:sha][0..8], "#{@application.repo_url}/commit/#{commit[:sha]}", target: "_blank" %> + +

<%= commit[:commit][:message].split(/\n/)[0] %>

+
+ <% if commit[:commit][:author] %> + + + <%= commit[:commit][:author][:name] %> + + <% end %> +
+<% else %> +
+ Couldn't get data from GitHub: +
+ <%= @github_error %> +
+<% end %> + + +

Deploy

+
+
+ Obey the Badger of Deploy +
+ +
+

Test on Staging

+

Make sure you're using the govuk_select_organisation script to test against the staging environment.

+

Deploy to Staging

+ +

Promote to Production

+

Deploy to Production

+
+
+ +
diff --git a/app/views/applications/show.html.erb b/app/views/applications/show.html.erb index 0ff37d363..21725422c 100644 --- a/app/views/applications/show.html.erb +++ b/app/views/applications/show.html.erb @@ -48,7 +48,7 @@ <% tags.each do |tag| %> - <%= tag[:name] %> + <%= tag[:name] %> <% end %> <% else %> diff --git a/config/routes.rb b/config/routes.rb index baae759e1..7214a2c21 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -8,6 +8,10 @@ put :update_notes end + member do + get :deploy + end + resources :deployments end From a83ca4cf067ebbff79eaad8bccf990478006b2b0 Mon Sep 17 00:00:00 2001 From: David Singleton Date: Thu, 22 Jan 2015 17:16:38 +0000 Subject: [PATCH 4/9] Add filtering for commits table - Can filter to just merge commits, or by author, or even by hash - Fix width of the columns so they don't wobble as you filter --- app/views/applications/deploy.html.erb | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/app/views/applications/deploy.html.erb b/app/views/applications/deploy.html.erb index 70c37954f..04cb55c68 100644 --- a/app/views/applications/deploy.html.erb +++ b/app/views/applications/deploy.html.erb @@ -28,13 +28,21 @@

<%= @commits.length %> <%= 'commit'.pluralize(@commits.length) %>

<% if @github_available %> - +
- - - + + + + + + <% @commits.each do |commit| %> @@ -43,7 +51,7 @@ <%= link_to commit[:sha][0..8], "#{@application.repo_url}/commit/#{commit[:sha]}", target: "_blank" %> - + + - - - + <% end %> From ea6d5796dfccbf9a8e87c49aad08df14575669a2 Mon Sep 17 00:00:00 2001 From: David Singleton Date: Mon, 26 Jan 2015 14:15:31 +0000 Subject: [PATCH 8/9] Fix broken author image, rebase this later --- app/views/applications/deploy.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/applications/deploy.html.erb b/app/views/applications/deploy.html.erb index 637fa026e..03ea9cad1 100644 --- a/app/views/applications/deploy.html.erb +++ b/app/views/applications/deploy.html.erb @@ -62,7 +62,7 @@
HashCommitAuthorHashCommitAuthor
+
+ + +
+
-

<%= commit[:commit][:message].split(/\n/)[0] %>

+ <%= commit[:commit][:message].split(/\n/)[0] %>
<% if commit[:commit][:author] %> From a439d3f6bc012256b3b6b1e5b71586d8504c4c03 Mon Sep 17 00:00:00 2001 From: David Singleton Date: Thu, 22 Jan 2015 17:26:44 +0000 Subject: [PATCH 5/9] Include commit message for additional detail --- app/views/applications/deploy.html.erb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/views/applications/deploy.html.erb b/app/views/applications/deploy.html.erb index 04cb55c68..c2b6da586 100644 --- a/app/views/applications/deploy.html.erb +++ b/app/views/applications/deploy.html.erb @@ -51,7 +51,11 @@ <%= link_to commit[:sha][0..8], "#{@application.repo_url}/commit/#{commit[:sha]}", target: "_blank" %> - <%= commit[:commit][:message].split(/\n/)[0] %> + <% summary, body = commit[:commit][:message].split(/\n/, 2) %> +

<%= summary %>

+ <% if body %> + <%= simple_format(body.strip) %> + <% end %>
<% if commit[:commit][:author] %> From 0ce4fda835a169491c43baeca49c15bda483b346 Mon Sep 17 00:00:00 2001 From: David Singleton Date: Fri, 23 Jan 2015 13:13:40 +0000 Subject: [PATCH 6/9] Tweaked 'where is production' phrasing --- app/views/applications/deploy.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/applications/deploy.html.erb b/app/views/applications/deploy.html.erb index c2b6da586..a974d85be 100644 --- a/app/views/applications/deploy.html.erb +++ b/app/views/applications/deploy.html.erb @@ -10,7 +10,7 @@

Candidate Release <%= @release_tag %>

-

Production was deployed to <%= @production_deploy.version %><%= time_ago_in_words(@production_deploy.created_at) %> ago

+

Production is <%= @production_deploy.version %> — deployed at <%= human_datetime(@production_deploy.created_at) %>

<% unless @application.staging_and_production_in_sync? %>
From c79b137a14c4d8ab1f145a9f358c36ea35392158 Mon Sep 17 00:00:00 2001 From: David Singleton Date: Mon, 26 Jan 2015 12:59:12 +0000 Subject: [PATCH 7/9] Add date information to release diff commit view - Add link to the commit summary - Add some other semantic/styling hooks --- app/views/applications/deploy.html.erb | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/app/views/applications/deploy.html.erb b/app/views/applications/deploy.html.erb index a974d85be..637fa026e 100644 --- a/app/views/applications/deploy.html.erb +++ b/app/views/applications/deploy.html.erb @@ -32,11 +32,12 @@
HashCommitMessage AuthorDate
+
@@ -50,14 +51,16 @@
<%= link_to commit[:sha][0..8], "#{@application.repo_url}/commit/#{commit[:sha]}", target: "_blank" %> + <% summary, body = commit[:commit][:message].split(/\n/, 2) %> -

<%= summary %>

+

" target="_blank"><%= summary %>

<% if body %> - <%= simple_format(body.strip) %> +
+ <%= simple_format(body.strip) %> +
<% end %>
+ <% if commit[:commit][:author] %> @@ -65,6 +68,13 @@ <% end %> + <% if commit[:commit][:author] %> + <% commit_date = commit[:commit][:author][:date] %> + <%= commit_date.to_date.to_s(:govuk_date) =%> + <%= commit_date.to_s(:govuk_time) =%> + <% end %> +
<% if commit[:commit][:author] %> - + <%= commit[:commit][:author][:name] %> From 3a98e0c33dbb0815996c3118a1f138ab2abfe93b Mon Sep 17 00:00:00 2001 From: David Singleton Date: Wed, 28 Jan 2015 14:24:38 +0000 Subject: [PATCH 9/9] Remove commit body, fix images full commit messages can be long, especially for many changes, taking up a huge amount of space. as the full commits are available on the github diff we can probably omit this. --- app/views/applications/deploy.html.erb | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/app/views/applications/deploy.html.erb b/app/views/applications/deploy.html.erb index 03ea9cad1..bba79fa3e 100644 --- a/app/views/applications/deploy.html.erb +++ b/app/views/applications/deploy.html.erb @@ -20,6 +20,9 @@ <% end %>

+ + Show full Commit + Full Diff @@ -53,16 +56,11 @@

<% summary, body = commit[:commit][:message].split(/\n/, 2) %> -

" target="_blank"><%= summary %>

- <% if body %> -
- <%= simple_format(body.strip) %> -
- <% end %> + " target="_blank"><%= summary %>
<% if commit[:commit][:author] %> - + <%= commit[:commit][:author][:name] %> @@ -71,7 +69,7 @@ <% if commit[:commit][:author] %> <% commit_date = commit[:commit][:author][:date] %> - <%= commit_date.to_date.to_s(:govuk_date) =%> + <%= commit_date.to_date.to_s(:short) =%> <%= commit_date.to_s(:govuk_time) =%> <% end %>