Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indicate the environment on test results #4

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
12 changes: 8 additions & 4 deletions lib/gitlab.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@ module Gitlab
# The FailedTest class encapsulates all the information related to a failed
# test within a pipeline job.
class FailedTest
attr_accessor :ref, :comment, :has_screenshot, :int_suite_version, :sequencescape_version, :limber_version,
:is_flaky
attr_accessor :ref, :comment, :has_screenshot, :environment,
:int_suite_version, :sequencescape_version,
:limber_version, :is_flaky

def initialize(location, description, job_url, has_screenshot)
@ref = location
@comment = description
@job_url = job_url
@has_screenshot = has_screenshot
@environment = nil
@int_suite_version = nil
@sequencescape_version = nil
@limber_version = nil
Expand Down Expand Up @@ -154,10 +156,12 @@ def self.pipeline_status(pipeline)
def self.extract_application_versions(html_summary)
versions = {}
if html_summary.include?('Application versions')
regex = %r{Application versions deployed in \w+ environment:(.*)<br/><br/>}
regex = %r{Application versions deployed in (?<environment>\w+) environment:(?<versions>.*)<br/><br/>}
match = html_summary.match(regex)
if match
match[1].strip.split('<br/>').each do |line|
environment = match[:environment]
versions['environment'] = environment
match[:versions].strip.split('<br/>').each do |line|
next unless line.start_with?(' ')

parts = line.strip.split
Expand Down
13 changes: 8 additions & 5 deletions lib/integration_suite.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,24 @@
require 'set'
require_relative 'gitlab'

UNKNOWN_VERSION = CGI.escapeHTML('<unknown>')
UNKNOWN = CGI.escapeHTML('<unknown>')

# The IntegrationSuite module encapsulates all the logic related to the
# Integration Suite, its pipelines, and interations between applications.
module IntegrationSuite
def self.group_pipelines(pipelines)
# Group pipelines by int_suite, sequencescape, and limber versions.
# Group pipelines by environment, int_suite, sequencescape, and limber versions.
grouped_pipelines = Hash.new { |hash, key| hash[key] = [] }

pipelines.each do |pipeline|
key = [
pipeline['versions']['environment'],
pipeline['versions']['int_suite'],
pipeline['versions']['sequencescape'],
pipeline['versions']['limber']
]

next if key.include?(UNKNOWN_VERSION) # Skip pipelines with unknown versions
next if key.include?(UNKNOWN) # Skip pipelines with unknown versions
next unless pipeline['tested?'] # Skip pipelines where tests were not executed

grouped_pipelines[key] << pipeline
Expand Down Expand Up @@ -61,15 +62,17 @@ def self.compile_pipelines(filters = {})
# Get the application versions
gitlab_versions = Gitlab.application_versions(pipeline) || {}
default_versions = {
'environment' => '',
'int_suite' => pipeline['int_suite_version'],
'sequencescape' => UNKNOWN_VERSION,
'limber' => UNKNOWN_VERSION
'sequencescape' => UNKNOWN,
'limber' => UNKNOWN
}
versions = default_versions.merge(gitlab_versions)
pipeline['versions'] = versions

# Apply the versions to the failed tests for analysis
pipeline['failed_tests'].each do |failed_test|
failed_test.environment = versions['environment']
failed_test.int_suite_version = versions['int_suite']
failed_test.sequencescape_version = versions['sequencescape']
failed_test.limber_version = versions['limber']
Expand Down
33 changes: 24 additions & 9 deletions views/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,17 @@
}
.application-label {
display: inline-block;
width: 1.4em;
padding-right: 0.2em;
font-size: 0.9em;
font-weight: bold;
}
.circle {
display: inline-block;
width: 0.7em;
height: 0.7em;
width: 0.8em;
height: 0.8em;
vertical-align: middle;
border-radius: 50%;
border: 1px solid #333;
border: 0.5px solid #aaa;
}
.status-success {
color: var(--bs-success);
Expand All @@ -61,6 +62,15 @@
.status-running {
color: var(--bs-info);
}
.env-uat {
background-color: var(--bs-danger);
}
.env-training {
background-color: var(--bs-success);
}
.env-production {
background-color: var(--bs-primary);
}
</style>
</head>
<body class="body-bg container-xl p-4">
Expand Down Expand Up @@ -127,7 +137,7 @@
<% pipelines.each do |pipeline| %>
<div class="card mt-3">
<div class="card-header">
<div class="row">
<div class="row g-2">
<span class="col-12">
<%= pipeline['createdAt'].gsub('T', ' ')[0, 16] %>
<a href="<%= gitlab_url %>/psd/integration-suite/-/pipelines/<%= pipeline['id'] %>"
Expand All @@ -141,19 +151,24 @@
</span>
</div>
<div class="row">
<span class="col-12 col-lg-3 offset-lg-1">
<span class="col-12 col-lg-3">
<span class="circle me-1 env-<%= pipeline['versions']['environment'] %>"></span>
<span class="application-label" title="Integration Suite">ENV</span>
<code><%= pipeline['versions']['environment'] %></code>
</span>
<span class="col-12 col-lg-3">
<span class="circle me-1"
style="background-color: #<%= pipeline['versions']['int_suite'][-6..] %>"></span>
<span class="application-label" title="Integration Suite">IS</span>
<code><%= pipeline['versions']['int_suite'] %></code>
</span>
<span class="col-12 col-lg-4">
<span class="col-12 col-lg-3">
<span class="circle me-1"
style="background-color: #<%= pipeline['versions']['sequencescape'][-6..] %>"></span>
<span class="application-label" title="Sequencescape">SS</span>
<code><%= pipeline['versions']['sequencescape'] %></code>
</span>
<span class="col-12 col-lg-4">
<span class="col-12 col-lg-3">
<span class="circle me-1"
style="background-color: #<%= pipeline['versions']['limber'][-6..] %>"></span>
<span class="application-label" title="Limber">LB</span>
Expand All @@ -165,7 +180,7 @@
<ul class='list-group list-group-flush'>
<% pipeline['failed_tests'].each do |failed_test| %>
<li class='list-group-item py-1 small'>
<% if failed_test.is_flaky %><span class="badge bg-warning text-dark">Flaky</span><% end %>
<% if failed_test.is_flaky %><span class="badge bg-warning text-dark">⚠ flaky</span><% end %>
<span class="font-monospace"><%= failed_test.ref %></span><span class="ms-2 text-secondary"><%= failed_test.comment %></span>
<% if failed_test.has_screenshot %>
<a href="<%= failed_test.screenshot_path %>" target="_blank" class="float-end"><i class="bi bi-window"></i></a>
Expand Down