13668: Adds package version to workbench. Reports versions on dialog.
authorLucas Di Pentima <ldipentima@veritasgenetics.com>
Mon, 9 Jul 2018 21:01:19 +0000 (18:01 -0300)
committerLucas Di Pentima <ldipentima@veritasgenetics.com>
Mon, 9 Jul 2018 21:01:19 +0000 (18:01 -0300)
API & Workbench package versions are displayed on the 'Show version' &
'Report problem' dialogs.

Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <ldipentima@veritasgenetics.com>

apps/workbench/app/helpers/version_helper.rb
apps/workbench/app/views/application/_report_issue_popup.html.erb
apps/workbench/config/application.default.yml
apps/workbench/lib/app_version.rb

index 915c3a9d381984abec802e78680f84a23ec54b6e..c372adbe122f7a967318bd8ef8b940d221a1b4f1 100644 (file)
@@ -9,6 +9,12 @@ module VersionHelper
     arvados_api_client.discovery[:source_version]
   end
 
+  # Get the package_version given in the API server's discovery
+  # document.
+  def api_package_version
+    arvados_api_client.discovery[:package_version]
+  end
+
   # URL for browsing source code for the given version.
   def version_link_target version
     "https://arvados.org/projects/arvados/repository/changes?rev=#{version.sub(/-.*/, "")}"
index 86d550a33f34dc8bbccceb556164c76c5bf8a03b..8823fdd5f78f8ebfe7c4a336c3a144bc479de26f 100644 (file)
@@ -14,8 +14,10 @@ SPDX-License-Identifier: AGPL-3.0 %>
   additional_info_str = additional_info.map {|k,v| "#{k}=#{v}"}.join("\n")
 
   additional_info['api_source_version'] = api_source_version
+  additional_info['api_package_version'] = api_package_version
   additional_info['generated_at'] = generated_at
   additional_info['workbench_version'] = AppVersion.hash
+  additional_info['workbench_package_version'] = AppVersion.package_version
   additional_info['arvados_base'] = arvados_base
   additional_info['support_email'] = support_email
   additional_info['error_message'] = params[:error_message] if params[:error_message]
@@ -73,7 +75,7 @@ SPDX-License-Identifier: AGPL-3.0 %>
           <label for="wb_version" class="col-sm-4 control-label"> Workbench version </label>
           <div class="col-sm-8">
             <p class="form-control-static" name="wb_version">
-              <%= link_to AppVersion.hash, version_link_target(AppVersion.hash) %>
+              <%= AppVersion.package_version %> (<%= link_to AppVersion.hash, version_link_target(AppVersion.hash) %>)
             </p>
           </div>
         </div>
@@ -82,7 +84,7 @@ SPDX-License-Identifier: AGPL-3.0 %>
           <label for="server_version" class="col-sm-4 control-label"> API version </label>
           <div class="col-sm-8">
             <p class="form-control-static" name="server_version">
-              <%= link_to api_source_version, version_link_target(api_source_version) %>
+              <%= api_package_version %> (<%= link_to api_source_version, version_link_target(api_source_version) %>)
             </p>
           </div>
         </div>
index d5f46feab6db211f52bd90533e4b329dc75f3162..e4ec4131286dac66d9a12947ad6d0ddd6bbad358 100644 (file)
@@ -201,6 +201,11 @@ common:
   # "git log".
   source_version: false
 
+  # Override the automatic package string. With the default value of
+  # false, the package string is read from package-build.version in
+  # Rails.root (included in vendor packages).
+  package_version: false
+
   # report notification to and from addresses
   issue_reporter_email_from: arvados@example.com
   issue_reporter_email_to: arvados@example.com
index cc4b4dee1928f0a6b278d80c9887999cbc6c2f5d..303d853ec5420ee3dffefbf34c789bb8689a769c 100644 (file)
@@ -15,6 +15,7 @@ class AppVersion
 
   def self.forget
     @hash = nil
+    @package_version = nil
   end
 
   # Return abbrev commit hash for current code version: "abc1234", or
@@ -54,4 +55,17 @@ class AppVersion
 
     @hash || "unknown"
   end
+
+  def self.package_version
+    if (cached = Rails.configuration.package_version || @package_version)
+      return cached
+    end
+
+    begin
+      @package_version = IO.read(Rails.root.join("package-build.version")).strip
+    rescue Errno::ENOENT
+    end
+
+    @package_version || "unknown"
+  end
 end