diffux_ci 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b4b7c2de4ab8683d94cba7d17e480431e4d0c727
4
- data.tar.gz: 0e45a3e707cdb960112dc9f0f6ff37ed01169616
3
+ metadata.gz: 487ecb122914c87206dc4e593571f405b732b71c
4
+ data.tar.gz: 7c49e81764fcf6c5e0553357cab570a7214be0b8
5
5
  SHA512:
6
- metadata.gz: 30a700e0bc8a120ce29fc7a634a740ce32d86cd0169ce2fdd1bb3e7feb70fcea916f7e297ad6bc812c0c0057e1d562a038dcc9df2656aec7b2d99e762823af18
7
- data.tar.gz: 8654640c02c0ea6911ab04c3aa0b04b045f923872b4a7f6efa76370f4961b58b2b425c5d654b399a3896904ec6a77ee38ea0cb65c03fddc855ee05240cc04eb4
6
+ metadata.gz: 45d01fffa9f37fceac8764c6d7d1067e987e49e423aedf736aec068df69267f5330a19c3c9a57b05d699ed20bb64b89d5df96ec122be6e9a0c651307cfbafe20
7
+ data.tar.gz: 8b2c46ca61c72880c664346f58a8ffc6efc5ae3fb14a9d5d8e2bdde22b572d90d8d1554964d4778ae251d9f8585042d6d86602437785a8b043f0bc18defe3535
@@ -8,11 +8,22 @@
8
8
  <h1>Diffux-CI diffs</h1>
9
9
  <p>File generated: <%= Time.now %></p>
10
10
 
11
+ <h2>Diffs</h2>
11
12
  <% diff_images.each do |diff| %>
12
13
  <h3>
13
14
  <%= Rack::Utils.escape_html(diff[:description]) %> @ <%= diff[:viewport] %>
14
15
  </h3>
15
16
  <p><img src="<%= diff[:url] %>"></p>
16
17
  <% end %>
18
+
19
+ <hr>
20
+
21
+ <h2>New examples</h2>
22
+ <% new_images.each do |image| %>
23
+ <h3>
24
+ <%= Rack::Utils.escape_html(image[:description]) %> @ <%= image[:viewport] %>
25
+ </h3>
26
+ <p><img src="<%= image[:url] %>"></p>
27
+ <% end %>
17
28
  </body>
18
29
  </html>
@@ -8,6 +8,7 @@ require 'diffux_core/snapshot_comparison_image/after'
8
8
  require 'oily_png'
9
9
  require 'diffux_ci_utils'
10
10
  require 'fileutils'
11
+ require 'yaml'
11
12
 
12
13
  def resolve_viewports(example)
13
14
  configured_viewports = DiffuxCIUtils.config['viewports']
@@ -50,6 +51,13 @@ begin
50
51
  fail "JavaScript errors found during initialization: \n#{errors.inspect}"
51
52
  end
52
53
 
54
+ # Initialize a hash to store a summary of the results from the run
55
+ result_summary = {
56
+ new_examples: [],
57
+ diff_examples: [],
58
+ okay_examples: []
59
+ }
60
+
53
61
  all_examples = driver.execute_script('return window.diffux.getAllExamples()')
54
62
 
55
63
  # To avoid the overhead of resizing the window all the time, we are going to
@@ -169,10 +177,18 @@ begin
169
177
  print '.'
170
178
 
171
179
  puts " #{comparison[:diff_in_percent].round(1)}% (#{candidate_path})"
180
+ result_summary[:diff_examples] << {
181
+ description: description,
182
+ viewport: viewport['name']
183
+ }
172
184
  else
173
185
  # No visual difference was found, so we don't need to do any more
174
186
  # work.
175
187
  puts ' No diff.'
188
+ result_summary[:okay_examples] << {
189
+ description: description,
190
+ viewport: viewport['name']
191
+ }
176
192
  end
177
193
  else
178
194
  # There was no baseline image yet, so we want to start by saving a new
@@ -185,9 +201,19 @@ begin
185
201
  screenshot.save(baseline_path, :fast_rgba)
186
202
  print '.'
187
203
  puts " First snapshot created (#{baseline_path})"
204
+ result_summary[:new_examples] << {
205
+ description: description,
206
+ viewport: viewport['name']
207
+ }
188
208
  end
189
209
  end
190
210
  end
211
+
212
+ result_summary_file = File.join(DiffuxCIUtils.config['snapshots_folder'],
213
+ 'result_summary.yaml')
214
+ File.open(result_summary_file, 'w') do |file|
215
+ file.write result_summary.to_yaml
216
+ end
191
217
  ensure
192
218
  driver.quit
193
219
  end
@@ -17,16 +17,32 @@ class DiffuxCIUploader
17
17
 
18
18
  dir = SecureRandom.uuid
19
19
 
20
- diff_images = current_snapshots[:diffs].map do |diff|
20
+ result_summary = YAML.load(File.read(File.join(
21
+ DiffuxCIUtils.config['snapshots_folder'], 'result_summary.yaml')))
22
+ diff_images = result_summary[:diff_examples].map do |diff|
21
23
  image = bucket.objects.build(
22
24
  "#{dir}/#{diff[:description]}_#{diff[:viewport]}.png")
23
- image.content = open(diff[:file])
25
+ image.content = open(DiffuxCIUtils.path_to(diff[:description],
26
+ diff[:viewport],
27
+ 'diff.png'))
24
28
  image.content_type = 'image/png'
25
29
  image.save
26
30
  diff[:url] = image.url
27
31
  diff
28
32
  end
29
33
 
34
+ new_images = result_summary[:new_examples].map do |example|
35
+ image = bucket.objects.build(
36
+ "#{dir}/#{example[:description]}_#{example[:viewport]}.png")
37
+ image.content = open(DiffuxCIUtils.path_to(example[:description],
38
+ example[:viewport],
39
+ 'baseline.png'))
40
+ image.content_type = 'image/png'
41
+ image.save
42
+ example[:url] = image.url
43
+ example
44
+ end
45
+
30
46
  html = bucket.objects.build("#{dir}/index.html")
31
47
  path = File.expand_path(
32
48
  File.join(File.dirname(__FILE__), 'diffux_ci-diffs.html.erb'))
@@ -34,7 +34,7 @@ class DiffuxCIUtils
34
34
  end
35
35
 
36
36
  def self.normalize_description(description)
37
- Base64.encode64(description)
37
+ Base64.encode64(description).strip
38
38
  end
39
39
 
40
40
  def self.path_to(description, viewport_name, file_name)
@@ -1,4 +1,4 @@
1
1
  # Defines the gem version.
2
2
  module DiffuxCI
3
- VERSION = '0.4.1'
3
+ VERSION = '0.4.2'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: diffux_ci
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henric Trotzig